twilight_http::request::guild::create_guild

Struct CreateGuild

source
pub struct CreateGuild<'a> { /* private fields */ }
Expand description

Create a new request to create a guild.

The minimum length of the name is 2 UTF-16 characters and the maximum is 100 UTF-16 characters. This endpoint can only be used by bots in less than 10 guilds.

Implementations§

source§

impl<'a> CreateGuild<'a>

source

pub fn add_role(self, role: RoleFields) -> Self

Add a role to the list of roles.

source

pub fn afk_channel_id(self, afk_channel_id: Id<ChannelMarker>) -> Self

Set the ID of the AFK voice channel.

This must be an ID specified in channels.

source

pub fn afk_timeout(self, afk_timeout: AfkTimeout) -> Self

Set the AFK timeout, in seconds.

source

pub fn channels(self, channels: Vec<GuildChannelFields>) -> Self

Set the channels to create with the guild.

The maximum number of channels that can be provided is 500.

§Examples
use twilight_http::{
    request::guild::create_guild::{
        CategoryFieldsBuilder, GuildChannelFieldsBuilder, TextFieldsBuilder, VoiceFieldsBuilder,
    },
    Client,
};

let text = TextFieldsBuilder::new("text channel".to_owned()).build()?;
let voice = VoiceFieldsBuilder::new("voice channel".to_owned()).build()?;
let text2 = TextFieldsBuilder::new("other text channel".to_owned())
    .topic("posting".to_owned())
    .build()?;

let category = CategoryFieldsBuilder::new("category channel".to_owned())
    .add_text(text2)
    .add_voice(voice);

let channels = GuildChannelFieldsBuilder::new()
    .add_text(text)
    .add_category_builder(category)
    .build()?;

let guild = client
    .create_guild("guild name".to_owned())
    .channels(channels)
    .await?;
§Errors

Returns a CreateGuildErrorType::TooManyChannels error type if the number of channels is over 500.

source

pub fn default_message_notifications( self, default_message_notifications: DefaultMessageNotificationLevel, ) -> Self

Set the default message notification level. See Discord Docs/Create Guild.

source

pub fn explicit_content_filter( self, explicit_content_filter: ExplicitContentFilter, ) -> Self

Set the explicit content filter level.

source

pub fn icon(self, icon: &'a str) -> Self

Set the icon.

This must be a Data URI, in the form of data:image/{type};base64,{data} where {type} is the image MIME type and {data} is the base64-encoded image. See Discord Docs/Image Data.

source

pub fn override_everyone(self, everyone: RoleFields) -> Self

Override the everyone role of the guild.

If there are not yet roles set with roles, this will create a role override in the first position. Discord understands the first role in the list to override @everyone. If there are roles, this replaces the first role in the position.

source

pub fn system_channel_id(self, system_channel_id: Id<ChannelMarker>) -> Self

Set the channel where system messages will be posted.

This must be an ID specified in channels.

source

pub fn system_channel_flags( self, system_channel_flags: SystemChannelFlags, ) -> Self

Set the guild’s SystemChannelFlags.

source

pub fn roles(self, roles: Vec<RoleFields>) -> Self

Set the roles to create with the guild.

The maximum number of roles that can be provided is 250.

§Examples
use twilight_http::{request::guild::create_guild::RoleFieldsBuilder, Client};

let roles = vec![RoleFieldsBuilder::new("role 1".to_owned())
    .color(0x543923)
    .build()?];
client
    .create_guild("guild name".to_owned())
    .roles(roles)
    .await?;
§Errors

Returns a CreateGuildErrorType::TooManyRoles error type if the number of roles is over 250.

Trait Implementations§

source§

impl IntoFuture for CreateGuild<'_>

source§

type Output = Result<Response<PartialGuild>, Error>

The output that the future will produce on completion.
source§

type IntoFuture = ResponseFuture<PartialGuild>

Which kind of future are we turning this into?
source§

fn into_future(self) -> Self::IntoFuture

Creates a future from a value. Read more
source§

impl TryIntoRequest for CreateGuild<'_>

source§

fn try_into_request(self) -> Result<Request, HttpError>

Try to convert a request builder into a raw Request. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for CreateGuild<'a>

§

impl<'a> !RefUnwindSafe for CreateGuild<'a>

§

impl<'a> Send for CreateGuild<'a>

§

impl<'a> Sync for CreateGuild<'a>

§

impl<'a> Unpin for CreateGuild<'a>

§

impl<'a> !UnwindSafe for CreateGuild<'a>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more