Struct serenity::model::guild::Role [−][src]
pub struct Role { pub id: RoleId, pub colour: Colour, pub hoist: bool, pub managed: bool, pub mentionable: bool, pub name: String, pub permissions: Permissions, pub position: i64, }
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
id: RoleId
The Id of the role. Can be used to calculate the role's creation date.
colour: Colour
The colour of the role. This is an ergonomic representation of the inner value.
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 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: i64
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
.
Methods
impl Role
[src]
impl Role
pub fn delete(&self) -> Result<()>
[src]
pub fn delete(&self) -> Result<()>
Deletes the role.
Note Requires the Manage Roles permission.
pub fn edit<F: FnOnce(EditRole) -> EditRole>(&self, f: F) -> Result<Role>
[src]
pub fn edit<F: FnOnce(EditRole) -> EditRole>(&self, f: F) -> Result<Role>
Edits a Role
, optionally setting its new fields.
Requires the Manage Roles permission.
Examples
Make a role hoisted:
// assuming a `role` has already been bound role.edit(|r| r.hoist(true));
pub fn find_guild(&self) -> Result<GuildId>
[src]
pub fn find_guild(&self) -> Result<GuildId>
Searches the cache for the guild that owns the role.
Errors
Returns a ModelError::GuildNotFound
if a guild is not in the cache
that contains the role.
pub fn has_permission(&self, permission: Permissions) -> bool
[src]
pub fn has_permission(&self, permission: Permissions) -> bool
Check that the role has the given permission.
pub fn has_permissions(&self, permissions: Permissions, precise: bool) -> bool
[src]
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
impl Clone for Role
[src]
impl Clone for Role
fn clone(&self) -> Role
[src]
fn clone(&self) -> Role
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for Role
[src]
impl Debug for Role
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Display for Role
[src]
impl Display for Role
fn fmt(&self, f: &mut Formatter) -> FmtResult
[src]
fn fmt(&self, f: &mut Formatter) -> FmtResult
Format a mention for the role, pinging its members.
impl Eq for Role
[src]
impl Eq for Role
impl Ord for Role
[src]
impl Ord for Role
fn cmp(&self, other: &Role) -> Ordering
[src]
fn cmp(&self, other: &Role) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl PartialEq for Role
[src]
impl PartialEq for Role
fn eq(&self, other: &Role) -> bool
[src]
fn eq(&self, other: &Role) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl PartialOrd for Role
[src]
impl PartialOrd for Role
fn partial_cmp(&self, other: &Role) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &Role) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
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
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
fn gt(&self, other: &Rhs) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
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
impl From<Role> for RoleId
[src]
impl From<Role> for RoleId
impl<'a> From<&'a Role> for RoleId
[src]
impl<'a> From<&'a Role> for RoleId
impl Mentionable for Role
[src]
impl Mentionable for Role
fn mention(&self) -> String
[src]
fn mention(&self) -> String
Creates a mentionable string, that will be able to notify and/or create a link to the item. Read more
impl FromStr for Role
[src]
impl FromStr for Role