[−][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.
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]
pub fn delete(&self, context: &Context) -> Result<()>
[src]
Deletes the role.
Note Requires the Manage Roles permission.
pub fn edit<F: FnOnce(&mut EditRole) -> &mut EditRole>(
&self,
context: &Context,
f: F
) -> Result<Role>
[src]
&self,
context: &Context,
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(|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 Mentionable for Role
[src]
impl FromStrAndCache for Role
[src]
type Err = RoleParseError
fn from_str(
cache: impl AsRef<CacheRwLock>,
s: &str
) -> StdResult<Self, Self::Err>
[src]
cache: impl AsRef<CacheRwLock>,
s: &str
) -> StdResult<Self, Self::Err>
impl Clone for Role
[src]
fn clone(&self) -> Role
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Ord for Role
[src]
fn cmp(&self, other: &Role) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
fn clamp(self, min: Self, max: Self) -> Self
[src]
clamp
)Restrict a value to a certain interval. Read more
impl From<Role> for RoleId
[src]
impl<'a> From<&'a Role> for RoleId
[src]
impl Eq 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]
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 PartialEq<Role> for Role
[src]
fn eq(&self, other: &Role) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl Debug for Role
[src]
impl Display for Role
[src]
fn fmt(&self, f: &mut Formatter) -> FmtResult
[src]
Format a mention for the role, pinging its members.
impl Serialize for Role
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<'de> Deserialize<'de> for Role
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
Auto Trait Implementations
Blanket Implementations
impl<F> FromStrAndCache for F where
F: FromStr,
[src]
F: FromStr,
type Err = <F as FromStr>::Err
fn from_str<impl AsRef>(
impl AsRef,
&str
) -> Result<F, <F as FromStrAndCache>::Err> where
impl AsRef: AsRef<CacheRwLock>,
[src]
impl AsRef
&str
) -> Result<F, <F as FromStrAndCache>::Err> where
impl AsRef
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
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.
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.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
fn equivalent(&self, key: &K) -> bool
[src]
impl<T> Erased for T
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
U: TryFrom<T>,
impl<T> DebugAny for T where
T: Any + Debug,
[src]
T: Any + Debug,
impl<T> CloneAny for T where
T: Clone + Any,
[src]
T: Clone + Any,
fn clone_any(&self) -> Box<dyn CloneAny + 'static>
[src]
fn clone_any_send(&self) -> Box<dyn CloneAny + 'static + Send> where
T: Send,
[src]
T: Send,
fn clone_any_sync(&self) -> Box<dyn CloneAny + 'static + Sync> where
T: Sync,
[src]
T: Sync,
fn clone_any_send_sync(&self) -> Box<dyn CloneAny + 'static + Sync + Send> where
T: Send + Sync,
[src]
T: Send + Sync,
impl<T> UnsafeAny for T where
T: Any,
T: Any,