Skip to main content

Command

Trait Command 

Source
pub trait Command:
    Send
    + Sync
    + 'static {
    // Required methods
    fn name(&self) -> &str;
    fn execute<'life0, 'life1, 'async_trait>(
        &'life0 self,
        ctx: &'life1 MessageContext<'_>,
    ) -> Pin<Box<dyn Future<Output = Result<CommandAction>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn description(&self) -> Option<&str> { ... }
    fn args(&self) -> Vec<Arg<'_>> { ... }
    fn priority(&self) -> u32 { ... }
    fn alias(&self) -> Vec<&str> { ... }
    fn permission(&self) -> Permission { ... }
}
Expand description

命令行为接口。

Required Methods§

Source

fn name(&self) -> &str

返回命令名称。

Source

fn execute<'life0, 'life1, 'async_trait>( &'life0 self, ctx: &'life1 MessageContext<'_>, ) -> Pin<Box<dyn Future<Output = Result<CommandAction>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

执行命令。

Provided Methods§

Source

fn description(&self) -> Option<&str>

返回命令描述。

Source

fn args(&self) -> Vec<Arg<'_>>

返回命令参数列表。

Source

fn priority(&self) -> u32

返回命令优先级,默认值为 500

Source

fn alias(&self) -> Vec<&str>

返回命令别名列表。

Source

fn permission(&self) -> Permission

返回命令权限,默认为 Permission::All

Trait Implementations§

Source§

impl PartialEq for dyn Command

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Implementors§