Make bot commands run in separate threads by default
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-11-22 21:59:58 +01:00
parent b681acdbca
commit 5f73c4069b
6 changed files with 95 additions and 106 deletions

View File

@@ -23,23 +23,20 @@ public class BotInfoCommand extends SlashCommandImpl
@Override
public void runSlashCommand(@NotNull SlashCommandInteractionEvent event)
{
// run in a thread because we might use thread-locking things
new Thread(() -> {
// defer reply because this might take a moment
event.deferReply().queue();
// defer reply because this might take a moment
event.deferReply().queue();
// get a list of slash commands
List<SlashCommand> registeredCommands = Cache.getSlashCommandListener().getRegisteredCommands();
LinkedList<String> registeredCommandNames = new LinkedList<>();
for(SlashCommand command : registeredCommands)
{
// node: adding slash so people realize that this is specific about slash commands.
registeredCommandNames.add("/" + command.getCommandName());
}
// get a list of slash commands
List<SlashCommand> registeredCommands = Cache.getSlashCommandListener().getRegisteredCommands();
LinkedList<String> registeredCommandNames = new LinkedList<>();
for(SlashCommand command : registeredCommands)
{
// node: adding slash so people realize that this is specific about slash commands.
registeredCommandNames.add("/" + command.getCommandName());
}
// send the list
MessageEmbed embed = BotInfo.generateEmbed(registeredCommandNames);
event.getHook().editOriginalEmbeds(embed).queue();
}).start();
// send the list
MessageEmbed embed = BotInfo.generateEmbed(registeredCommandNames);
event.getHook().editOriginalEmbeds(embed).queue();
}
}