Struct twilight_http::request::guild::create_guild::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>
impl<'a> CreateGuild<'a>
sourcepub fn add_role(self, role: RoleFields) -> Self
pub fn add_role(self, role: RoleFields) -> Self
Add a role to the list of roles.
sourcepub const fn afk_channel_id(self, afk_channel_id: Id<ChannelMarker>) -> Self
pub const 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
.
sourcepub const fn afk_timeout(self, afk_timeout: AfkTimeout) -> Self
pub const fn afk_timeout(self, afk_timeout: AfkTimeout) -> Self
Set the AFK timeout, in seconds.
sourcepub fn channels(
self,
channels: Vec<GuildChannelFields>
) -> Result<Self, CreateGuildError>
pub fn channels( self, channels: Vec<GuildChannelFields> ) -> Result<Self, CreateGuildError>
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.
sourcepub const fn default_message_notifications(
self,
default_message_notifications: DefaultMessageNotificationLevel
) -> Self
pub const fn default_message_notifications( self, default_message_notifications: DefaultMessageNotificationLevel ) -> Self
Set the default message notification level. See Discord Docs/Create Guild.
sourcepub const fn explicit_content_filter(
self,
explicit_content_filter: ExplicitContentFilter
) -> Self
pub const fn explicit_content_filter( self, explicit_content_filter: ExplicitContentFilter ) -> Self
Set the explicit content filter level.
sourcepub fn icon(self, icon: &'a str) -> Self
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.
sourcepub fn override_everyone(self, everyone: RoleFields) -> Self
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.
sourcepub const fn system_channel_id(
self,
system_channel_id: Id<ChannelMarker>
) -> Self
pub const 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
.
sourcepub const fn system_channel_flags(
self,
system_channel_flags: SystemChannelFlags
) -> Self
pub const fn system_channel_flags( self, system_channel_flags: SystemChannelFlags ) -> Self
Set the guild’s SystemChannelFlags
.
sourcepub fn roles(self, roles: Vec<RoleFields>) -> Result<Self, CreateGuildError>
pub fn roles(self, roles: Vec<RoleFields>) -> Result<Self, CreateGuildError>
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.
sourcepub fn exec(self) -> ResponseFuture<PartialGuild> ⓘ
👎Deprecated since 0.14.0: use .await
or into_future
instead
pub fn exec(self) -> ResponseFuture<PartialGuild> ⓘ
.await
or into_future
insteadExecute the request, returning a future resolving to a Response
.