#[non_exhaustive]pub struct Role {
pub id: RoleId,
pub guild_id: GuildId,
pub colour: Colour,
pub hoist: bool,
pub managed: bool,
pub mentionable: bool,
pub name: String,
pub permissions: Permissions,
pub position: u16,
pub tags: RoleTags,
pub icon: Option<ImageHash>,
pub unicode_emoji: Option<String>,
}
Expand description
Information about a role within a guild.
A role represents a set of permissions, and can be attached to one or multiple users. A role has various miscellaneous configurations, such as being assigned a colour. Roles are unique per guild and do not cross over to other guilds in any way, and can have channel-specific permission overrides in addition to guild-level permissions.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.id: RoleId
The Id of the role. Can be used to calculate the role’s creation date.
guild_id: GuildId
The Id of the Guild the Role is in.
colour: Colour
The colour of the role.
hoist: bool
Indicator of whether the role is pinned above lesser roles.
In the client, this causes Member
s in the role to be seen above those in roles with a
lower Self::position
.
managed: bool
Indicator of whether the role is managed by an integration service.
mentionable: bool
Indicator of whether the role can be mentioned, similar to mentioning a specific member or
@everyone
.
Only members of the role will be notified if a role is mentioned with this set to true
.
name: String
The name of the role.
permissions: Permissions
A set of permissions that the role has been assigned.
See the permissions
module for more information.
position: u16
The role’s position in the position list. Roles are considered higher in hierarchy if their position is higher.
The @everyone
role is usually either -1
or 0
.
The tags this role has. It can be used to determine if this role is a special role in this
guild such as guild subscriber role, or if the role is linked to an Integration
or a
bot.
icon: Option<ImageHash>
Role icon image hash.
unicode_emoji: Option<String>
Role unicoded image.
Implementations§
Source§impl Role
impl Role
Sourcepub async fn delete(&mut self, http: impl AsRef<Http>) -> Result<()>
pub async fn delete(&mut self, http: impl AsRef<Http>) -> Result<()>
Deletes the role.
Note Requires the Manage Roles permission.
§Errors
Returns Error::Http
if the current user lacks permission to delete this role.
Sourcepub async fn edit(
&mut self,
http: impl AsRef<Http>,
builder: EditRole<'_>,
) -> Result<()>
pub async fn edit( &mut self, http: impl AsRef<Http>, builder: EditRole<'_>, ) -> Result<()>
Edits a Role
, optionally setting its new fields.
Requires the Manage Roles permission.
§Examples
See the documentation of EditRole
for details.
§Errors
Returns Error::Http
if the current user does not have permission to Manage Roles.
Sourcepub fn has_permission(&self, permission: Permissions) -> bool
pub fn has_permission(&self, permission: Permissions) -> bool
Check that the role has the given permission.
Sourcepub fn has_permissions(&self, permissions: Permissions, precise: bool) -> bool
pub fn has_permissions(&self, permissions: Permissions, precise: bool) -> bool
Checks whether the role has all of the given permissions.
The ‘precise’ argument is used to check if the role’s permissions are precisely equivalent
to the given permissions. If you need only check that the role has at least the given
permissions, pass false
.
Trait Implementations§
Source§impl ArgumentConvert for Role
Look up a Role
by a string case-insensitively.
impl ArgumentConvert for Role
Look up a Role
by a string case-insensitively.
Requires the cache feature to be enabled.
The lookup strategy is as follows (in order):
- Lookup by ID
- Lookup by mention.
- Lookup by name (case-insensitive)
Source§type Err = RoleParseError
type Err = RoleParseError
Source§fn convert<'life0, 'async_trait>(
ctx: impl 'async_trait + CacheHttp,
guild_id: Option<GuildId>,
_channel_id: Option<ChannelId>,
s: &'life0 str,
) -> Pin<Box<dyn Future<Output = Result<Self, Self::Err>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn convert<'life0, 'async_trait>(
ctx: impl 'async_trait + CacheHttp,
guild_id: Option<GuildId>,
_channel_id: Option<ChannelId>,
s: &'life0 str,
) -> Pin<Box<dyn Future<Output = Result<Self, Self::Err>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
s
as a command parameter of this type.Source§impl<'de> Deserialize<'de> for Role
impl<'de> Deserialize<'de> for Role
Source§fn 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>,
Source§impl Mentionable for Role
impl Mentionable for Role
Source§impl Ord for Role
impl Ord for Role
Source§impl PartialOrd for Role
impl PartialOrd for Role
impl Eq for Role
Auto Trait Implementations§
impl Freeze for Role
impl RefUnwindSafe for Role
impl Send for Role
impl Sync for Role
impl Unpin for Role
impl UnwindSafe for Role
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneDebuggableStorage for Twhere
T: DebuggableStorage + Clone,
impl<T> CloneDebuggableStorage for Twhere
T: DebuggableStorage + Clone,
fn clone_storage(&self) -> Box<dyn CloneDebuggableStorage>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> CloneableStorage for T
impl<T> CloneableStorage for T
fn clone_storage(&self) -> Box<dyn CloneableStorage>
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.