pub struct EditRole<'a> { /* private fields */ }
Expand description
A builder to create or edit a Role
for use via a number of model methods.
These are:
PartialGuild::create_role
PartialGuild::edit_role
Guild::create_role
Guild::edit_role
GuildId::create_role
GuildId::edit_role
Role::edit
Defaults are provided for each parameter on role creation.
§Examples
Create a hoisted, mentionable role named "a test role"
:
// assuming a `guild_id` has been bound
let builder = EditRole::new().name("a test role").hoist(true).mentionable(true);
let role = guild_id.create_role(&http, builder).await?;
Implementations§
Source§impl<'a> EditRole<'a>
impl<'a> EditRole<'a>
Sourcepub fn new() -> Self
pub fn new() -> Self
Equivalent to Self::default
.
Sourcepub fn hoist(self, hoist: bool) -> Self
pub fn hoist(self, hoist: bool) -> Self
Whether or not to hoist the role above lower-positioned roles in the user list.
Sourcepub fn mentionable(self, mentionable: bool) -> Self
pub fn mentionable(self, mentionable: bool) -> Self
Whether or not to make the role mentionable, upon which users with that role will be notified.
Sourcepub fn permissions(self, permissions: Permissions) -> Self
pub fn permissions(self, permissions: Permissions) -> Self
Set the role’s permissions.
Sourcepub fn position(self, position: u16) -> Self
pub fn position(self, position: u16) -> Self
Set the role’s position in the role list. This correlates to the role’s position in the user list.
Sourcepub fn unicode_emoji(self, unicode_emoji: Option<String>) -> Self
pub fn unicode_emoji(self, unicode_emoji: Option<String>) -> Self
Set the role icon to a unicode emoji.
Sourcepub fn icon(self, icon: Option<&CreateAttachment>) -> Self
pub fn icon(self, icon: Option<&CreateAttachment>) -> Self
Set the role icon to a custom image.
Sourcepub fn audit_log_reason(self, reason: &'a str) -> Self
pub fn audit_log_reason(self, reason: &'a str) -> Self
Sets the request’s audit log reason.
Trait Implementations§
Source§impl Builder for EditRole<'_>
impl Builder for EditRole<'_>
Source§fn execute<'life0, 'async_trait>(
self,
cache_http: impl 'async_trait + CacheHttp,
ctx: Self::Context<'life0>,
) -> Pin<Box<dyn Future<Output = Result<Self::Built>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn execute<'life0, 'async_trait>(
self,
cache_http: impl 'async_trait + CacheHttp,
ctx: Self::Context<'life0>,
) -> Pin<Box<dyn Future<Output = Result<Self::Built>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Edits the role.
Note: Requires the Manage Roles permission.
§Errors
If the cache
is enabled, returns a ModelError::InvalidPermissions
if the current user
lacks permission. Otherwise returns Error::Http
, as well as if invalid data is given.