Make Command system more flexible
This commit is contained in:
parent
2719ab3301
commit
ff886efd78
6 changed files with 289 additions and 261 deletions
23
src/bot/command/hidden.rs
Normal file
23
src/bot/command/hidden.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
use async_trait::async_trait;
|
||||
|
||||
use crate::api::Message;
|
||||
|
||||
use super::{Command, Context};
|
||||
|
||||
pub struct Hidden<C>(pub C);
|
||||
|
||||
#[async_trait]
|
||||
impl<B, E, C> Command<B, E> for Hidden<C>
|
||||
where
|
||||
B: Send,
|
||||
C: Command<B, E> + Send + Sync,
|
||||
{
|
||||
fn description(&self, _ctx: &Context) -> Option<String> {
|
||||
// Default implementation, repeated here for emphasis.
|
||||
None
|
||||
}
|
||||
|
||||
async fn execute(&self, arg: &str, msg: &Message, ctx: &Context, bot: &mut B) -> Result<(), E> {
|
||||
self.0.execute(arg, msg, ctx, bot).await
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue