pub struct RoleManager<'a, B: Backend> { /* private fields */ }Expand description
The roles of one guild. Returned by Context::roles.
discord.js counterpart: RoleManager (guild.roles).
Implementations§
Source§impl<'a, B: Backend> RoleManager<'a, B>
impl<'a, B: Backend> RoleManager<'a, B>
Sourcepub const fn guild_id(self) -> GuildId
pub const fn guild_id(self) -> GuildId
The guild these roles belong to.
discord.js counterpart: RoleManager#guild.
Sourcepub fn cache(self) -> Option<GuildView<'a, RoleId, Role, B>>
pub fn cache(self) -> Option<GuildView<'a, RoleId, Role, B>>
The cached roles of the guild, if the client has a cache.
discord.js counterpart: RoleManager#cache.
Sourcepub fn fetch(
self,
role_id: RoleId,
) -> Fetch<Arc<Role>, impl Future<Output = Result<Arc<Role>, Error>> + Send + 'a>
pub fn fetch( self, role_id: RoleId, ) -> Fetch<Arc<Role>, impl Future<Output = Result<Arc<Role>, Error>> + Send + 'a>
A role: the cached one, or Get Guild Role, whose result is cached.
discord.js counterpart: RoleManager#fetch(id).
§Errors
Returns the REST error if Discord was asked and the request failed.
Sourcepub async fn list(self) -> Result<Collection<RoleId, Arc<Role>>, Error>
pub async fn list(self) -> Result<Collection<RoleId, Arc<Role>>, Error>
Every role of the guild, in Discord’s order (Get Guild Roles); the roles are cached.
discord.js counterpart: RoleManager#fetch().
§Errors
Returns the REST error if the request failed.
Sourcepub async fn create(
self,
body: &CreateGuildRole,
reason: Option<&str>,
) -> Result<Arc<Role>, Error>
pub async fn create( self, body: &CreateGuildRole, reason: Option<&str>, ) -> Result<Arc<Role>, Error>
Creates a role (Create Guild Role); it is cached.
discord.js counterpart: RoleManager#create.
§Errors
Returns the REST error if the request failed (it needs MANAGE_ROLES).
Sourcepub async fn edit(
self,
role_id: RoleId,
body: &ModifyGuildRole,
reason: Option<&str>,
) -> Result<Arc<Role>, Error>
pub async fn edit( self, role_id: RoleId, body: &ModifyGuildRole, reason: Option<&str>, ) -> Result<Arc<Role>, Error>
Edits a role (Modify Guild Role); the result is cached.
discord.js counterpart: RoleManager#edit / Role#edit.
§Errors
Returns the REST error if the request failed (the role must be below the bot’s highest role).
Sourcepub async fn delete(
self,
role_id: RoleId,
reason: Option<&str>,
) -> Result<(), Error>
pub async fn delete( self, role_id: RoleId, reason: Option<&str>, ) -> Result<(), Error>
Deletes a role (Delete Guild Role). The cache is
updated by the GUILD_ROLE_DELETE event that follows (D-236).
discord.js counterpart: RoleManager#delete / Role#delete.
§Errors
Returns the REST error if the request failed.
Sourcepub async fn set_positions(
self,
positions: &[ModifyGuildRolePosition],
reason: Option<&str>,
) -> Result<Collection<RoleId, Arc<Role>>, Error>
pub async fn set_positions( self, positions: &[ModifyGuildRolePosition], reason: Option<&str>, ) -> Result<Collection<RoleId, Arc<Role>>, Error>
Moves roles (Modify Guild Role Positions), returning every role of the guild in Discord’s order; the roles are cached.
discord.js counterpart: RoleManager#setPositions.
§Errors
Returns the REST error if the request failed.
Trait Implementations§
Source§impl<B: Backend> Clone for RoleManager<'_, B>
impl<B: Backend> Clone for RoleManager<'_, B>
impl<B: Backend> Copy for RoleManager<'_, B>
Auto Trait Implementations§
impl<'a, B> !RefUnwindSafe for RoleManager<'a, B>
impl<'a, B> !UnwindSafe for RoleManager<'a, B>
impl<'a, B> Freeze for RoleManager<'a, B>
impl<'a, B> Send for RoleManager<'a, B>
impl<'a, B> Sync for RoleManager<'a, B>
impl<'a, B> Unpin for RoleManager<'a, B>
impl<'a, B> UnsafeUnpin for RoleManager<'a, B>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Classify for T
impl<T> Classify for T
type Classified = T
fn classify(self) -> T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Declassify for T
impl<T> Declassify for T
type Declassified = T
fn declassify(self) -> T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more