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

#[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: i64, pub tags: RoleTags, }
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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct {{ .. }} syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
id: RoleId
Expand description

The Id of the role. Can be used to calculate the role’s creation date.

guild_id: GuildId
Expand description

The Id of the Guild the Role is in.

colour: Colour
Expand description

The colour of the role. This is an ergonomic representation of the inner value.

hoist: bool
Expand description

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 Self::position.

managed: bool
Expand description

Indicator of whether the role is managed by an integration service.

mentionable: bool
Expand description

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
Expand description

The name of the role.

permissions: Permissions
Expand description

A set of permissions that the role has been assigned.

See the permissions module for more information.

position: i64
Expand description

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.

tags: RoleTags
Expand description

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.

Implementations

impl Role[src]

pub async fn delete(&mut self, http: impl AsRef<Http>) -> Result<()>[src]

Deletes the role.

Note Requires the Manage Roles permission.

Errors

Returns Error::Http if the curent user lacks permission to delete this role.

pub async fn edit(
    &self,
    http: impl AsRef<Http>,
    f: impl FnOnce(&mut EditRole) -> &mut EditRole
) -> Result<Role>
[src]

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(|mut r| {
    r.hoist(true);

    r
});

Errors

Returns Error::Http if the current user does not have permission to Manage Roles.

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]

fn clone(&self) -> Role[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Role[src]

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

Formats the value using the given formatter. Read more

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

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
    __D: Deserializer<'de>, 
[src]

Deserialize this value from the given Serde deserializer. Read more

impl Display for Role[src]

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

Format a mention for the role, pinging its members.

impl From<&'_ Role> for Mention[src]

fn from(value: &Role) -> Self[src]

Performs the conversion.

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

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

Gets the Id of a role.

impl From<Role> for RoleId[src]

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

Gets the Id of a role.

impl FromStrAndCache for Role[src]

type Err = RoleParseError

fn from_str<'life0, 'async_trait, CRL>(
    cache: CRL,
    s: &'life0 str
) -> Pin<Box<dyn Future<Output = StdResult<Self, Self::Err>> + Send + 'async_trait>> where
    CRL: AsRef<Cache> + Send + Sync,
    CRL: 'async_trait,
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

impl Mentionable for Role[src]

fn mention(&self) -> Mention[src]

Creates a Mention that will be able to notify or create a link to the item. Read more

impl Ord for Role[src]

fn cmp(&self, other: &Role) -> Ordering[src]

This method returns an Ordering between self and other. Read more

#[must_use]
fn max(self, other: Self) -> Self
1.21.0[src]

Compares and returns the maximum of two values. Read more

#[must_use]
fn min(self, other: Self) -> Self
1.21.0[src]

Compares and returns the minimum of two values. Read more

#[must_use]
fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]

Restrict a value to a certain interval. Read more

impl PartialEq<Role> for Role[src]

fn eq(&self, other: &Role) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl PartialOrd<Role> for Role[src]

fn partial_cmp(&self, other: &Role) -> Option<Ordering>[src]

This method returns an ordering between self and other values if one exists. Read more

#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Serialize for Role[src]

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
    __S: Serializer
[src]

Serialize this value into the given Serde serializer. Read more

impl Eq 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]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn equivalent(&self, key: &K) -> bool[src]

Compare self to key and return true if they are equal.

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

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> Instrument for T[src]

fn instrument(self, span: Span) -> Instrumented<Self>[src]

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

fn in_current_span(self) -> Instrumented<Self>[src]

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

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

pub fn into(self) -> U[src]

Performs the conversion.

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.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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

pub default fn to_string(&self) -> String[src]

Converts the given value to a String. Read more

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

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

pub fn vzip(self) -> V

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