serenity
serenity copied to clipboard
How to chain commands?
I am trying to set up a bot that contains for instance 3 commands : action1, action2 and action3.
I want to setup a global command called all_actions that would call all three commands above.
Is there a way to do this through ACTION1_COMMAND, ... ? I search everywhere, tried to read serenity source code but cannot find the way to do it.
There is no formal method of telling the framework to call another command, but you are free to call the command's function to execute it. For example:
#[command]
async fn foo(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
// ...
Ok(())
}
#[command]
async fn bar(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
// ...
foo(ctx, msg, args).await?;
Ok(())
}
This issue can be closed I believe