pub struct GuildId(pub u64);
Expand description
An identifier for a Guild
Tuple Fields
0: u64
Implementations
sourceimpl GuildId
impl GuildId
sourcepub async fn add_member(
self,
http: impl AsRef<Http>,
user_id: impl Into<UserId>,
f: impl FnOnce(&mut AddMember) -> &mut AddMember
) -> Result<Option<Member>>
Available on crate feature model
only.
pub async fn add_member(
self,
http: impl AsRef<Http>,
user_id: impl Into<UserId>,
f: impl FnOnce(&mut AddMember) -> &mut AddMember
) -> Result<Option<Member>>
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 values are set.
sourcepub async fn ban(
self,
http: impl AsRef<Http>,
user: impl Into<UserId>,
dmd: u8
) -> Result<()>
Available on crate feature model
only.
pub async fn ban(
self,
http: impl AsRef<Http>,
user: impl Into<UserId>,
dmd: u8
) -> Result<()>
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(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.
sourcepub 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.
pub async fn ban_with_reason(
self,
http: impl AsRef<Http>,
user: impl Into<UserId>,
dmd: u8,
reason: impl AsRef<str>
) -> Result<()>
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.
sourcepub async fn bans(self, http: impl AsRef<Http>) -> Result<Vec<Ban>>
Available on crate feature model
only.
pub async fn bans(self, http: impl AsRef<Http>) -> Result<Vec<Ban>>
model
only.Gets a list of the guild’s bans.
Note: Requires the Ban Members permission.
Errors
Returns Error::Http
if the current user lacks permission.
sourcepub async fn audit_logs(
self,
http: impl AsRef<Http>,
action_type: Option<u8>,
user_id: Option<UserId>,
before: Option<AuditLogEntryId>,
limit: Option<u8>
) -> Result<AuditLogs>
Available on crate feature model
only.
pub async fn audit_logs(
self,
http: impl AsRef<Http>,
action_type: Option<u8>,
user_id: Option<UserId>,
before: Option<AuditLogEntryId>,
limit: Option<u8>
) -> Result<AuditLogs>
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.
sourcepub async fn channels(
self,
http: impl AsRef<Http>
) -> Result<HashMap<ChannelId, GuildChannel>>
Available on crate feature model
only.
pub async fn channels(
self,
http: impl AsRef<Http>
) -> Result<HashMap<ChannelId, GuildChannel>>
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.
sourcepub async fn create_channel(
self,
http: impl AsRef<Http>,
f: impl FnOnce(&mut CreateChannel) -> &mut CreateChannel
) -> Result<GuildChannel>
Available on crate feature model
only.
pub async fn create_channel(
self,
http: impl AsRef<Http>,
f: impl FnOnce(&mut CreateChannel) -> &mut CreateChannel
) -> Result<GuildChannel>
model
only.Creates a GuildChannel
in the the guild.
Refer to Http::create_channel
for more information.
Requires the Manage Channels permission.
Examples
Create a voice channel in a guild with the name test
:
use serenity::model::channel::ChannelType;
use serenity::model::id::GuildId;
let _channel =
GuildId(7).create_channel(&http, |c| c.name("test").kind(ChannelType::Voice)).await;
Errors
Returns Error::Http
if the current user lacks permission,
or if invalid values are set.
sourcepub async fn create_emoji(
self,
http: impl AsRef<Http>,
name: &str,
image: &str
) -> Result<Emoji>
Available on crate feature model
only.
pub async fn create_emoji(
self,
http: impl AsRef<Http>,
name: &str,
image: &str
) -> Result<Emoji>
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 Manage Emojis and Stickers 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.
sourcepub async fn create_integration(
self,
http: impl AsRef<Http>,
integration_id: impl Into<IntegrationId>,
kind: &str
) -> Result<()>
Available on crate feature model
only.
pub async fn create_integration(
self,
http: impl AsRef<Http>,
integration_id: impl Into<IntegrationId>,
kind: &str
) -> Result<()>
model
only.Creates an integration for the guild.
Requires the Manage Guild permission.
Errors
Returns Error::Http
if the current user lacks permission.
sourcepub async fn create_role<F>(self, http: impl AsRef<Http>, f: F) -> Result<Role> where
F: FnOnce(&mut EditRole) -> &mut EditRole,
Available on crate feature model
only.
pub async fn create_role<F>(self, http: impl AsRef<Http>, f: F) -> Result<Role> where
F: FnOnce(&mut EditRole) -> &mut EditRole,
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
Returns Error::Http
if the current user lacks permission,
or if invalid data is given.
sourcepub async fn create_sticker<'a, F>(
self,
http: impl AsRef<Http>,
f: F
) -> Result<Sticker> where
for<'b> F: FnOnce(&'b mut CreateSticker<'a>) -> &'b mut CreateSticker<'a>,
Available on crate feature model
only.
pub async fn create_sticker<'a, F>(
self,
http: impl AsRef<Http>,
f: F
) -> Result<Sticker> where
for<'b> F: FnOnce(&'b mut CreateSticker<'a>) -> &'b mut CreateSticker<'a>,
model
only.Creates a new sticker in the guild with the data set, if any.
Note: Requires the Manage Emojis and Stickers permission.
Errors
Returns Error::Http
if the current user lacks permission,
or if invalid data is given.
sourcepub async fn delete(self, http: impl AsRef<Http>) -> Result<PartialGuild>
Available on crate feature model
only.
pub async fn delete(self, http: impl AsRef<Http>) -> Result<PartialGuild>
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.
sourcepub async fn delete_emoji(
self,
http: impl AsRef<Http>,
emoji_id: impl Into<EmojiId>
) -> Result<()>
Available on crate feature model
only.
pub async fn delete_emoji(
self,
http: impl AsRef<Http>,
emoji_id: impl Into<EmojiId>
) -> Result<()>
model
only.Deletes an Emoji
from the guild.
Note: Requires the Manage Emojis and Stickers permission.
Errors
Returns Error::Http
if the current user lacks permission,
or if an Emoji with that Id does not exist.
sourcepub async fn delete_integration(
self,
http: impl AsRef<Http>,
integration_id: impl Into<IntegrationId>
) -> Result<()>
Available on crate feature model
only.
pub async fn delete_integration(
self,
http: impl AsRef<Http>,
integration_id: impl Into<IntegrationId>
) -> Result<()>
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.
sourcepub async fn delete_role(
self,
http: impl AsRef<Http>,
role_id: impl Into<RoleId>
) -> Result<()>
Available on crate feature model
only.
pub async fn delete_role(
self,
http: impl AsRef<Http>,
role_id: impl Into<RoleId>
) -> Result<()>
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.
sourcepub async fn delete_sticker(
self,
http: impl AsRef<Http>,
sticker_id: impl Into<StickerId>
) -> Result<()>
Available on crate feature model
only.
pub async fn delete_sticker(
self,
http: impl AsRef<Http>,
sticker_id: impl Into<StickerId>
) -> Result<()>
model
only.Deletes a Sticker
by Id from the guild.
Note: Requires the Manage Emojis and Stickers permission.
Errors
Returns Error::Http
if the current user lacks permission,
or if a sticker with that Id does not exist.
sourcepub async fn edit<F>(
&mut self,
http: impl AsRef<Http>,
f: F
) -> Result<PartialGuild> where
F: FnOnce(&mut EditGuild) -> &mut EditGuild,
Available on crate feature model
only.
pub async fn edit<F>(
&mut self,
http: impl AsRef<Http>,
f: F
) -> Result<PartialGuild> where
F: FnOnce(&mut EditGuild) -> &mut EditGuild,
model
only.Edits the current guild with new data where specified.
Refer to Guild::edit
for more information.
Note: Requires the current user to have the Manage Guild permission.
Errors
Returns Error::Http
if the current user lacks permission,
or if an invalid value is set.
sourcepub async fn edit_emoji(
self,
http: impl AsRef<Http>,
emoji_id: impl Into<EmojiId>,
name: &str
) -> Result<Emoji>
Available on crate feature model
only.
pub async fn edit_emoji(
self,
http: impl AsRef<Http>,
emoji_id: impl Into<EmojiId>,
name: &str
) -> Result<Emoji>
model
only.Edits an Emoji
’s name in the guild.
Also see Emoji::edit
if you have the cache
and methods
features
enabled.
Requires the Manage Emojis and Stickers permission.
Errors
Returns Error::Http
if the current user lacks permission.
sourcepub async fn edit_member<F>(
self,
http: impl AsRef<Http>,
user_id: impl Into<UserId>,
f: F
) -> Result<Member> where
F: FnOnce(&mut EditMember) -> &mut EditMember,
Available on crate feature model
only.
pub async fn edit_member<F>(
self,
http: impl AsRef<Http>,
user_id: impl Into<UserId>,
f: F
) -> Result<Member> where
F: FnOnce(&mut EditMember) -> &mut EditMember,
model
only.Edits the properties of member of the guild, such as muting or nicknaming them.
Refer to EditMember
’s documentation 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:
guild.edit_member(&context, user_id, |m| m.mute(true).roles(&vec![role_id]));
Errors
Returns Error::Http
if the current user lacks the necessary permissions.
sourcepub async fn edit_nickname(
self,
http: impl AsRef<Http>,
new_nickname: Option<&str>
) -> Result<()>
Available on crate feature model
only.
pub async fn edit_nickname(
self,
http: impl AsRef<Http>,
new_nickname: Option<&str>
) -> Result<()>
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.
sourcepub async fn edit_role<F>(
self,
http: impl AsRef<Http>,
role_id: impl Into<RoleId>,
f: F
) -> Result<Role> where
F: FnOnce(&mut EditRole) -> &mut EditRole,
Available on crate feature model
only.
pub async fn edit_role<F>(
self,
http: impl AsRef<Http>,
role_id: impl Into<RoleId>,
f: F
) -> Result<Role> where
F: FnOnce(&mut EditRole) -> &mut EditRole,
model
only.Edits a Role
, optionally setting its new fields.
Requires the Manage Roles permission.
Examples
Make a role hoisted:
use serenity::model::{GuildId, RoleId};
GuildId(7).edit_role(&context, RoleId(8), |r| r.hoist(true));
Errors
Returns Error::Http
if the current user lacks permission.
sourcepub async fn edit_sticker<F>(
&self,
http: impl AsRef<Http>,
sticker_id: impl Into<StickerId>,
f: F
) -> Result<Sticker> where
F: FnOnce(&mut EditSticker) -> &mut EditSticker,
Available on crate feature model
only.
pub async fn edit_sticker<F>(
&self,
http: impl AsRef<Http>,
sticker_id: impl Into<StickerId>,
f: F
) -> Result<Sticker> where
F: FnOnce(&mut EditSticker) -> &mut EditSticker,
model
only.Edits a Sticker
, optionally setting its fields.
Requires the Manage Emojis and Stickers permission.
Examples
Rename a sticker:
guild.edit_sticker(&context, StickerId(7), |r| r.name("Bun bun meow"));
Errors
Returns Error::Http
if the current user lacks permission.
sourcepub async fn edit_role_position(
self,
http: impl AsRef<Http>,
role_id: impl Into<RoleId>,
position: u64
) -> Result<Vec<Role>>
Available on crate feature model
only.
pub async fn edit_role_position(
self,
http: impl AsRef<Http>,
role_id: impl Into<RoleId>,
position: u64
) -> Result<Vec<Role>>
model
only.Edits the order of Role
s
Requires the Manage Roles permission.
Examples
Change the order of a role:
use serenity::model::{GuildId, RoleId};
GuildId(7).edit_role_position(&context, RoleId(8), 2);
Errors
Returns an Error::Http
if the current user lacks permission.
sourcepub async fn edit_welcome_screen<F>(
&self,
http: impl AsRef<Http>,
f: F
) -> Result<GuildWelcomeScreen> where
F: FnOnce(&mut EditGuildWelcomeScreen) -> &mut EditGuildWelcomeScreen,
Available on crate feature model
only.
pub async fn edit_welcome_screen<F>(
&self,
http: impl AsRef<Http>,
f: F
) -> Result<GuildWelcomeScreen> where
F: FnOnce(&mut EditGuildWelcomeScreen) -> &mut EditGuildWelcomeScreen,
model
only.Edits the GuildWelcomeScreen
.
Errors
Returns an Error::Http
if some mandatory fields are not provided.
sourcepub async fn edit_widget<F>(
&self,
http: impl AsRef<Http>,
f: F
) -> Result<GuildWidget> where
F: FnOnce(&mut EditGuildWidget) -> &mut EditGuildWidget,
Available on crate feature model
only.
pub async fn edit_widget<F>(
&self,
http: impl AsRef<Http>,
f: F
) -> Result<GuildWidget> where
F: FnOnce(&mut EditGuildWidget) -> &mut EditGuildWidget,
model
only.Edits the GuildWidget
.
Errors
Returns an Error::Http
if the bot does not have the MANAGE_GUILD
permission.
sourcepub async fn roles(
self,
http: impl AsRef<Http>
) -> Result<HashMap<RoleId, Role>>
Available on crate feature model
only.
pub async fn roles(
self,
http: impl AsRef<Http>
) -> Result<HashMap<RoleId, Role>>
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.
sourcepub fn to_guild_cached(self, cache: impl AsRef<Cache>) -> Option<Guild>
Available on crate features model
and cache
only.
pub fn to_guild_cached(self, cache: impl AsRef<Cache>) -> Option<Guild>
model
and cache
only.Tries to find the Guild
by its Id in the cache.
sourcepub async fn to_partial_guild(
self,
http: impl AsRef<Http>
) -> Result<PartialGuild>
Available on crate feature model
only.
pub async fn to_partial_guild(
self,
http: impl AsRef<Http>
) -> Result<PartialGuild>
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.
sourcepub async fn to_partial_guild_with_counts(
self,
http: impl AsRef<Http>
) -> Result<PartialGuild>
Available on crate feature model
only.
pub async fn to_partial_guild_with_counts(
self,
http: impl AsRef<Http>
) -> Result<PartialGuild>
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.
sourcepub async fn emojis(&self, http: impl AsRef<Http>) -> Result<Vec<Emoji>>
Available on crate feature model
only.
pub async fn emojis(&self, http: impl AsRef<Http>) -> Result<Vec<Emoji>>
model
only.sourcepub async fn emoji(
&self,
http: impl AsRef<Http>,
emoji_id: EmojiId
) -> Result<Emoji>
Available on crate feature model
only.
pub async fn emoji(
&self,
http: impl AsRef<Http>,
emoji_id: EmojiId
) -> Result<Emoji>
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.
sourcepub async fn stickers(&self, http: impl AsRef<Http>) -> Result<Vec<Sticker>>
Available on crate feature model
only.
pub async fn stickers(&self, http: impl AsRef<Http>) -> Result<Vec<Sticker>>
model
only.Gets all Sticker
s of this guild via HTTP.
Errors
Returns an Error::Http
if the guild is unavailable.
sourcepub async fn sticker(
&self,
http: impl AsRef<Http>,
sticker_id: StickerId
) -> Result<Sticker>
Available on crate feature model
only.
pub async fn sticker(
&self,
http: impl AsRef<Http>,
sticker_id: StickerId
) -> Result<Sticker>
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.
sourcepub async fn integrations(
self,
http: impl AsRef<Http>
) -> Result<Vec<Integration>>
Available on crate feature model
only.
pub async fn integrations(
self,
http: impl AsRef<Http>
) -> Result<Vec<Integration>>
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.
sourcepub async fn invites(self, http: impl AsRef<Http>) -> Result<Vec<RichInvite>>
Available on crate feature model
only.
pub async fn invites(self, http: impl AsRef<Http>) -> Result<Vec<RichInvite>>
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.
sourcepub async fn kick(
self,
http: impl AsRef<Http>,
user_id: impl Into<UserId>
) -> Result<()>
Available on crate feature model
only.
pub async fn kick(
self,
http: impl AsRef<Http>,
user_id: impl Into<UserId>
) -> Result<()>
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.
sourcepub async fn kick_with_reason(
self,
http: impl AsRef<Http>,
user_id: impl Into<UserId>,
reason: &str
) -> Result<()>
Available on crate feature model
only.
pub async fn kick_with_reason(
self,
http: impl AsRef<Http>,
user_id: impl Into<UserId>,
reason: &str
) -> Result<()>
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.
sourcepub async fn leave(self, http: impl AsRef<Http>) -> Result<()>
Available on crate feature model
only.
pub async fn leave(self, http: impl AsRef<Http>) -> Result<()>
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.
sourcepub async fn member(
self,
cache_http: impl CacheHttp,
user_id: impl Into<UserId>
) -> Result<Member>
Available on crate feature model
only.
pub async fn member(
self,
cache_http: impl CacheHttp,
user_id: impl Into<UserId>
) -> Result<Member>
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
sourcepub 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.
pub async fn members(
self,
http: impl AsRef<Http>,
limit: Option<u64>,
after: impl Into<Option<UserId>>
) -> Result<Vec<Member>>
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.
sourcepub fn members_iter<H: AsRef<Http>>(
self,
http: H
) -> impl Stream<Item = Result<Member>>
Available on crate feature model
only.
pub fn members_iter<H: AsRef<Http>>(
self,
http: H
) -> impl Stream<Item = Result<Member>>
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),
}
}
sourcepub async fn move_member(
self,
http: impl AsRef<Http>,
user_id: impl Into<UserId>,
channel_id: impl Into<ChannelId>
) -> Result<Member>
Available on crate feature model
only.
pub async fn move_member(
self,
http: impl AsRef<Http>,
user_id: impl Into<UserId>,
channel_id: impl Into<ChannelId>
) -> Result<Member>
model
only.Moves a member to a specific voice channel.
Requires the Move Members permission.
Errors
Returns an Error::Http
if the current user
lacks permission, or if the member is not currently
in a voice channel for this Guild
.
sourcepub fn name(self, cache: impl AsRef<Cache>) -> Option<String>
Available on crate features model
and cache
only.
pub fn name(self, cache: impl AsRef<Cache>) -> Option<String>
model
and cache
only.Returns the name of whatever guild this id holds.
sourcepub async fn disconnect_member(
self,
http: impl AsRef<Http>,
user_id: impl Into<UserId>
) -> Result<Member>
Available on crate feature model
only.
pub async fn disconnect_member(
self,
http: impl AsRef<Http>,
user_id: impl Into<UserId>
) -> Result<Member>
model
only.Disconnects a member from a voice channel in the guild.
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.
sourcepub async fn prune_count(
self,
http: impl AsRef<Http>,
days: u16
) -> Result<GuildPrune>
Available on crate feature model
only.
pub async fn prune_count(
self,
http: impl AsRef<Http>,
days: u16
) -> Result<GuildPrune>
model
only.Gets the number of Member
s 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.
sourcepub async fn reorder_channels<It>(
self,
http: impl AsRef<Http>,
channels: It
) -> Result<()> where
It: IntoIterator<Item = (ChannelId, u64)>,
Available on crate feature model
only.
pub async fn reorder_channels<It>(
self,
http: impl AsRef<Http>,
channels: It
) -> Result<()> where
It: IntoIterator<Item = (ChannelId, u64)>,
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.
sourcepub async fn search_members(
self,
http: impl AsRef<Http>,
query: &str,
limit: Option<u64>
) -> Result<Vec<Member>>
Available on crate feature model
only.
pub async fn search_members(
self,
http: impl AsRef<Http>,
query: &str,
limit: Option<u64>
) -> Result<Vec<Member>>
model
only.Returns a list of Member
s 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.
sourcepub fn shard_id(self, cache: impl AsRef<Cache>) -> u64
Available on crate features cache
and utils
and model
only.
pub fn shard_id(self, cache: impl AsRef<Cache>) -> u64
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
.
sourcepub async fn start_integration_sync(
self,
http: impl AsRef<Http>,
integration_id: impl Into<IntegrationId>
) -> Result<()>
Available on crate feature model
only.
pub async fn start_integration_sync(
self,
http: impl AsRef<Http>,
integration_id: impl Into<IntegrationId>
) -> Result<()>
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.
sourcepub async fn start_prune(
self,
http: impl AsRef<Http>,
days: u16
) -> Result<GuildPrune>
Available on crate feature model
only.
pub async fn start_prune(
self,
http: impl AsRef<Http>,
days: u16
) -> Result<GuildPrune>
model
only.Starts a prune of Member
s.
See the documentation on GuildPrune
for more information.
Note: Requires the Kick Members permission.
Errors
Returns Error::Http
if the current user lacks permission.
sourcepub async fn unban(
self,
http: impl AsRef<Http>,
user_id: impl Into<UserId>
) -> Result<()>
Available on crate feature model
only.
pub async fn unban(
self,
http: impl AsRef<Http>,
user_id: impl Into<UserId>
) -> Result<()>
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.
sourcepub async fn vanity_url(self, http: impl AsRef<Http>) -> Result<String>
Available on crate feature model
only.
pub async fn vanity_url(self, http: impl AsRef<Http>) -> Result<String>
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.
sourcepub async fn webhooks(self, http: impl AsRef<Http>) -> Result<Vec<Webhook>>
Available on crate feature model
only.
pub async fn webhooks(self, http: impl AsRef<Http>) -> Result<Vec<Webhook>>
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.
sourcepub fn await_reply(
&self,
shard_messenger: impl AsRef<ShardMessenger>
) -> CollectReplyⓘNotable traits for CollectReplyimpl Future for CollectReply type Output = Option<Arc<Message>>;
Available on crate features model
and collector
only.
pub fn await_reply(
&self,
shard_messenger: impl AsRef<ShardMessenger>
) -> CollectReplyⓘNotable traits for CollectReplyimpl Future for CollectReply type Output = Option<Arc<Message>>;
model
and collector
only.Returns a future that will await one message sent in this guild.
sourcepub fn await_replies(
&self,
shard_messenger: impl AsRef<ShardMessenger>
) -> MessageCollectorBuilder
Available on crate features model
and collector
only.
pub fn await_replies(
&self,
shard_messenger: impl AsRef<ShardMessenger>
) -> MessageCollectorBuilder
model
and collector
only.Returns a stream builder which can be awaited to obtain a stream of messages in this guild.
sourcepub fn await_reaction(
&self,
shard_messenger: impl AsRef<ShardMessenger>
) -> CollectReactionⓘNotable traits for CollectReactionimpl Future for CollectReaction type Output = Option<Arc<ReactionAction>>;
Available on crate features model
and collector
only.
pub fn await_reaction(
&self,
shard_messenger: impl AsRef<ShardMessenger>
) -> CollectReactionⓘNotable traits for CollectReactionimpl Future for CollectReaction type Output = Option<Arc<ReactionAction>>;
model
and collector
only.Await a single reaction in this guild.
sourcepub fn await_reactions(
&self,
shard_messenger: impl AsRef<ShardMessenger>
) -> ReactionCollectorBuilder
Available on crate features model
and collector
only.
pub fn await_reactions(
&self,
shard_messenger: impl AsRef<ShardMessenger>
) -> ReactionCollectorBuilder
model
and collector
only.Returns a stream builder which can be awaited to obtain a stream of reactions sent in this guild.
sourcepub async fn create_application_command<F>(
&self,
http: impl AsRef<Http>,
f: F
) -> Result<ApplicationCommand> where
F: FnOnce(&mut CreateApplicationCommand) -> &mut CreateApplicationCommand,
Available on crate feature model
only.
pub async fn create_application_command<F>(
&self,
http: impl AsRef<Http>,
f: F
) -> Result<ApplicationCommand> where
F: FnOnce(&mut CreateApplicationCommand) -> &mut CreateApplicationCommand,
model
only.Creates a guild specific ApplicationCommand
Note: Unlike global ApplicationCommand
s, guild commands will update instantly.
Errors
Returns the same possible errors as create_global_application_command
.
sourcepub async fn set_application_commands<F>(
&self,
http: impl AsRef<Http>,
f: F
) -> Result<Vec<ApplicationCommand>> where
F: FnOnce(&mut CreateApplicationCommands) -> &mut CreateApplicationCommands,
Available on crate feature model
only.
pub async fn set_application_commands<F>(
&self,
http: impl AsRef<Http>,
f: F
) -> Result<Vec<ApplicationCommand>> where
F: FnOnce(&mut CreateApplicationCommands) -> &mut CreateApplicationCommands,
model
only.Overrides all guild application commands.
Errors
Returns the same possible errors as set_global_application_commands
.
sourcepub async fn create_application_command_permission<F>(
&self,
http: impl AsRef<Http>,
command_id: CommandId,
f: F
) -> Result<ApplicationCommandPermission> where
F: FnOnce(&mut CreateApplicationCommandPermissionsData) -> &mut CreateApplicationCommandPermissionsData,
Available on crate feature model
only.
pub async fn create_application_command_permission<F>(
&self,
http: impl AsRef<Http>,
command_id: CommandId,
f: F
) -> Result<ApplicationCommandPermission> where
F: FnOnce(&mut CreateApplicationCommandPermissionsData) -> &mut CreateApplicationCommandPermissionsData,
model
only.Creates a guild specific ApplicationCommandPermission
.
Note: It will update instantly.
Errors
If there is an error, it will be either Error::Http
or Error::Json
.
sourcepub async fn set_application_commands_permissions<F>(
&self,
http: impl AsRef<Http>,
f: F
) -> Result<Vec<ApplicationCommandPermission>> where
F: FnOnce(&mut CreateApplicationCommandsPermissions) -> &mut CreateApplicationCommandsPermissions,
Available on crate feature model
only.
pub async fn set_application_commands_permissions<F>(
&self,
http: impl AsRef<Http>,
f: F
) -> Result<Vec<ApplicationCommandPermission>> where
F: FnOnce(&mut CreateApplicationCommandsPermissions) -> &mut CreateApplicationCommandsPermissions,
model
only.Overrides all application commands permissions.
Errors
If there is an error, it will be either Error::Http
or Error::Json
.
sourcepub async fn get_application_commands(
&self,
http: impl AsRef<Http>
) -> Result<Vec<ApplicationCommand>>
Available on crate feature model
only.
pub async fn get_application_commands(
&self,
http: impl AsRef<Http>
) -> Result<Vec<ApplicationCommand>>
model
only.Get all guild application commands.
Errors
If there is an error, it will be either Error::Http
or Error::Json
.
sourcepub async fn get_application_command(
&self,
http: impl AsRef<Http>,
command_id: CommandId
) -> Result<ApplicationCommand>
Available on crate feature model
only.
pub async fn get_application_command(
&self,
http: impl AsRef<Http>,
command_id: CommandId
) -> Result<ApplicationCommand>
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
.
sourcepub async fn edit_application_command<F>(
&self,
http: impl AsRef<Http>,
command_id: CommandId,
f: F
) -> Result<ApplicationCommand> where
F: FnOnce(&mut CreateApplicationCommand) -> &mut CreateApplicationCommand,
Available on crate feature model
only.
pub async fn edit_application_command<F>(
&self,
http: impl AsRef<Http>,
command_id: CommandId,
f: F
) -> Result<ApplicationCommand> where
F: FnOnce(&mut CreateApplicationCommand) -> &mut CreateApplicationCommand,
model
only.Edit guild application command by its Id.
Errors
If there is an error, it will be either Error::Http
or Error::Json
.
sourcepub async fn delete_application_command(
&self,
http: impl AsRef<Http>,
command_id: CommandId
) -> Result<()>
Available on crate feature model
only.
pub async fn delete_application_command(
&self,
http: impl AsRef<Http>,
command_id: CommandId
) -> Result<()>
model
only.Delete guild application command by its Id.
Errors
If there is an error, it will be either Error::Http
or Error::Json
.
sourcepub async fn get_application_commands_permissions(
&self,
http: impl AsRef<Http>
) -> Result<Vec<ApplicationCommandPermission>>
Available on crate feature model
only.
pub async fn get_application_commands_permissions(
&self,
http: impl AsRef<Http>
) -> Result<Vec<ApplicationCommandPermission>>
model
only.Get all guild application commands permissions only.
Errors
If there is an error, it will be either Error::Http
or Error::Json
.
sourcepub async fn get_application_command_permissions(
&self,
http: impl AsRef<Http>,
command_id: CommandId
) -> Result<ApplicationCommandPermission>
Available on crate feature model
only.
pub async fn get_application_command_permissions(
&self,
http: impl AsRef<Http>,
command_id: CommandId
) -> Result<ApplicationCommandPermission>
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
.
sourcepub async fn get_welcome_screen(
&self,
http: impl AsRef<Http>
) -> Result<GuildWelcomeScreen>
Available on crate feature model
only.
pub async fn get_welcome_screen(
&self,
http: impl AsRef<Http>
) -> Result<GuildWelcomeScreen>
model
only.Get the guild welcome screen.
Errors
Returns Error::Http
if the guild does not have a welcome screen.
sourcepub async fn get_preview(&self, http: impl AsRef<Http>) -> Result<GuildPreview>
Available on crate feature model
only.
pub async fn get_preview(&self, http: impl AsRef<Http>) -> Result<GuildPreview>
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.
sourcepub async fn get_widget(&self, http: impl AsRef<Http>) -> Result<GuildWidget>
Available on crate feature model
only.
pub async fn get_widget(&self, http: impl AsRef<Http>) -> Result<GuildWidget>
model
only.Get the guild widget.
Errors
Returns Error::Http
if the bot does not have MANAGE_MESSAGES
permission.
sourcepub fn widget_image_url(&self, style: GuildWidgetStyle) -> String
Available on crate feature model
only.
pub fn widget_image_url(&self, style: GuildWidgetStyle) -> String
model
only.Get the widget image URL.
sourcepub async fn get_active_threads(
&self,
http: impl AsRef<Http>
) -> Result<ThreadsData>
Available on crate feature model
only.
pub async fn get_active_threads(
&self,
http: impl AsRef<Http>
) -> Result<ThreadsData>
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.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for GuildId
impl<'de> Deserialize<'de> for GuildId
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<'a> From<&'a InviteGuild> for GuildId
impl<'a> From<&'a InviteGuild> for GuildId
sourcefn from(invite_guild: &InviteGuild) -> GuildId
fn from(invite_guild: &InviteGuild) -> GuildId
Gets the Id of Invite Guild struct.
sourceimpl<'a> From<&'a PartialGuild> for GuildId
impl<'a> From<&'a PartialGuild> for GuildId
sourcefn from(guild: &PartialGuild) -> GuildId
fn from(guild: &PartialGuild) -> GuildId
Gets the Id of a partial guild.
sourceimpl From<GuildId> for GuildContainer
impl From<GuildId> for GuildContainer
sourcefn from(guild_id: GuildId) -> GuildContainer
fn from(guild_id: GuildId) -> GuildContainer
Converts to this type from the input type.
sourceimpl From<InviteGuild> for GuildId
impl From<InviteGuild> for GuildId
sourcefn from(invite_guild: InviteGuild) -> GuildId
fn from(invite_guild: InviteGuild) -> GuildId
Gets the Id of Invite Guild struct.
sourceimpl From<PartialGuild> for GuildId
impl From<PartialGuild> for GuildId
sourcefn from(guild: PartialGuild) -> GuildId
fn from(guild: PartialGuild) -> GuildId
Gets the Id of a partial guild.
sourceimpl Ord for GuildId
impl Ord for GuildId
sourceimpl PartialOrd<GuildId> for GuildId
impl PartialOrd<GuildId> for GuildId
sourcefn partial_cmp(&self, other: &GuildId) -> Option<Ordering>
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 · sourcefn lt(&self, other: &Rhs) -> bool
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 · sourcefn le(&self, other: &Rhs) -> bool
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
impl Copy for GuildId
impl Eq for GuildId
impl StructuralEq for GuildId
impl StructuralPartialEq for GuildId
Auto Trait Implementations
impl RefUnwindSafe for GuildId
impl Send for GuildId
impl Sync for GuildId
impl Unpin for GuildId
impl UnwindSafe for GuildId
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more