Struct serenity::model::guild::Role

source ·
#[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.

Discord docs.

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

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

§tags: RoleTags

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

source

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

Available on crate feature model only.

Deletes the role.

Note Requires the Manage Roles permission.

§Errors

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

source

pub async fn edit( &mut self, http: impl AsRef<Http>, builder: EditRole<'_> ) -> Result<()>

Available on crate feature model only.

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.

source

pub fn has_permission(&self, permission: Permissions) -> bool

Available on crate feature model only.

Check that the role has the given permission.

source

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

Available on crate feature model only.

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

Available on crate features client and utils only.

Look up a Role by a string case-insensitively.

Requires the cache feature to be enabled.

The lookup strategy is as follows (in order):

  1. Lookup by ID
  2. Lookup by mention.
  3. Lookup by name (case-insensitive)
§

type Err = RoleParseError

The associated error which can be returned from parsing.
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,

Parses a string s as a command parameter of this type.
source§

impl Clone for Role

source§

fn clone(&self) -> Role

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Role

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for Role

source§

fn default() -> Role

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for Role

source§

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

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for Role

source§

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

Format a mention for the role, pinging its members.

source§

impl<'a> From<&'a Role> for RoleId

source§

fn from(role: &Role) -> RoleId

Gets the Id of a role.

source§

impl From<Role> for RoleId

source§

fn from(role: Role) -> RoleId

Gets the Id of a role.

source§

impl Mentionable for Role

source§

fn mention(&self) -> Mention

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

impl Ord for Role

source§

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

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for Role

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Role

source§

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

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

fn lt(&self, other: &Rhs) -> bool

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

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
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

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

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
source§

impl Serialize for Role

source§

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

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for Role

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§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneDebuggableStorage for T

source§

impl<T> CloneableStorage for T
where T: Any + Send + Sync + Clone,

§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

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

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

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

§

fn equivalent(&self, key: &K) -> bool

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

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

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

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
§

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

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DebuggableStorage for T
where T: Any + Send + Sync + Debug,

source§

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