Improve command registration

This commit is contained in:
Tom 2022-08-18 21:33:21 +02:00
parent d54b600391
commit 8ffea41db0

View file

@ -38,6 +38,7 @@ async fn register(
ctx: Context<'_>,
#[flag] global: bool,
#[flag] purge: bool,
#[flag] not: bool,
#[rest] rest: String,
) -> Result<(), Error> {
// poise::builtins::register_application_commands(ctx, global).await?;
@ -47,8 +48,8 @@ async fn register(
ctx.say(format!("Commands: {}", commands.len())).await?;
let mut command_count: u8 = 0;
for command in commands {
command_count += 1;
if rest.eq_ignore_ascii_case("all") || rest.contains(&command.name) {
if rest.eq_ignore_ascii_case("all") || (rest.contains(&command.name) ^ not) {
command_count += 1;
if let Some(slash_command) = command.create_as_slash_command() {
commands_builder.add_application_command(slash_command);
}