pub struct CommandRegistry { /* private fields */ }Expand description
Registry of slash commands with dispatch by name or alias.
Implementations§
Source§impl CommandRegistry
impl CommandRegistry
Sourcepub fn with_builtins() -> Self
pub fn with_builtins() -> Self
Create a registry with all built-in commands pre-registered.
Sourcepub fn has_command(&self, name: &str) -> bool
pub fn has_command(&self, name: &str) -> bool
Check if a name (or alias) is registered as a built-in command.
Sourcepub fn register(&mut self, cmd: Box<dyn Command>)
pub fn register(&mut self, cmd: Box<dyn Command>)
Register a command. Overwrites any existing command with the same name.
Sourcepub fn execute(
&self,
input: &str,
ctx: &mut CommandContext,
) -> Option<CommandResult>
pub fn execute( &self, input: &str, ctx: &mut CommandContext, ) -> Option<CommandResult>
Dispatch a /-prefixed input string. Returns None if the name is unknown.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CommandRegistry
impl !RefUnwindSafe for CommandRegistry
impl Send for CommandRegistry
impl Sync for CommandRegistry
impl Unpin for CommandRegistry
impl UnsafeUnpin for CommandRegistry
impl !UnwindSafe for CommandRegistry
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
Mutably borrows from an owned value. Read more