[−][src]Struct serenity::model::guild::Guild
Information about a Discord guild, such as channels, emojis, etc.
Fields
afk_channel_id: Option<ChannelId>
Id of a voice channel that's considered the AFK channel.
afk_timeout: u64
The amount of seconds a user can not show any activity in a voice channel before being moved to an AFK channel -- if one exists.
application_id: Option<ApplicationId>
Application ID of the guild creator if it is bot-created.
channels: HashMap<ChannelId, GuildChannel>
All voice and text channels contained within a guild.
This contains all channels regardless of permissions (i.e. the ability of the bot to read from or connect to them).
default_message_notifications: DefaultMessageNotificationLevel
Indicator of whether notifications for all messages are enabled by default in the guild.
emojis: HashMap<EmojiId, Emoji>
All of the guild's custom emojis.
explicit_content_filter: ExplicitContentFilter
Default explicit content filter level.
features: Vec<String>
VIP features enabled for the guild. Can be obtained through the Discord Partnership website.
The following is a list of known features:
INVITE_SPLASH
VANITY_URL
VERIFIED
VIP_REGIONS
PARTNERED
MORE_EMOJI
DISCOVERABLE
FEATURABLE
COMMERCE
PUBLIC
NEWS
BANNER
ANIMATED_ICON
PUBLIC_DISABLED
COMMUNITY
WELCOME_SCREEN_ENABLED
icon: Option<String>
The hash of the icon used by the guild.
In the client, this appears on the guild list on the left-hand side.
id: GuildId
The unique Id identifying the guild.
This is equivilant to the Id of the default role (@everyone
) and also
that of the default channel (typically #general
).
joined_at: DateTime<Utc>
The date that the current user joined the guild.
large: bool
Indicator of whether the guild is considered "large" by Discord.
member_count: u64
The number of members in the guild.
members: HashMap<UserId, Member>
Users who are members of the guild.
Members might not all be available when the ReadyEvent
is received
if the member_count
is greater than the LARGE_THRESHOLD
set by
the library.
mfa_level: MfaLevel
Indicator of whether the guild requires multi-factor authentication for
Role
s or User
s with moderation permissions.
name: String
The name of the guild.
owner_id: UserId
The Id of the User
who owns the guild.
presences: HashMap<UserId, Presence>
A mapping of User
s' Ids to their current presences.
region: String
The region that the voice servers that the guild uses are located in.
roles: HashMap<RoleId, Role>
A mapping of the guild's roles.
splash: Option<String>
An identifying hash of the guild's splash icon.
If the ["InviteSplash"
] feature is enabled, this can be used to generate
a URL to a splash image.
system_channel_id: Option<ChannelId>
The ID of the channel to which system messages are sent.
verification_level: VerificationLevel
Indicator of the current verification level of the guild.
voice_states: HashMap<UserId, VoiceState>
A mapping of User
s to their current voice state.
description: Option<String>
The server's description
The server's premium boosting level.
The total number of users currently boosting this server.
The server's banner.
vanity_url_code: Option<String>
The vanity url code for the guild.
preferred_locale: String
The preferred locale of this guild only set if guild has the "DISCOVERABLE" feature, defaults to en-US.
Implementations
impl Guild
[src]
pub async fn default_channel<'_, '_>(
&'_ self,
uid: UserId
) -> Option<&'_ GuildChannel>
[src]
&'_ self,
uid: UserId
) -> Option<&'_ GuildChannel>
Returns the "default" channel of the guild for the passed user id.
(This returns the first channel that can be read by the user, if there isn't one,
returns None
)
pub async fn default_channel_guaranteed<'_, '_>(
&'_ self
) -> Option<&'_ GuildChannel>
[src]
&'_ self
) -> Option<&'_ GuildChannel>
Returns the guaranteed "default" channel of the guild.
(This returns the first channel that can be read by everyone, if there isn't one,
returns None
)
Note however that this is very costy if used in a server with lots of channels,
members, or both.
pub async fn channel_id_from_name<'_>(
&'_ self,
cache: impl AsRef<Cache>,
name: impl AsRef<str>
) -> Option<ChannelId>
[src]
&'_ self,
cache: impl AsRef<Cache>,
name: impl AsRef<str>
) -> Option<ChannelId>
pub async fn ban<'_>(
&'_ self,
cache_http: impl CacheHttp,
user: impl Into<UserId>,
dmd: u8
) -> Result<()>
[src]
&'_ self,
cache_http: impl CacheHttp,
user: impl Into<UserId>,
dmd: u8
) -> Result<()>
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:
// assumes a `user` and `guild` have already been bound let _ = guild.ban(user, 4);
Errors
Returns a ModelError::InvalidPermissions
if the current user does
not have permission to perform bans.
Returns a ModelError::DeleteMessageDaysAmount
if the number of
days' worth of messages to delete is over the maximum.
pub async fn ban_with_reason<'_>(
&'_ self,
cache_http: impl CacheHttp,
user: impl Into<UserId>,
dmd: u8,
reason: impl AsRef<str>
) -> Result<()>
[src]
&'_ self,
cache_http: impl CacheHttp,
user: impl Into<UserId>,
dmd: u8,
reason: impl AsRef<str>
) -> Result<()>
pub async fn bans<'_>(&'_ self, cache_http: impl CacheHttp) -> Result<Vec<Ban>>
[src]
Retrieves a list of Ban
s for the guild.
Note: Requires the Ban Members permission.
Errors
If the cache
is enabled, returns a ModelError::InvalidPermissions
if the current user does not have permission to perform bans.
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>
[src]
&'_ self,
http: impl AsRef<Http>,
action_type: Option<u8>,
user_id: Option<UserId>,
before: Option<AuditLogEntryId>,
limit: Option<u8>
) -> Result<AuditLogs>
Retrieves a list of AuditLogs
for the guild.
pub async fn channels<'_>(
&'_ self,
http: impl AsRef<Http>
) -> Result<HashMap<ChannelId, GuildChannel>>
[src]
&'_ self,
http: impl AsRef<Http>
) -> Result<HashMap<ChannelId, GuildChannel>>
Gets all of the guild's channels over the REST API.
pub async fn create<'_, '_>(
http: impl AsRef<Http>,
name: &'_ str,
region: Region,
icon: Option<&'_ str>
) -> Result<PartialGuild>
[src]
http: impl AsRef<Http>,
name: &'_ str,
region: Region,
icon: Option<&'_ str>
) -> Result<PartialGuild>
Creates a guild with the data provided.
Only a PartialGuild
will be immediately returned, and a full
Guild
will be received over a Shard
.
Note: This endpoint is usually only available for user accounts. Refer to Discord's information for the endpoint here for more information. If you require this as a bot, re-think what you are doing and if it really needs to be doing this.
Examples
Create a guild called "test"
in the US West region with no icon:
use serenity::model::{Guild, Region}; let _guild = Guild::create_guild(&http, "test", Region::UsWest, None).await;
pub async fn create_channel<'_>(
&'_ self,
cache_http: impl CacheHttp,
f: impl FnOnce(&mut CreateChannel) -> &mut CreateChannel
) -> Result<GuildChannel>
[src]
&'_ self,
cache_http: impl CacheHttp,
f: impl FnOnce(&mut CreateChannel) -> &mut CreateChannel
) -> Result<GuildChannel>
Creates a new Channel
in the guild.
Note: Requires the Manage Channels permission.
Examples
use serenity::model::ChannelType; // assuming a `guild` has already been bound let _ = guild .create_channel(&http, |c| c.name("my-test-channel").kind(ChannelType::Text)) .await;
Errors
If the cache
is enabled, returns a ModelError::InvalidPermissions
if the current user does not have permission to perform bans.
pub async fn create_emoji<'_, '_, '_>(
&'_ self,
http: impl AsRef<Http>,
name: &'_ str,
image: &'_ str
) -> Result<Emoji>
[src]
&'_ self,
http: impl AsRef<Http>,
name: &'_ str,
image: &'_ str
) -> Result<Emoji>
Creates an emoji in the guild with a name and base64-encoded image. The
utils::read_image
function is provided for you as a simple method to
read an image and encode it into base64, if you are reading from the
filesystem.
The name of the emoji must be at least 2 characters long and can only contain alphanumeric characters and underscores.
Requires the Manage Emojis 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.
pub async fn create_integration<I, '_, '_>(
&'_ self,
http: impl AsRef<Http>,
integration_id: impl Into<IntegrationId>,
kind: &'_ str
) -> Result<()>
[src]
&'_ self,
http: impl AsRef<Http>,
integration_id: impl Into<IntegrationId>,
kind: &'_ str
) -> Result<()>
Creates an integration for the guild.
Requires the Manage Guild permission.
pub async fn create_role<F, '_>(
&'_ self,
cache_http: impl CacheHttp,
f: F
) -> Result<Role> where
F: FnOnce(&mut EditRole) -> &mut EditRole,
[src]
&'_ self,
cache_http: impl CacheHttp,
f: F
) -> Result<Role> where
F: FnOnce(&mut EditRole) -> &mut EditRole,
Creates a new role in the guild with the data set, if any.
Note: Requires the Manage Roles permission.
Examples
Create a role which can be mentioned, with the name 'test':
// assuming a `guild` has been bound let role = guild.create_role(&http, |r| r.hoist(true).name("role")).await;
Errors
If the cache
is enabled, returns a ModelError::InvalidPermissions
if the current user does not have permission to perform bans.
pub async fn delete<'_>(
&'_ self,
cache_http: impl CacheHttp
) -> Result<PartialGuild>
[src]
&'_ self,
cache_http: impl CacheHttp
) -> Result<PartialGuild>
Deletes the current guild if the current user is the owner of the guild.
Note: Requires the current user to be the owner of the guild.
Errors
If the cache
is enabled, then returns a ModelError::InvalidUser
if the current user is not the guild owner.
pub async fn delete_emoji<'_>(
&'_ self,
http: impl AsRef<Http>,
emoji_id: impl Into<EmojiId>
) -> Result<()>
[src]
&'_ self,
http: impl AsRef<Http>,
emoji_id: impl Into<EmojiId>
) -> Result<()>
Deletes an Emoji
from the guild.
Requires the Manage Emojis permission.
pub async fn delete_integration<'_>(
&'_ self,
http: impl AsRef<Http>,
integration_id: impl Into<IntegrationId>
) -> Result<()>
[src]
&'_ self,
http: impl AsRef<Http>,
integration_id: impl Into<IntegrationId>
) -> Result<()>
Deletes an integration by Id from the guild.
Requires the Manage Guild permission.
pub async fn delete_role<'_>(
&'_ self,
http: impl AsRef<Http>,
role_id: impl Into<RoleId>
) -> Result<()>
[src]
&'_ self,
http: impl AsRef<Http>,
role_id: impl Into<RoleId>
) -> Result<()>
Deletes a Role
by Id from the guild.
Also see Role::delete
if you have the cache
and methods
features
enabled.
Requires the Manage Roles permission.
pub async fn edit<F, '_>(
&'_ mut self,
cache_http: impl CacheHttp,
f: F
) -> Result<()> where
F: FnOnce(&mut EditGuild) -> &mut EditGuild,
[src]
&'_ mut self,
cache_http: impl CacheHttp,
f: F
) -> Result<()> where
F: FnOnce(&mut EditGuild) -> &mut EditGuild,
Edits the current guild with new data where specified.
Refer to EditGuild
's documentation for a full list of methods.
Note: Requires the current user to have the Manage Guild permission.
Examples
Change a guild's icon using a file name "icon.png":
use serenity::utils; // We are using read_image helper function from utils. let base64_icon = utils::read_image("./icon.png") .expect("Failed to read image"); guild.edit(|g| g.icon(base64_icon));
Errors
If the cache
is enabled, returns a ModelError::InvalidPermissions
if the current user does not have permission to perform bans.
pub async fn edit_emoji<'_, '_>(
&'_ self,
http: impl AsRef<Http>,
emoji_id: impl Into<EmojiId>,
name: &'_ str
) -> Result<Emoji>
[src]
&'_ self,
http: impl AsRef<Http>,
emoji_id: impl Into<EmojiId>,
name: &'_ str
) -> Result<Emoji>
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 permission.
pub async fn edit_member<F, '_>(
&'_ self,
http: impl AsRef<Http>,
user_id: impl Into<UserId>,
f: F
) -> Result<()> where
F: FnOnce(&mut EditMember) -> &mut EditMember,
[src]
&'_ self,
http: impl AsRef<Http>,
user_id: impl Into<UserId>,
f: F
) -> Result<()> where
F: FnOnce(&mut EditMember) -> &mut EditMember,
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(user_id, |m| m.mute(true).roles(&vec![role_id]));
pub async fn edit_nickname<'_, '_>(
&'_ self,
cache_http: impl CacheHttp,
new_nickname: Option<&'_ str>
) -> Result<()>
[src]
&'_ self,
cache_http: impl CacheHttp,
new_nickname: Option<&'_ str>
) -> Result<()>
Edits the current user's nickname for the guild.
Pass None
to reset the nickname.
Note: Requires the Change Nickname permission.
Errors
If the cache
is enabled, returns a ModelError::InvalidPermissions
if the current user does not have permission to change their own
nickname.
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,
[src]
&'_ self,
http: impl AsRef<Http>,
role_id: impl Into<RoleId>,
f: F
) -> Result<Role> where
F: FnOnce(&mut EditRole) -> &mut EditRole,
Edits a role, optionally setting its fields.
Requires the Manage Roles permission.
Examples
Make a role hoisted:
guild.edit_role(&context, RoleId(7), |r| r.hoist(true));
pub async fn edit_role_position<'_>(
&'_ self,
http: impl AsRef<Http>,
role_id: impl Into<RoleId>,
position: u64
) -> Result<Vec<Role>>
[src]
&'_ self,
http: impl AsRef<Http>,
role_id: impl Into<RoleId>,
position: u64
) -> Result<Vec<Role>>
Edits the order of Role
s
Requires the Manage Roles permission.
Examples
Change the order of a role:
use serenity::model::id::RoleId; guild.edit_role_position(&context, RoleId(8), 2);
pub async fn get(
http: impl AsRef<Http>,
guild_id: impl Into<GuildId>
) -> Result<PartialGuild>
[src]
http: impl AsRef<Http>,
guild_id: impl Into<GuildId>
) -> Result<PartialGuild>
Gets a partial amount of guild data by its Id.
Requires that the current user be in the guild.
pub async fn greater_member_hierarchy<'_>(
&'_ self,
cache: impl AsRef<Cache>,
lhs_id: impl Into<UserId>,
rhs_id: impl Into<UserId>
) -> Option<UserId>
[src]
&'_ self,
cache: impl AsRef<Cache>,
lhs_id: impl Into<UserId>,
rhs_id: impl Into<UserId>
) -> Option<UserId>
Returns which of two User
s has a higher Member
hierarchy.
Hierarchy is essentially who has the Role
with the highest
position
.
Returns None
if at least one of the given users' member instances
is not present. Returns None
if the users have the same hierarchy, as
neither are greater than the other.
If both user IDs are the same, None
is returned. If one of the users
is the guild owner, their ID is returned.
pub fn icon_url(&self) -> Option<String>
[src]
Returns the formatted URL of the guild's icon, if one exists.
pub async fn emojis<'_>(&'_ self, http: impl AsRef<Http>) -> Result<Vec<Emoji>>
[src]
Gets all Emoji
s of this guild via HTTP.
pub async fn emoji<'_>(
&'_ self,
http: impl AsRef<Http>,
emoji_id: EmojiId
) -> Result<Emoji>
[src]
&'_ self,
http: impl AsRef<Http>,
emoji_id: EmojiId
) -> Result<Emoji>
Gets an Emoji
of this guild by its ID via HTTP.
pub async fn integrations<'_>(
&'_ self,
http: impl AsRef<Http>
) -> Result<Vec<Integration>>
[src]
&'_ self,
http: impl AsRef<Http>
) -> Result<Vec<Integration>>
Gets all integration of the guild.
This performs a request over the REST API.
pub async fn invites<'_>(
&'_ self,
cache_http: impl CacheHttp
) -> Result<Vec<RichInvite>>
[src]
&'_ self,
cache_http: impl CacheHttp
) -> Result<Vec<RichInvite>>
Retrieves the active invites for the guild.
Note: Requires the Manage Guild permission.
Errors
If the cache
is enabled, returns a ModelError::InvalidPermissions
if the current user does not have permission to perform bans.
pub fn is_large(&self) -> bool
[src]
Checks if the guild is 'large'. A guild is considered large if it has more than 250 members.
pub async fn kick<'_>(
&'_ self,
http: impl AsRef<Http>,
user_id: impl Into<UserId>
) -> Result<()>
[src]
&'_ self,
http: impl AsRef<Http>,
user_id: impl Into<UserId>
) -> Result<()>
Kicks a Member
from the guild.
Requires the Kick Members permission.
pub async fn kick_with_reason<'_, '_>(
&'_ self,
http: impl AsRef<Http>,
user_id: impl Into<UserId>,
reason: &'_ str
) -> Result<()>
[src]
&'_ self,
http: impl AsRef<Http>,
user_id: impl Into<UserId>,
reason: &'_ str
) -> Result<()>
pub async fn leave<'_>(&'_ self, http: impl AsRef<Http>) -> Result<()>
[src]
Leaves the guild.
pub async fn member<'_>(
&'_ self,
cache_http: impl CacheHttp,
user_id: impl Into<UserId>
) -> Result<Member>
[src]
&'_ self,
cache_http: impl CacheHttp,
user_id: impl Into<UserId>
) -> Result<Member>
Gets a user's Member
for the guild by Id.
pub async fn members<'_>(
&'_ self,
http: impl AsRef<Http>,
limit: Option<u64>,
after: impl Into<Option<UserId>>
) -> Result<Vec<Member>>
[src]
&'_ self,
http: impl AsRef<Http>,
limit: Option<u64>,
after: impl Into<Option<UserId>>
) -> Result<Vec<Member>>
Gets a list of the guild's members.
Optionally pass in the limit
to limit the number of results. Maximum
value is 1000. Optionally pass in after
to offset the results by a
User
's Id.
pub fn members_with_status(&self, status: OnlineStatus) -> Vec<&Member>
[src]
Gets a list of all the members (satisfying the status provided to the function) in this guild.
pub fn member_named(&self, name: &str) -> Option<&Member>
[src]
Retrieves the first Member
found that matches the name - with an
optional discriminator - provided.
Searching with a discriminator given is the most precise form of lookup, as no two people can share the same username and discriminator.
If a member can not be found by username or username#discriminator,
then a search will be done for the nickname. When searching by nickname,
the hash (#
) and everything after it is included in the search.
The following are valid types of searches:
- username: "zey"
- username and discriminator: "zey#5479"
pub async fn members_starting_with<'_, '_, '_>(
&'_ self,
prefix: &'_ str,
case_sensitive: bool,
sorted: bool
) -> Vec<(&'_ Member, String)>
[src]
&'_ self,
prefix: &'_ str,
case_sensitive: bool,
sorted: bool
) -> Vec<(&'_ Member, String)>
Retrieves all Member
that start with a given String
.
sorted
decides whether the best early match of the prefix
should be the criteria to sort the result.
For the prefix
"zey" and the unsorted result:
- "zeya", "zeyaa", "zeyla", "zeyzey", "zeyzeyzey" It would be sorted:
- "zeya", "zeyaa", "zeyla", "zeyzey", "zeyzeyzey"
Locking:
First collects a Member
's User
-name by read-locking all inner
User
s, and then sorts. This ensures that no name is being changed
after being sorted in the originally correct position.
However, since the read-locks are dropped after borrowing the name,
the names might have been changed by the user, the sorted list cannot
account for this.
pub async fn members_containing<'_, '_, '_>(
&'_ self,
substring: &'_ str,
case_sensitive: bool,
sorted: bool
) -> Vec<(&'_ Member, String)>
[src]
&'_ self,
substring: &'_ str,
case_sensitive: bool,
sorted: bool
) -> Vec<(&'_ Member, String)>
Retrieves all Member
containing a given String
as
either username or nick, with a priority on username.
If the substring is "yla", following results are possible:
- "zeyla", "meiyla", "yladenisyla" If 'case_sensitive' is false, the following are not found:
- "zeYLa", "meiyLa", "LYAdenislyA"
sorted
decides whether the best early match of the search-term
should be the criteria to sort the result.
It will look at the account name first, if that does not fit the
search-criteria substring
, the display-name will be considered.
For the substring
"zey" and the unsorted result:
- "azey", "zey", "zeyla", "zeylaa", "zeyzeyzey" It would be sorted:
- "zey", "azey", "zeyla", "zeylaa", "zeyzeyzey"
Note: Due to two fields of a Member
being candidates for
the searched field, setting sorted
to true
will result in an overhead,
as both fields have to be considered again for sorting.
Locking:
First collects a Member
's User
-name by read-locking all inner
User
s, and then sorts. This ensures that no name is being changed
after being sorted in the originally correct position.
However, since the read-locks are dropped after borrowing the name,
the names might have been changed by the user, the sorted list cannot
account for this.
pub async fn members_username_containing<'_, '_, '_>(
&'_ self,
substring: &'_ str,
case_sensitive: bool,
sorted: bool
) -> Vec<(&'_ Member, String)>
[src]
&'_ self,
substring: &'_ str,
case_sensitive: bool,
sorted: bool
) -> Vec<(&'_ Member, String)>
Retrieves a tuple of Member
s containing a given String
in
their username as the first field and the name used for sorting
as the second field.
If the substring is "yla", following results are possible:
- "zeyla", "meiyla", "yladenisyla" If 'case_sensitive' is false, the following are not found:
- "zeYLa", "meiyLa", "LYAdenislyA"
sort
decides whether the best early match of the search-term
should be the criteria to sort the result.
For the substring
"zey" and the unsorted result:
- "azey", "zey", "zeyla", "zeylaa", "zeyzeyzey" It would be sorted:
- "zey", "azey", "zeyla", "zeylaa", "zeyzeyzey"
Locking:
First collects a Member
's User
-name by read-locking all inner
User
s, and then sorts. This ensures that no name is being changed
after being sorted in the originally correct position.
However, since the read-locks are dropped after borrowing the name,
the names might have been changed by the user, the sorted list cannot
account for this.
pub async fn members_nick_containing<'_, '_, '_>(
&'_ self,
substring: &'_ str,
case_sensitive: bool,
sorted: bool
) -> Vec<(&'_ Member, String)>
[src]
&'_ self,
substring: &'_ str,
case_sensitive: bool,
sorted: bool
) -> Vec<(&'_ Member, String)>
Retrieves all Member
containing a given String
in
their nick.
If the substring is "yla", following results are possible:
- "zeyla", "meiyla", "yladenisyla" If 'case_sensitive' is false, the following are not found:
- "zeYLa", "meiyLa", "LYAdenislyA"
sort
decides whether the best early match of the search-term
should be the criteria to sort the result.
For the substring
"zey" and the unsorted result:
- "azey", "zey", "zeyla", "zeylaa", "zeyzeyzey" It would be sorted:
- "zey", "azey", "zeyla", "zeylaa", "zeyzeyzey"
Note: Instead of panicing, when sorting does not find a nick, the username will be used (this should never happen).
Locking:
First collects a Member
's nick directly or by read-locking all inner
User
s (in case of no nick, see note above), and then sorts.
This ensures that no name is being changed after being sorted in the
originally correct position.
However, since the read-locks are dropped after borrowing the name,
the names might have been changed by the user, the sorted list cannot
account for this.
pub fn member_permissions(&self, user_id: impl Into<UserId>) -> Permissions
[src]
Calculate a Member
's permissions in the guild.
pub async fn move_member<'_>(
&'_ self,
http: impl AsRef<Http>,
user_id: impl Into<UserId>,
channel_id: impl Into<ChannelId>
) -> Result<()>
[src]
&'_ self,
http: impl AsRef<Http>,
user_id: impl Into<UserId>,
channel_id: impl Into<ChannelId>
) -> Result<()>
Moves a member to a specific voice channel.
Requires the Move Members permission.
pub fn user_permissions_in(
&self,
channel_id: impl Into<ChannelId>,
user_id: impl Into<UserId>
) -> Permissions
[src]
&self,
channel_id: impl Into<ChannelId>,
user_id: impl Into<UserId>
) -> Permissions
Calculate a User
's permissions in a given channel in the guild.
pub fn role_permissions_in(
&self,
channel_id: impl Into<ChannelId>,
role_id: impl Into<RoleId>
) -> Option<Permissions>
[src]
&self,
channel_id: impl Into<ChannelId>,
role_id: impl Into<RoleId>
) -> Option<Permissions>
Calculate a Role
's permissions in a given channel in the guild.
Returns None
if given role_id
cannot be found.
pub async fn prune_count<'_>(
&'_ self,
cache_http: impl CacheHttp,
days: u16
) -> Result<GuildPrune>
[src]
&'_ self,
cache_http: impl CacheHttp,
days: u16
) -> Result<GuildPrune>
Retrieves the count of the number of Member
s that would be pruned
with the number of given days.
See the documentation on GuildPrune
for more information.
Note: Requires the Kick Members permission.
Errors
If the cache
is enabled, returns a ModelError::InvalidPermissions
if the current user does not have permission to perform bans.
pub async fn reorder_channels<It, '_>(
&'_ self,
http: impl AsRef<Http>,
channels: It
) -> Result<()> where
It: IntoIterator<Item = (ChannelId, u64)>,
[src]
&'_ self,
http: impl AsRef<Http>,
channels: It
) -> Result<()> where
It: IntoIterator<Item = (ChannelId, u64)>,
Re-orders the channels of the guild.
Although not required, you should specify all channels' positions, regardless of whether they were updated. Otherwise, positioning can sometimes get weird.
pub async fn shard_id<'_>(&'_ self, cache: impl AsRef<Cache>) -> u64
[src]
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
.
pub fn splash_url(&self) -> Option<String>
[src]
Returns the formatted URL of the guild's splash image, if one exists.
pub async fn start_integration_sync<'_>(
&'_ self,
http: impl AsRef<Http>,
integration_id: impl Into<IntegrationId>
) -> Result<()>
[src]
&'_ self,
http: impl AsRef<Http>,
integration_id: impl Into<IntegrationId>
) -> Result<()>
Starts an integration sync for the given integration Id.
Requires the Manage Guild permission.
pub async fn start_prune<'_>(
&'_ self,
cache_http: impl CacheHttp,
days: u16
) -> Result<GuildPrune>
[src]
&'_ self,
cache_http: impl CacheHttp,
days: u16
) -> Result<GuildPrune>
Starts a prune of Member
s.
See the documentation on GuildPrune
for more information.
Note: Requires the Kick Members permission.
Errors
If the cache
is enabled, returns a ModelError::InvalidPermissions
if the current user does not have permission to perform bans.
pub async fn unban<'_>(
&'_ self,
cache_http: impl CacheHttp,
user_id: impl Into<UserId>
) -> Result<()>
[src]
&'_ self,
cache_http: impl CacheHttp,
user_id: impl Into<UserId>
) -> Result<()>
Unbans the given User
from the guild.
Note: Requires the Ban Members permission.
Errors
If the cache
is enabled, returns a ModelError::InvalidPermissions
if the current user does not have permission to perform bans.
pub async fn vanity_url<'_>(&'_ self, http: impl AsRef<Http>) -> Result<String>
[src]
Retrieve's the guild's vanity URL.
Note: Requires the Manage Guild permission.
pub async fn webhooks<'_>(
&'_ self,
http: impl AsRef<Http>
) -> Result<Vec<Webhook>>
[src]
&'_ self,
http: impl AsRef<Http>
) -> Result<Vec<Webhook>>
Retrieves the guild's webhooks.
Note: Requires the Manage Webhooks permission.
pub fn role_by_name(&self, role_name: &str) -> Option<&Role>
[src]
Obtain a reference to a role by its name.
Note: If two or more roles have the same name, obtained reference will be one of them.
Examples
Obtain a reference to a Role
by its name.
use serenity::model::prelude::*; use serenity::prelude::*; struct Handler; #[serenity::async_trait] impl EventHandler for Handler { async fn message(&self, ctx: Context, msg: Message) { if let Some(guild_id) = msg.guild_id { if let Some(guild) = guild_id.to_guild_cached(&ctx).await { if let Some(role) = guild.role_by_name("role_name") { println!("{:?}", role); } } } } } let mut client = Client::builder("token").event_handler(Handler).await?; client.start().await?;
Trait Implementations
impl Clone for Guild
[src]
impl Debug for Guild
[src]
impl<'de> Deserialize<'de> for Guild
[src]
pub fn deserialize<D: Deserializer<'de>>(
deserializer: D
) -> StdResult<Self, D::Error>
[src]
deserializer: D
) -> StdResult<Self, D::Error>
impl<'a> From<&'a Guild> for GuildId
[src]
impl From<Guild> for GuildId
[src]
impl Serialize for Guild
[src]
Auto Trait Implementations
impl RefUnwindSafe for Guild
impl Send for Guild
impl Sync for Guild
impl Unpin for Guild
impl UnwindSafe for Guild
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,
pub fn vzip(self) -> V
impl<T> WithSubscriber for T
[src]
pub fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
[src]
S: Into<Dispatch>,