pub struct CommandManager<'a, B: Backend> { /* private fields */ }Expand description
The bot’s global application commands. Returned by Context::commands.
The cache does not keep commands, so the djs-model ApplicationCommand
is returned. Build the bodies with djs_rs::builders (SlashCommandBuilder, …).
discord.js counterpart: ApplicationCommandManager (client.application.commands).
Implementations§
Source§impl<'a, B: Backend> CommandManager<'a, B>
impl<'a, B: Backend> CommandManager<'a, B>
Sourcepub const fn application_id(self) -> ApplicationId
pub const fn application_id(self) -> ApplicationId
The application these commands belong to.
discord.js counterpart: ClientApplication#id, whose commands ApplicationCommandManager holds.
Sourcepub fn fetch(
self,
command_id: CommandId,
) -> Fetch<ApplicationCommand, impl Future<Output = Result<ApplicationCommand, Error>> + Send + 'a>
pub fn fetch( self, command_id: CommandId, ) -> Fetch<ApplicationCommand, impl Future<Output = Result<ApplicationCommand, Error>> + Send + 'a>
A global command (Get Global Application Command).
discord.js counterpart: ApplicationCommandManager#fetch(id).
§Errors
Returns the REST error if the request failed.
Sourcepub async fn list(
self,
query: &GetApplicationCommands,
) -> Result<Collection<CommandId, ApplicationCommand>, Error>
pub async fn list( self, query: &GetApplicationCommands, ) -> Result<Collection<CommandId, ApplicationCommand>, Error>
Every global command (Get Global Application Commands).
discord.js counterpart: ApplicationCommandManager#fetch().
§Errors
Returns the REST error if the request failed.
Sourcepub async fn create(
self,
body: &CreateApplicationCommand,
) -> Result<ApplicationCommand, Error>
pub async fn create( self, body: &CreateApplicationCommand, ) -> Result<ApplicationCommand, Error>
Creates a global command, or replaces the one with the same name and type (Create Global Application Command).
discord.js counterpart: ApplicationCommandManager#create.
§Errors
Returns the REST error if the request failed (at most 200 creations a day).
Sourcepub async fn edit(
self,
command_id: CommandId,
body: &EditApplicationCommand,
) -> Result<ApplicationCommand, Error>
pub async fn edit( self, command_id: CommandId, body: &EditApplicationCommand, ) -> Result<ApplicationCommand, Error>
Edits a global command (Edit Global Application Command).
discord.js counterpart: ApplicationCommandManager#edit.
§Errors
Returns the REST error if the request failed.
Sourcepub async fn delete(self, command_id: CommandId) -> Result<(), Error>
pub async fn delete(self, command_id: CommandId) -> Result<(), Error>
Deletes a global command (Delete Global Application Command).
discord.js counterpart: ApplicationCommandManager#delete.
§Errors
Returns the REST error if the request failed.
Sourcepub async fn set(
self,
commands: &[CreateApplicationCommand],
) -> Result<Collection<CommandId, ApplicationCommand>, Error>
pub async fn set( self, commands: &[CreateApplicationCommand], ) -> Result<Collection<CommandId, ApplicationCommand>, Error>
Replaces every global command with commands (Bulk Overwrite Global Application
Commands); an empty slice
deletes them all. Commands left unchanged keep their ID.
discord.js counterpart: ApplicationCommandManager#set.
§Errors
Returns the REST error if the request failed.
Trait Implementations§
Source§impl<B: Backend> Clone for CommandManager<'_, B>
impl<B: Backend> Clone for CommandManager<'_, B>
impl<B: Backend> Copy for CommandManager<'_, B>
Auto Trait Implementations§
impl<'a, B> !RefUnwindSafe for CommandManager<'a, B>
impl<'a, B> !UnwindSafe for CommandManager<'a, B>
impl<'a, B> Freeze for CommandManager<'a, B>
impl<'a, B> Send for CommandManager<'a, B>
impl<'a, B> Sync for CommandManager<'a, B>
impl<'a, B> Unpin for CommandManager<'a, B>
impl<'a, B> UnsafeUnpin for CommandManager<'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