serenity icon indicating copy to clipboard operation
serenity copied to clipboard

How to chain commands?

Open leirn opened this issue 3 years ago • 1 comments

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.

leirn avatar Mar 08 '22 20:03 leirn

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(())
}

arqunis avatar Mar 08 '22 23:03 arqunis

This issue can be closed I believe

kangalio avatar Sep 12 '22 08:09 kangalio