Fix command registration
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Bea 2022-11-20 03:52:15 +01:00
parent 813107a2f9
commit fca7c2d26f
1 changed files with 19 additions and 3 deletions

View File

@ -39,6 +39,7 @@ public class SlashCommandsUtil
// for each command that we have already registered... // for each command that we have already registered...
for(Command currRegCmd : registeredCommands) for(Command currRegCmd : registeredCommands)
{ {
boolean found = false;
// iterate through all "recognized" commands // iterate through all "recognized" commands
for(CommandData cmdData : allCommands) for(CommandData cmdData : allCommands)
@ -47,13 +48,20 @@ public class SlashCommandsUtil
if(cmdData.getName().equals(currRegCmd.getName())) if(cmdData.getName().equals(currRegCmd.getName()))
{ {
// quit the loop since we found it. // quit the loop since we found it.
found = true;
break; break;
} }
} }
// if no match was found, we need to send an updated command list because // if no match was found, we need to send an updated command list because
// an old command was probably removed. // an old command was probably removed.
update = true; if(!found)
{
update = true;
// quit the loop since we only need to trigger this once.
break;
}
} }
// if an update is not already queued... // if an update is not already queued...
@ -62,6 +70,7 @@ public class SlashCommandsUtil
// for each "recognized" valid command // for each "recognized" valid command
for(CommandData currCmdData : allCommands) for(CommandData currCmdData : allCommands)
{ {
boolean found = false;
// iterate through all already registered commands. // iterate through all already registered commands.
for(Command cmd : registeredCommands) for(Command cmd : registeredCommands)
@ -70,16 +79,23 @@ public class SlashCommandsUtil
if(cmd.getName().equals(currCmdData.getName())) if(cmd.getName().equals(currCmdData.getName()))
{ {
// quit the loop since we found a match. // quit the loop since we found a match.
found = true;
break; break;
} }
} }
// if no match was found, we need to send an updated command list because // if no match was found, we need to send an updated command list because
// a new command was probably added. // a new command was probably added.
update = true; if(!found)
{
update = true;
// quit the loop since we only need to trigger this once.
break;
}
} }
} }
logger.log("Found " + registeredCommands.size() + " commands."); logger.log("Found " + registeredCommands.size() + " commands.");
if(update) if(update)