[][src]Struct serenity::model::guild::Role

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,
    // some fields omitted
}

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

Implementations

impl Role[src]

pub fn delete<T>(&mut self, cache_and_http: T) -> Result<()> where
    T: AsRef<CacheRwLock> + AsRef<Http>, 
[src]

Deletes the role.

Note Requires the Manage Roles permission.

pub fn edit<F: FnOnce(&mut EditRole) -> &mut EditRole, T>(
    &self,
    cache_and_http: T,
    f: F
) -> Result<Role> where
    T: AsRef<CacheRwLock> + AsRef<Http>, 
[src]

Edits a Role, optionally setting its new fields.

Requires the Manage Roles permission.

Examples

Make a role hoisted:

This example is not tested
// assuming a `role` has already been bound
role.edit(|mut r| {
    r.hoist(true);

    r
});

pub fn find_guild(&self, cache: impl AsRef<CacheRwLock>) -> Result<GuildId>[src]

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]

Check that the role has the given permission.

pub fn has_permissions(&self, permissions: Permissions, precise: bool) -> bool[src]

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 Debug for Role[src]

impl<'de> Deserialize<'de> for Role[src]

impl Display for Role[src]

pub fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult[src]

Format a mention for the role, pinging its members.

impl Eq for Role[src]

impl<'a> From<&'a Role> for RoleId[src]

pub fn from(role: &Role) -> RoleId[src]

Gets the Id of a role.

impl From<Role> for RoleId[src]

pub fn from(role: Role) -> RoleId[src]

Gets the Id of a role.

impl FromStrAndCache for Role[src]

type Err = RoleParseError

impl Mentionable for Role[src]

impl Ord for Role[src]

impl PartialEq<Role> for Role[src]

impl PartialOrd<Role> for Role[src]

impl Serialize for Role[src]

Auto Trait Implementations

impl RefUnwindSafe for Role

impl Send for Role

impl Sync for Role

impl Unpin for Role

impl UnwindSafe for Role

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> CloneAny for T where
    T: Clone + Any
[src]

impl<T> DebugAny for T where
    T: Any + Debug
[src]

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

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

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> UnsafeAny for T where
    T: Any

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,