Fix command registration
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Bea 2022-11-20 03:52:15 +01:00
parent 813107a2f9
commit fca7c2d26f

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.
if(!found)
{
update = true; 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,13 +79,20 @@ 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.
if(!found)
{
update = true; update = true;
// quit the loop since we only need to trigger this once.
break;
}
} }
} }