Refactor command registration logic
This commit is contained in:
parent
d33a479f5c
commit
29aa5e2463
@ -11,6 +11,9 @@ async fn on_ready(
|
|||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
println!("Connected to API as {}", ready.user.name);
|
println!("Connected to API as {}", ready.user.name);
|
||||||
|
|
||||||
|
let register_commands = std::env::var("REGISTER_CMDS").unwrap_or_else(|_| String::from("true")).parse::<bool>().unwrap_or(true);
|
||||||
|
|
||||||
|
if register_commands {
|
||||||
let builder = poise::builtins::create_application_commands(&framework.options().commands);
|
let builder = poise::builtins::create_application_commands(&framework.options().commands);
|
||||||
let commands = serenity::Command::set_global_application_commands(&ctx.http, |commands| {
|
let commands = serenity::Command::set_global_application_commands(&ctx.http, |commands| {
|
||||||
*commands = builder.clone();
|
*commands = builder.clone();
|
||||||
@ -25,6 +28,7 @@ async fn on_ready(
|
|||||||
},
|
},
|
||||||
Err(why) => println!("Error registering commands: {:?}", why)
|
Err(why) => println!("Error registering commands: {:?}", why)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user