[−][src]Struct serenity::model::guild::Role
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.
guild_id: GuildId
The Id of the Guild the Role is in.
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
.
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.
pub async fn edit<'_>(
&'_ self,
http: impl AsRef<Http>,
f: impl FnOnce(&mut EditRole) -> &mut EditRole
) -> Result<Role>
[src]
&'_ self,
http: impl AsRef<Http>,
f: impl FnOnce(&mut EditRole) -> &mut EditRole
) -> 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(|mut r| { r.hoist(true); r });
pub async fn find_guild<'_>(
&'_ self,
cache: impl AsRef<Cache>
) -> Result<GuildId>
[src]
&'_ self,
cache: impl AsRef<Cache>
) -> Result<GuildId>
replaced with the guild_id
field
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]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Display for Role
[src]
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]
impl From<Role> for RoleId
[src]
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]
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,
impl Mentionable for Role
[src]
impl Ord for Role
[src]
fn cmp(&self, other: &Role) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<Role> for Role
[src]
impl PartialOrd<Role> for Role
[src]
fn partial_cmp(&self, other: &Role) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
pub fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<F> FromStrAndCache for F where
F: FromStr,
[src]
F: FromStr,
type Err = <F as FromStr>::Err
pub fn from_str<'life0, 'async_trait, CRL>(
CRL,
&'life0 str
) -> Pin<Box<dyn Future<Output = Result<F, <F as FromStrAndCache>::Err>> + 'async_trait + Send>> where
'life0: 'async_trait,
CRL: AsRef<Cache> + Send + Sync + 'async_trait,
F: 'async_trait,
[src]
CRL,
&'life0 str
) -> Pin<Box<dyn Future<Output = Result<F, <F as FromStrAndCache>::Err>> + 'async_trait + Send>> where
'life0: 'async_trait,
CRL: AsRef<Cache> + Send + Sync + 'async_trait,
F: 'async_trait,
impl<T> Instrument for T
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
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]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
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]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,
pub fn vzip(self) -> V
impl<T> WithSubscriber for T
[src]
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
[src]
S: Into<Dispatch>,