Struct skua::model::id::GuildId

source ·
#[repr(packed(1))]
pub struct GuildId(/* private fields */);
Expand description

An identifier for a Guild

Implementations§

source§

impl GuildId

source

pub async fn automod_rules(self, http: impl AsRef<Http>) -> Result<Vec<Rule>>

Available on crate feature model only.

Gets all auto moderation Rules of this guild via HTTP.

Note: Requires the Manage Guild permission.

§Errors

Returns an Error::Http if the guild is unavailable.

source

pub async fn automod_rule( self, http: impl AsRef<Http>, rule_id: impl Into<RuleId> ) -> Result<Rule>

Available on crate feature model only.

Gets an auto moderation Rule of this guild by its ID via HTTP.

Note: Requires the Manage Guild permission.

§Errors

Returns an Error::Http if a rule with the given ID does not exist.

source

pub async fn create_automod_rule( self, cache_http: impl CacheHttp, builder: EditAutoModRule<'_> ) -> Result<Rule>

Available on crate feature model only.

Creates an auto moderation Rule in the guild.

Note: Requires the Manage Guild permission.

§Examples

Create a custom keyword filter to block the message and timeout the author.

use std::time::Duration;

use serenity::builder::EditAutoModRule;
use serenity::model::guild::automod::{Action, Trigger};
use serenity::model::id::GuildId;

let builder = EditAutoModRule::new()
    .name("foobar filter")
    .trigger(Trigger::Keyword {
        strings: vec!["foo*".to_string(), "*bar".to_string()],
        regex_patterns: vec![],
        allow_list: vec![],
    })
    .actions(vec![
        Action::BlockMessage {
            custom_message: None,
        },
        Action::Timeout(Duration::from_secs(60)),
    ]);
let _rule = GuildId::new(7).create_automod_rule(&http, builder).await;
§Errors

Returns Error::Http if the current user lacks permission, or if invalid data is given.

source

pub async fn edit_automod_rule( self, cache_http: impl CacheHttp, rule_id: impl Into<RuleId>, builder: EditAutoModRule<'_> ) -> Result<Rule>

Available on crate feature model only.

Edit an auto moderation Rule, given its Id.

Note: Requires the Manage Guild permission.

§Errors

Returns Error::Http if the current user lacks permission, or if invalid data is given.

source

pub async fn delete_automod_rule( self, http: impl AsRef<Http>, rule_id: impl Into<RuleId> ) -> Result<()>

Available on crate feature model only.

Deletes an auto moderation Rule from the guild.

Note: Requires the Manage Guild permission.

§Errors

Returns Error::Http if the current user lacks permission, or if a rule with that Id does not exist.

source

pub async fn add_member( self, cache_http: impl CacheHttp, user_id: impl Into<UserId>, builder: AddMember ) -> Result<Option<Member>>

Available on crate feature model only.

Adds a User to this guild with a valid OAuth2 access token.

Returns the created Member object, or nothing if the user is already a member of the guild.

§Errors

Returns Error::Http if the current user lacks permission, or if invalid data is given.

source

pub async fn ban( self, http: impl AsRef<Http>, user: impl Into<UserId>, dmd: u8 ) -> Result<()>

Available on crate feature model only.

Ban a User from the guild, deleting a number of days’ worth of messages (dmd) between the range 0 and 7.

Refer to the documentation for Guild::ban for more information.

Note: Requires the Ban Members permission.

§Examples

Ban a member and remove all messages they’ve sent in the last 4 days:

use serenity::model::id::{GuildId, UserId};

// assuming a `user` has already been bound
let _ = GuildId::new(81384788765712384).ban(&http, user, 4).await;
§Errors

Returns a ModelError::DeleteMessageDaysAmount if the number of days’ worth of messages to delete is over the maximum.

Also can return Error::Http if the current user lacks permission.

source

pub async fn ban_with_reason( self, http: impl AsRef<Http>, user: impl Into<UserId>, dmd: u8, reason: impl AsRef<str> ) -> Result<()>

Available on crate feature model only.

Ban a User from the guild with a reason. Refer to Self::ban to further documentation.

§Errors

In addition to the reasons Self::ban may return an error, may also return Error::ExceededLimit if reason is too long.

source

pub async fn bans( self, http: impl AsRef<Http>, target: Option<UserPagination>, limit: Option<u8> ) -> Result<Vec<Ban>>

Available on crate feature model only.

Gets a list of the guild’s bans, with additional options and filtering. See Http::get_bans for details.

Note: Requires the Ban Members permission.

§Errors

Returns Error::Http if the current user lacks permission.

source

pub async fn audit_logs( self, http: impl AsRef<Http>, action_type: Option<Action>, user_id: Option<UserId>, before: Option<AuditLogEntryId>, limit: Option<u8> ) -> Result<AuditLogs>

Available on crate feature model only.

Gets a list of the guild’s audit log entries

Note: Requires the View Audit Log permission.

§Errors

Returns Error::Http if the current user lacks permission, or if an invalid value is given.

source

pub async fn channels( self, http: impl AsRef<Http> ) -> Result<HashMap<ChannelId, GuildChannel>>

Available on crate feature model only.

Gets all of the guild’s channels over the REST API.

§Errors

Returns Error::Http if the current user is not in the guild.

source

pub async fn create_channel( self, cache_http: impl CacheHttp, builder: CreateChannel<'_> ) -> Result<GuildChannel>

Available on crate feature model only.

Creates a GuildChannel in the the guild.

Refer to Http::create_channel for more information.

Note: Requires the Manage Channels permission.

§Examples

Create a voice channel in a guild with the name test:

use serenity::builder::CreateChannel;
use serenity::model::channel::ChannelType;
use serenity::model::id::GuildId;

let builder = CreateChannel::new("test").kind(ChannelType::Voice);
let _channel = GuildId::new(7).create_channel(&http, builder).await?;
§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.

source

pub async fn create_emoji( self, http: impl AsRef<Http>, name: &str, image: &str ) -> Result<Emoji>

Available on crate feature model only.

Creates an emoji in the guild with a name and base64-encoded image.

Refer to the documentation for Guild::create_emoji for more information.

Requires the Create Guild Expressions permission.

§Examples

See the EditProfile::avatar example for an in-depth example as to how to read an image from the filesystem and encode it as base64. Most of the example can be applied similarly for this method.

§Errors

Returns Error::Http if the current user lacks permission, if the name is too long, or if the image is too big.

source

pub async fn create_integration( self, http: impl AsRef<Http>, integration_id: impl Into<IntegrationId>, kind: &str ) -> Result<()>

Available on crate feature model only.

Creates an integration for the guild.

Requires the Manage Guild permission.

§Errors

Returns Error::Http if the current user lacks permission.

source

pub async fn create_role( self, cache_http: impl CacheHttp, builder: EditRole<'_> ) -> Result<Role>

Available on crate feature model only.

Creates a new role in the guild with the data set, if any.

See the documentation for Guild::create_role on how to use this.

Note: Requires the Manage Roles 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.

source

pub async fn create_scheduled_event( self, cache_http: impl CacheHttp, builder: CreateScheduledEvent<'_> ) -> Result<ScheduledEvent>

Available on crate feature model only.

Creates a new scheduled event in the guild with the data set, if any.

Note: Requires the [Create Events] 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.

source

pub async fn create_sticker( self, cache_http: impl CacheHttp, builder: CreateSticker<'_> ) -> Result<Sticker>

Available on crate feature model only.

Creates a new sticker in the guild with the data set, if any.

Note: Requires the Create Guild Expressions 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.

source

pub async fn delete(self, http: impl AsRef<Http>) -> Result<()>

Available on crate feature model only.

Deletes the current guild if the current account is the owner of the guild.

Refer to Guild::delete for more information.

Note: Requires the current user to be the owner of the guild.

§Errors

Returns Error::Http if the current user is not the owner of the guild.

source

pub async fn delete_emoji( self, http: impl AsRef<Http>, emoji_id: impl Into<EmojiId> ) -> Result<()>

Available on crate feature model only.

Deletes an Emoji from the guild.

Note: If the emoji was created by the current user, requires either the Create Guild Expressions or the Manage Guild Expressions permission. Otherwise, the Manage Guild Expressions permission is required.

§Errors

Returns Error::Http if the current user lacks permission, or if an emoji with the given id does not exist in the guild.

source

pub async fn delete_integration( self, http: impl AsRef<Http>, integration_id: impl Into<IntegrationId> ) -> Result<()>

Available on crate feature model only.

Deletes an integration by Id from the guild.

Note: Requires the Manage Guild permission.

§Errors

Returns Error::Http if the current user lacks permission, or if an integration with that Id does not exist.

source

pub async fn delete_role( self, http: impl AsRef<Http>, role_id: impl Into<RoleId> ) -> Result<()>

Available on crate feature model only.

Deletes a Role by Id from the guild.

Also see Role::delete if you have the cache and model features enabled.

Note: Requires the Manage Roles permission.

§Errors

Returns Error::Http if the current user lacks permission, or if a role with that Id does not exist.

source

pub async fn delete_scheduled_event( self, http: impl AsRef<Http>, event_id: impl Into<ScheduledEventId> ) -> Result<()>

Available on crate feature model only.

Deletes a specified scheduled event in the guild.

Note: If the event was created by the current user, requires either Create Events or the Manage Events permission. Otherwise, the Manage Events permission is required.

§Errors

Returns Error::Http if the current user lacks permission, or if invalid data is given.

source

pub async fn delete_sticker( self, http: impl AsRef<Http>, sticker_id: impl Into<StickerId> ) -> Result<()>

Available on crate feature model only.

Deletes a Sticker by id from the guild.

Note: If the sticker was created by the current user, requires either the Create Guild Expressions or the Manage Guild Expressions permission. Otherwise, the Manage Guild Expressions permission is required.

§Errors

Returns Error::Http if the current user lacks permission, or if a sticker with that id does not exist.

source

pub async fn edit( self, cache_http: impl CacheHttp, builder: EditGuild<'_> ) -> Result<PartialGuild>

Available on crate feature model only.

Edits the current guild with new data where specified.

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.

source

pub async fn edit_emoji( self, http: impl AsRef<Http>, emoji_id: impl Into<EmojiId>, name: &str ) -> Result<Emoji>

Available on crate feature model only.

Edits an Emoji’s name in the guild.

Also see Emoji::edit if you have the cache and methods features enabled.

Note: If the emoji was created by the current user, requires either the Create Guild Expressions or the Manage Guild Expressions permission. Otherwise, the Manage Guild Expressions permission is required.

§Errors

Returns Error::Http if the current user lacks permission, or if an emoji with the given id does not exist.

source

pub async fn edit_member( self, cache_http: impl CacheHttp, user_id: impl Into<UserId>, builder: EditMember<'_> ) -> Result<Member>

Available on crate feature model only.

Edits the properties a guild member, such as muting or nicknaming them. Returns the new member.

Refer to the documentation of EditMember for a full list of methods and permission restrictions.

§Examples

Mute a member and set their roles to just one role with a predefined Id:

let builder = EditMember::new().mute(true).roles(vec![role_id]);
let _ = GuildId::new(7).edit_member(&http, user_id, builder).await?;
§Errors

Returns Error::Http if the current user lacks permission, or if invalid data is given.

source

pub async fn edit_mfa_level( self, http: impl AsRef<Http>, mfa_level: MfaLevel, audit_log_reason: Option<&str> ) -> Result<MfaLevel>

Available on crate feature model only.

Edits the guild’s MFA level. Returns the new level on success.

Requires guild ownership.

§Errors

Returns Error::Http if the current user lacks permission.

source

pub async fn edit_nickname( self, http: impl AsRef<Http>, new_nickname: Option<&str> ) -> Result<()>

Available on crate feature model only.

Edits the current user’s nickname for the guild.

Pass None to reset the nickname.

Requires the Change Nickname permission.

§Errors

Returns Error::Http if the current user lacks permission.

source

pub async fn edit_role( self, cache_http: impl CacheHttp, role_id: impl Into<RoleId>, builder: EditRole<'_> ) -> Result<Role>

Available on crate feature model only.

Edits a Role, optionally setting its new fields.

Note: Requires the Manage Roles permission.

§Examples

Make a role hoisted, and change its name:

// assuming a `role_id` and `guild_id` has been bound
let builder = EditRole::new().name("a test role").hoist(true);
let role = guild_id.edit_role(&http, role_id, builder).await?;
§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.

source

pub async fn edit_scheduled_event( self, cache_http: impl CacheHttp, event_id: impl Into<ScheduledEventId>, builder: EditScheduledEvent<'_> ) -> Result<ScheduledEvent>

Available on crate feature model only.

Modifies a scheduled event in the guild with the data set, if any.

Note: If the event was created by the current user, requires either Create Events or the Manage Events permission. Otherwise, the Manage Events permission is required.

§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.

source

pub async fn edit_sticker( self, cache_http: impl CacheHttp, sticker_id: impl Into<StickerId>, builder: EditSticker<'_> ) -> Result<Sticker>

Available on crate feature model only.

Edits a sticker.

Note: If the sticker was created by the current user, requires either the Create Guild Expressions or the Manage Guild Expressions permission. Otherwise, the Manage Guild Expressions permission is required.

§Examples

Rename a sticker:

use serenity::builder::EditSticker;
use serenity::model::id::{GuildId, StickerId};

let builder = EditSticker::new().name("Bun bun meow");
let _ = GuildId::new(7).edit_sticker(&http, StickerId::new(7), builder).await?;
§Errors

Returns Error::Http if the current user lacks permission, or if invalid data is given.

source

pub async fn edit_role_position( self, http: impl AsRef<Http>, role_id: impl Into<RoleId>, position: u16 ) -> Result<Vec<Role>>

Available on crate feature model only.

Edit the position of a Role relative to all others in the Guild.

Note: Requires the Manage Roles permission.

§Examples
use serenity::model::{GuildId, RoleId};
GuildId::new(7).edit_role_position(&context, RoleId::new(8), 2);
§Errors

Returns an Error::Http if the current user lacks permission.

source

pub async fn edit_welcome_screen( self, cache_http: impl CacheHttp, builder: EditGuildWelcomeScreen<'_> ) -> Result<GuildWelcomeScreen>

Available on crate feature model only.

Edits the guild’s welcome screen.

Note: Requires the Manage Guild permission.

§Errors

Returns Error::Http if the current user lacks permission.

source

pub async fn edit_widget( self, cache_http: impl CacheHttp, builder: EditGuildWidget<'_> ) -> Result<GuildWidget>

Available on crate feature model only.

Edits the guild’s widget.

Note: Requires the Manage Guild permission.

§Errors

Returns Error::Http if the current user lacks permission.

source

pub async fn roles( self, http: impl AsRef<Http> ) -> Result<HashMap<RoleId, Role>>

Available on crate feature model only.

Gets all of the guild’s roles over the REST API.

§Errors

Returns Error::Http if the current user is not in the guild.

source

pub fn everyone_role(&self) -> RoleId

Available on crate feature model only.

Gets the default permission role (@everyone) from the guild.

source

pub fn to_guild_cached(self, cache: &impl AsRef<Cache>) -> Option<GuildRef<'_>>

Available on crate features model and cache only.

Tries to find the Guild by its Id in the cache.

source

pub async fn to_partial_guild( self, cache_http: impl CacheHttp ) -> Result<PartialGuild>

Available on crate feature model only.

Requests PartialGuild over REST API.

Note: This will not be a Guild, as the REST API does not send all data with a guild retrieval.

§Errors

Returns an Error::Http if the current user is not in the guild.

source

pub async fn to_partial_guild_with_counts( self, http: impl AsRef<Http> ) -> Result<PartialGuild>

Available on crate feature model only.

Requests PartialGuild over REST API with counts.

Note: This will not be a Guild, as the REST API does not send all data with a guild retrieval.

§Errors

Returns an Error::Http if the current user is not in the guild.

source

pub async fn emojis(self, http: impl AsRef<Http>) -> Result<Vec<Emoji>>

Available on crate feature model only.

Gets all Emojis of this guild via HTTP.

§Errors

Returns an Error::Http if the guild is unavailable.

source

pub async fn emoji( self, http: impl AsRef<Http>, emoji_id: EmojiId ) -> Result<Emoji>

Available on crate feature model only.

Gets an Emoji of this guild by its ID via HTTP.

§Errors

Returns an Error::Http if an emoji with that id does not exist.

source

pub async fn stickers(self, http: impl AsRef<Http>) -> Result<Vec<Sticker>>

Available on crate feature model only.

Gets all Stickers of this guild via HTTP.

§Errors

Returns an Error::Http if the guild is unavailable.

source

pub async fn sticker( self, http: impl AsRef<Http>, sticker_id: StickerId ) -> Result<Sticker>

Available on crate feature model only.

Gets an Sticker of this guild by its ID via HTTP.

§Errors

Returns an Error::Http if an sticker with that Id does not exist.

source

pub async fn integrations( self, http: impl AsRef<Http> ) -> Result<Vec<Integration>>

Available on crate feature model only.

Gets all integration of the guild.

Requires the Manage Guild permission.

§Errors

Returns an Error::Http if the current user lacks permission, also may return Error::Json if there is an error in deserializing the API response.

source

pub async fn invites(self, http: impl AsRef<Http>) -> Result<Vec<RichInvite>>

Available on crate feature model only.

Gets all of the guild’s invites.

Requires the Manage Guild permission.

§Errors

Returns Error::Http if the current user lacks permission, also may return Error::Json if there is an error in deserializing the API response.

source

pub async fn kick( self, http: impl AsRef<Http>, user_id: impl Into<UserId> ) -> Result<()>

Available on crate feature model only.

Kicks a Member from the guild.

Requires the Kick Members permission.

§Errors

Returns Error::Http if the member cannot be kicked by the current user.

source

pub async fn kick_with_reason( self, http: impl AsRef<Http>, user_id: impl Into<UserId>, reason: &str ) -> Result<()>

Available on crate feature model only.
§Errors

In addition to the reasons Self::kick may return an error, may also return an error if the reason is too long.

source

pub async fn current_user_member(self, http: impl AsRef<Http>) -> Result<Member>

Available on crate feature model only.

Returns a guild Member object for the current user.

See Http::get_current_user_guild_member for more.

§Errors

Returns an Error::Http if the current user is not in the guild or the access token lacks the necessary scope.

source

pub async fn leave(self, http: impl AsRef<Http>) -> Result<()>

Available on crate feature model only.

Leaves the guild.

§Errors

May return an Error::Http if the current user cannot leave the guild, or currently is not in the guild.

source

pub async fn member( self, cache_http: impl CacheHttp, user_id: impl Into<UserId> ) -> Result<Member>

Available on crate feature model only.

Gets a user’s Member for the guild by Id.

If the cache feature is enabled the cache will be checked first. If not found it will resort to an http request.

§Errors

Returns an Error::Http if the user is not in the guild, or if the guild is otherwise unavailable

source

pub async fn members( self, http: impl AsRef<Http>, limit: Option<u64>, after: impl Into<Option<UserId>> ) -> Result<Vec<Member>>

Available on crate feature model only.

Gets a list of the guild’s members.

Optionally pass in the limit to limit the number of results. Minimum value is 1, maximum and default value is 1000.

Optionally pass in after to offset the results by a User’s Id.

§Errors

Returns an Error::Http if the API returns an error, may also return Error::NotInRange if the input is not within range.

source

pub fn members_iter<H: AsRef<Http>>( self, http: H ) -> impl Stream<Item = Result<Member>>

Available on crate feature model only.

Streams over all the members in a guild.

This is accomplished and equivalent to repeated calls to Self::members. A buffer of at most 1,000 members is used to reduce the number of calls necessary.

§Examples
use serenity::futures::StreamExt;
use serenity::model::guild::MembersIter;

let mut members = guild_id.members_iter(&ctx).boxed();
while let Some(member_result) = members.next().await {
    match member_result {
        Ok(member) => println!("{} is {}", member, member.display_name(),),
        Err(error) => eprintln!("Uh oh!  Error: {}", error),
    }
}
source

pub async fn move_member( self, cache_http: impl CacheHttp, user_id: impl Into<UserId>, channel_id: impl Into<ChannelId> ) -> Result<Member>

Available on crate feature model only.

Moves a member to a specific voice channel.

Note: Requires the Move Members permission.

§Errors

Returns Error::Http if the current user lacks permission, or if the member is not currently in a voice channel for this Guild.

source

pub fn name(self, cache: impl AsRef<Cache>) -> Option<String>

Available on crate features model and cache only.

Returns the name of whatever guild this id holds.

source

pub async fn disconnect_member( self, cache_http: impl CacheHttp, user_id: impl Into<UserId> ) -> Result<Member>

Available on crate feature model only.

Disconnects a member from a voice channel in the guild.

Note: Requires the Move Members permission.

§Errors

Returns Error::Http if the current user lacks permission, or if the member is not currently in a voice channel for this Guild.

source

pub async fn prune_count( self, http: impl AsRef<Http>, days: u8 ) -> Result<GuildPrune>

Available on crate feature model only.

Gets the number of Members that would be pruned with the given number of days.

Requires the Kick Members permission.

§Errors

Returns Error::Http if the current user does not have permission.

source

pub async fn reorder_channels( self, http: impl AsRef<Http>, channels: impl IntoIterator<Item = (ChannelId, u64)> ) -> Result<()>

Available on crate feature model only.

Re-orders the channels of the guild.

Accepts an iterator of a tuple of the channel ID to modify and its new position.

Although not required, you should specify all channels’ positions, regardless of whether they were updated. Otherwise, positioning can sometimes get weird.

Note: Requires the Manage Channels permission.

§Errors

Returns Error::Http if the current user lacks permission.

source

pub async fn search_members( self, http: impl AsRef<Http>, query: &str, limit: Option<u64> ) -> Result<Vec<Member>>

Available on crate feature model only.

Returns a list of Members in a Guild whose username or nickname starts with a provided string.

Optionally pass in the limit to limit the number of results. Minimum value is 1, maximum and default value is 1000.

§Errors

Returns an Error::Http if the API returns an error.

source

pub async fn scheduled_event( self, http: impl AsRef<Http>, event_id: impl Into<ScheduledEventId>, with_user_count: bool ) -> Result<ScheduledEvent>

Available on crate feature model only.

Fetches a specified scheduled event in the guild, by Id. If with_user_count is set to true, then the user_count field will be populated, indicating the number of users interested in the event.

Note: Requires the View Channel permission for the channel associated with the event.

§Errors

Returns Error::Http if the current user lacks permission, or if the provided id is invalid.

source

pub async fn scheduled_events( self, http: impl AsRef<Http>, with_user_count: bool ) -> Result<Vec<ScheduledEvent>>

Available on crate feature model only.

Fetches a list of all scheduled events in the guild. If with_user_count is set to true, then each event returned will have its user_count field populated.

Note: Requires the View Channel permission at the guild level.

§Errors

Returns Error::Http if the current user lacks permission.

source

pub async fn scheduled_event_users( self, http: impl AsRef<Http>, event_id: impl Into<ScheduledEventId>, limit: Option<u64> ) -> Result<Vec<ScheduledEventUser>>

Available on crate feature model only.

Fetches a list of interested users for the specified event.

If limit is left unset, by default at most 100 users are returned.

Note: Requires the View Channel permission for the channel associated with the event.

§Errors

Returns Error::Http if the current user lacks permission, or if the provided Id is invalid.

source

pub async fn scheduled_event_users_optioned( self, http: impl AsRef<Http>, event_id: impl Into<ScheduledEventId>, limit: Option<u64>, target: Option<UserPagination>, with_member: Option<bool> ) -> Result<Vec<ScheduledEventUser>>

Available on crate feature model only.

Fetches a list of interested users for the specified event, with additional options and filtering. See Http::get_scheduled_event_users for details.

Note: Requires the View Channel permission for the channel associated with the event.

§Errors

Returns Error::Http if the current user lacks permission, or if the provided Id is invalid.

source

pub fn shard_id(self, cache: impl AsRef<Cache>) -> u32

Available on crate features cache and utils and model only.

Returns the Id of the shard associated with the guild.

When the cache is enabled this will automatically retrieve the total number of shards.

Note: When the cache is enabled, this function unlocks the cache to retrieve the total number of shards in use. If you already have the total, consider using utils::shard_id.

source

pub async fn start_integration_sync( self, http: impl AsRef<Http>, integration_id: impl Into<IntegrationId> ) -> Result<()>

Available on crate feature model only.

Starts an integration sync for the given integration Id.

Requires the Manage Guild permission.

§Errors

Returns Error::Http if the current user lacks permission, or if an Integration with that Id does not exist.

source

pub async fn start_prune( self, http: impl AsRef<Http>, days: u8 ) -> Result<GuildPrune>

Available on crate feature model only.

Starts a prune of Members.

See the documentation on GuildPrune for more information.

Note: Requires the Kick Members permission.

§Errors

Returns Error::Http if the current user lacks permission.

source

pub async fn unban( self, http: impl AsRef<Http>, user_id: impl Into<UserId> ) -> Result<()>

Available on crate feature model only.

Unbans a User from the guild.

Note: Requires the Ban Members permission.

§Errors

Returns Error::Http if the current user does not have permission.

source

pub async fn vanity_url(self, http: impl AsRef<Http>) -> Result<String>

Available on crate feature model only.

Retrieve’s the guild’s vanity URL.

Note: Requires the Manage Guild permission.

§Errors

Will return Error::Http if the current user lacks permission. Can also return Error::Json if there is an error deserializing the API response.

source

pub async fn webhooks(self, http: impl AsRef<Http>) -> Result<Vec<Webhook>>

Available on crate feature model only.

Retrieves the guild’s webhooks.

Note: Requires the Manage Webhooks permission.

§Errors

Will return an Error::Http if the bot is lacking permissions. Can also return an Error::Json if there is an error deserializing the API response.

source

pub fn await_reply( self, shard_messenger: impl AsRef<ShardMessenger> ) -> MessageCollector

Available on crate features model and collector only.

Returns a builder which can be awaited to obtain a message or stream of messages in this guild.

source

pub fn await_replies( &self, shard_messenger: impl AsRef<ShardMessenger> ) -> MessageCollector

Available on crate features model and collector only.
source

pub fn await_reaction( self, shard_messenger: impl AsRef<ShardMessenger> ) -> ReactionCollector

Available on crate features model and collector only.

Returns a builder which can be awaited to obtain a message or stream of reactions sent in this guild.

source

pub fn await_reactions( &self, shard_messenger: impl AsRef<ShardMessenger> ) -> ReactionCollector

Available on crate features model and collector only.
source

pub async fn create_command( self, cache_http: impl CacheHttp, builder: CreateCommand ) -> Result<Command>

Available on crate feature model only.

Create a guild specific application Command.

Note: Unlike global commands, guild commands will update instantly.

§Errors

See CreateCommand::execute for a list of possible errors.

source

pub async fn set_commands( self, http: impl AsRef<Http>, commands: Vec<CreateCommand> ) -> Result<Vec<Command>>

Available on crate feature model only.

Override all guild application commands.

§Errors

Returns the same errors as Self::create_command.

source

pub async fn edit_command_permissions( self, cache_http: impl CacheHttp, command_id: CommandId, builder: EditCommandPermissions ) -> Result<CommandPermissions>

Available on crate feature model only.

Overwrites permissions for a specific command.

Note: It will update instantly.

§Errors

See EditCommandPermissions::execute for a list of possible errors.

source

pub async fn get_commands(self, http: impl AsRef<Http>) -> Result<Vec<Command>>

Available on crate feature model only.

Get all guild application commands.

§Errors

If there is an error, it will be either Error::Http or Error::Json.

source

pub async fn get_commands_with_localizations( self, http: impl AsRef<Http> ) -> Result<Vec<Command>>

Available on crate feature model only.

Get all guild application commands with localizations.

§Errors

If there is an error, it will be either Error::Http or Error::Json.

source

pub async fn get_command( self, http: impl AsRef<Http>, command_id: CommandId ) -> Result<Command>

Available on crate feature model only.

Get a specific guild application command by its Id.

§Errors

If there is an error, it will be either Error::Http or Error::Json.

source

pub async fn edit_command( self, cache_http: impl CacheHttp, command_id: CommandId, builder: CreateCommand ) -> Result<Command>

Available on crate feature model only.

Edit a guild application command, given its Id.

§Errors

See CreateCommand::execute for a list of possible errors.

source

pub async fn delete_command( self, http: impl AsRef<Http>, command_id: CommandId ) -> Result<()>

Available on crate feature model only.

Delete guild application command by its Id.

§Errors

If there is an error, it will be either Error::Http or Error::Json.

source

pub async fn get_commands_permissions( self, http: impl AsRef<Http> ) -> Result<Vec<CommandPermissions>>

Available on crate feature model only.

Get all guild application commands permissions only.

§Errors

If there is an error, it will be either Error::Http or Error::Json.

source

pub async fn get_command_permissions( self, http: impl AsRef<Http>, command_id: CommandId ) -> Result<CommandPermissions>

Available on crate feature model only.

Get permissions for specific guild application command by its Id.

§Errors

If there is an error, it will be either Error::Http or Error::Json.

source

pub async fn get_welcome_screen( self, http: impl AsRef<Http> ) -> Result<GuildWelcomeScreen>

Available on crate feature model only.

Get the guild welcome screen.

§Errors

Returns Error::Http if the guild does not have a welcome screen.

source

pub async fn get_preview(self, http: impl AsRef<Http>) -> Result<GuildPreview>

Available on crate feature model only.

Get the guild preview.

Note: The bot need either to be part of the guild or the guild needs to have the DISCOVERABLE feature.

§Errors

Returns Error::Http if the bot cannot see the guild preview, see the note.

source

pub async fn get_widget(self, http: impl AsRef<Http>) -> Result<GuildWidget>

Available on crate feature model only.

Get the guild widget.

§Errors

Returns Error::Http if the bot does not have MANAGE_MESSAGES permission.

source

pub fn widget_image_url(self, style: GuildWidgetStyle) -> String

Available on crate feature model only.

Get the widget image URL.

source

pub async fn get_active_threads( self, http: impl AsRef<Http> ) -> Result<ThreadsData>

Available on crate feature model only.

Gets the guild active threads.

§Errors

Returns Error::Http if there is an error in the deserialization, or if the bot issuing the request is not in the guild.

source§

impl GuildId

source

pub const fn new(id: u64) -> Self

Creates a new GuildId from a u64.

§Panics

Panics if id is zero.

source

pub const fn get(self) -> u64

Retrieves the inner id as a u64.

source

pub fn created_at(&self) -> Timestamp

Retrieves the time that the GuildId was created.

Trait Implementations§

source§

impl AsRef<GuildId> for GuildId

source§

fn as_ref(&self) -> &Self

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Clone for GuildId

source§

fn clone(&self) -> GuildId

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for GuildId

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for GuildId

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for GuildId

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for GuildId

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> From<&'a Guild> for GuildId

source§

fn from(live_guild: &Guild) -> GuildId

Gets the Id of Guild.

source§

impl<'a> From<&'a GuildId> for GuildId

source§

fn from(id: &'a GuildId) -> GuildId

Converts to this type from the input type.
source§

impl<'a> From<&'a GuildInfo> for GuildId

source§

fn from(guild_info: &GuildInfo) -> GuildId

Gets the Id of Guild information struct.

source§

impl<'a> From<&'a InviteGuild> for GuildId

source§

fn from(invite_guild: &InviteGuild) -> GuildId

Gets the Id of Invite Guild struct.

source§

impl<'a> From<&'a PartialGuild> for GuildId

source§

fn from(guild: &PartialGuild) -> GuildId

Gets the Id of a partial guild.

source§

impl<'a> From<&'a WebhookGuild> for GuildId

source§

fn from(webhook_guild: &WebhookGuild) -> GuildId

Gets the Id of Webhook Guild struct.

source§

impl From<Guild> for GuildId

source§

fn from(live_guild: Guild) -> GuildId

Gets the Id of Guild.

source§

impl From<GuildId> for NonZeroI64

source§

fn from(id: GuildId) -> NonZeroI64

Converts to this type from the input type.
source§

impl From<GuildId> for NonZeroU64

source§

fn from(id: GuildId) -> NonZeroU64

Converts to this type from the input type.
source§

impl From<GuildId> for i64

source§

fn from(id: GuildId) -> i64

Converts to this type from the input type.
source§

impl From<GuildId> for u64

source§

fn from(id: GuildId) -> u64

Converts to this type from the input type.
source§

impl From<GuildInfo> for GuildId

source§

fn from(guild_info: GuildInfo) -> GuildId

Gets the Id of Guild information struct.

source§

impl From<InviteGuild> for GuildId

source§

fn from(invite_guild: InviteGuild) -> GuildId

Gets the Id of Invite Guild struct.

source§

impl From<NonZero<u64>> for GuildId

source§

fn from(id: NonZeroU64) -> GuildId

Converts to this type from the input type.
source§

impl From<PartialGuild> for GuildId

source§

fn from(guild: PartialGuild) -> GuildId

Gets the Id of a partial guild.

source§

impl From<WebhookGuild> for GuildId

source§

fn from(webhook_guild: WebhookGuild) -> GuildId

Gets the Id of Webhook Guild struct.

source§

impl From<u64> for GuildId

source§

fn from(id: u64) -> GuildId

Converts to this type from the input type.
source§

impl FromStr for GuildId

§

type Err = <u64 as FromStr>::Err

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl Hash for GuildId

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for GuildId

source§

fn cmp(&self, other: &GuildId) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<u64> for GuildId

source§

fn eq(&self, u: &u64) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq for GuildId

source§

fn eq(&self, other: &GuildId) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for GuildId

source§

fn partial_cmp(&self, other: &GuildId) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Serialize for GuildId

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Copy for GuildId

source§

impl Eq for GuildId

source§

impl StructuralPartialEq for GuildId

Auto Trait Implementations§

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> ArgumentConvert for T
where T: FromStr,

§

type Err = <T as FromStr>::Err

Available on crate features utils and client only.
The associated error which can be returned from parsing.
source§

fn convert<'life0, 'async_trait>( __arg0: impl CacheHttp + 'async_trait, __arg1: Option<GuildId>, __arg2: Option<ChannelId>, s: &'life0 str ) -> Pin<Box<dyn Future<Output = Result<T, <T as ArgumentConvert>::Err>> + Send + 'async_trait>>
where 'life0: 'async_trait, T: 'async_trait,

Available on crate features utils and client only.
Parses a string s as a command parameter of this type.
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> CloneDebuggableStorage for T

source§

impl<T> CloneableStorage for T
where T: Any + Send + Sync + Clone,

§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

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

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

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> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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>,

§

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

source§

impl<T> WithSubscriber for T

source§

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
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> DebuggableStorage for T
where T: Any + Send + Sync + Debug,

source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,