pub struct EditGuild<'a> { /* private fields */ }
Expand description
A builder to optionally edit certain fields of a guild
Implementations§
Source§impl<'a> EditGuild<'a>
impl<'a> EditGuild<'a>
Sourcepub fn new() -> Self
pub fn new() -> Self
Equivalent to Self::default
.
Sourcepub fn afk_channel(self, channel: Option<ChannelId>) -> Self
pub fn afk_channel(self, channel: Option<ChannelId>) -> Self
Set the “AFK voice channel” that users are to move to if they have been AFK for an amount
of time, configurable by Self::afk_timeout
. Pass None
to unset the current value.
Sourcepub fn afk_timeout(self, timeout: AfkTimeout) -> Self
pub fn afk_timeout(self, timeout: AfkTimeout) -> Self
Set the amount of time a user is to be moved to the AFK channel - configured via
Self::afk_channel
- after being AFK.
Sourcepub fn icon(self, icon: Option<&CreateAttachment>) -> Self
pub fn icon(self, icon: Option<&CreateAttachment>) -> Self
Set the icon of the guild. Pass None
to remove the icon.
§Examples
Using the utility builder - CreateAttachment
- to read an image and encode it in
base64, to then set as the guild icon.
let icon = CreateAttachment::path("./guild_icon.png").await?;
// assuming a `guild` has already been bound
let builder = EditGuild::new().icon(Some(&icon));
guild.edit(&http, builder).await?;
Sourcepub fn delete_icon(self) -> Self
pub fn delete_icon(self) -> Self
Clear the current guild icon, resetting it to the default logo.
Sourcepub fn name(self, name: impl Into<String>) -> Self
pub fn name(self, name: impl Into<String>) -> Self
Set the name of the guild.
Note: Must be between (and including) 2-100 characters.
Sourcepub fn description(self, name: impl Into<String>) -> Self
pub fn description(self, name: impl Into<String>) -> Self
Set the description of the guild.
Note: Requires that the guild have the DISCOVERABLE
feature enabled. You can check
this through a guild’s features
list.
Sourcepub fn features(self, features: Vec<String>) -> Self
pub fn features(self, features: Vec<String>) -> Self
Set the features of the guild.
Note: Requires that the guild have the DISCOVERABLE
feature enabled. You can check
this through a guild’s features
list.
Sourcepub fn owner(self, user_id: impl Into<UserId>) -> Self
pub fn owner(self, user_id: impl Into<UserId>) -> Self
Transfers the ownership of the guild to another user by Id.
Note: The current user must be the owner of the guild.
Sourcepub fn splash(self, splash: Option<String>) -> Self
pub fn splash(self, splash: Option<String>) -> Self
Set the splash image of the guild on the invitation page.
The splash
must be base64-encoded 1024x1024 png/jpeg/gif image-data.
Requires that the guild have the INVITE_SPLASH
feature enabled. You can check this
through a guild’s features
list.
Sourcepub fn discovery_splash(self, splash: Option<String>) -> Self
pub fn discovery_splash(self, splash: Option<String>) -> Self
Set the splash image of the guild on the discovery page.
The splash
must be base64-encoded 1024x1024 png/jpeg/gif image-data.
Requires that the guild have the DISCOVERABLE
feature enabled. You can check this through
a guild’s features
list.
Set the banner image of the guild, it appears on the left side-bar.
The banner
must be base64-encoded 16:9 png/jpeg image data.
Requires that the guild have the BANNER
feature enabled. You can check this through a
guild’s features
list.
Sourcepub fn system_channel_id(self, channel_id: Option<ChannelId>) -> Self
pub fn system_channel_id(self, channel_id: Option<ChannelId>) -> Self
Set the channel ID where welcome messages and boost events will be posted.
Sourcepub fn rules_channel_id(self, channel_id: Option<ChannelId>) -> Self
pub fn rules_channel_id(self, channel_id: Option<ChannelId>) -> Self
Set the channel ID of the rules and guidelines channel.
Note: This feature is for Community guilds only.
Sourcepub fn public_updates_channel_id(self, channel_id: Option<ChannelId>) -> Self
pub fn public_updates_channel_id(self, channel_id: Option<ChannelId>) -> Self
Set the channel ID where admins and moderators receive update messages from Discord.
Note: This feature is for Community guilds only.
Sourcepub fn preferred_locale(self, locale: Option<String>) -> Self
pub fn preferred_locale(self, locale: Option<String>) -> Self
Set the preferred locale used in Server Discovery and update messages from Discord.
If this is not set, the locale will default to “en-US”;
Note: This feature is for Community guilds only.
Sourcepub fn explicit_content_filter(
self,
level: Option<ExplicitContentFilter>,
) -> Self
pub fn explicit_content_filter( self, level: Option<ExplicitContentFilter>, ) -> Self
Set the content filter level.
Sourcepub fn default_message_notifications(
self,
level: Option<DefaultMessageNotificationLevel>,
) -> Self
pub fn default_message_notifications( self, level: Option<DefaultMessageNotificationLevel>, ) -> Self
Set the default message notification level.
Sourcepub fn verification_level(
self,
verification_level: impl Into<VerificationLevel>,
) -> Self
pub fn verification_level( self, verification_level: impl Into<VerificationLevel>, ) -> Self
Set the verification level of the guild. This can restrict what a user must have prior to being able to send messages in a guild.
Refer to the documentation for VerificationLevel
for more information on each variant.
§Examples
Setting the verification level to High
:
use serenity::model::guild::VerificationLevel;
let builder = EditGuild::new().verification_level(VerificationLevel::High);
// assuming a `guild` has already been bound
let edit = guild.edit(&http, builder).await;
if let Err(why) = edit {
println!("Error setting verification level: {:?}", why);
}
Sourcepub fn system_channel_flags(
self,
system_channel_flags: SystemChannelFlags,
) -> Self
pub fn system_channel_flags( self, system_channel_flags: SystemChannelFlags, ) -> Self
Modifies the notifications that are sent by discord to the configured system channel.
use serenity::model::guild::SystemChannelFlags;
let builder = EditGuild::new().system_channel_flags(
SystemChannelFlags::SUPPRESS_JOIN_NOTIFICATIONS
| SystemChannelFlags::SUPPRESS_GUILD_REMINDER_NOTIFICATIONS,
);
// assuming a `guild` has already been bound
let edit = guild.edit(&http, builder).await;
if let Err(why) = edit {
println!("Error setting system channel flags: {:?}", why);
}
Sourcepub fn audit_log_reason(self, reason: &'a str) -> Self
pub fn audit_log_reason(self, reason: &'a str) -> Self
Sets the request’s audit log reason.
Whether the guild’s boost progress bar should be enabled
Trait Implementations§
Source§impl Builder for EditGuild<'_>
impl Builder for EditGuild<'_>
Source§fn execute<'life0, 'async_trait>(
self,
cache_http: impl 'async_trait + CacheHttp,
ctx: Self::Context<'life0>,
) -> Pin<Box<dyn Future<Output = Result<Self::Built>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn execute<'life0, 'async_trait>(
self,
cache_http: impl 'async_trait + CacheHttp,
ctx: Self::Context<'life0>,
) -> Pin<Box<dyn Future<Output = Result<Self::Built>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Edits the given guild.
Note: Requires the Manage Guild permission.
§Errors
If the cache
is enabled, returns a ModelError::InvalidPermissions
if the current user
lacks permission. Otherwise returns Error::Http
, as well as if invalid data is given.