start moving to @Components
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-09-06 21:44:55 +02:00
parent dcc4785edc
commit 5ad1d9e891
9 changed files with 66 additions and 96 deletions

View File

@@ -0,0 +1,54 @@
package wtf.beatrice.hidekobot.commands.slash;
import net.dv8tion.jda.api.entities.MessageEmbed;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
import net.dv8tion.jda.api.interactions.commands.build.Commands;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import wtf.beatrice.hidekobot.Cache;
import wtf.beatrice.hidekobot.commands.base.BotInfo;
import wtf.beatrice.hidekobot.objects.commands.SlashCommand;
import wtf.beatrice.hidekobot.objects.commands.SlashCommandImpl;
import java.util.LinkedList;
import java.util.List;
@Component
public class SlashBotInfoCommand extends SlashCommandImpl
{
private final BotInfo botInfo;
public SlashBotInfoCommand(@Autowired BotInfo botInfo)
{
this.botInfo = botInfo;
}
@Override
public CommandData getSlashCommandData()
{
return Commands.slash("botinfo", "Get info about the bot.");
}
@Override
public void runSlashCommand(@NotNull SlashCommandInteractionEvent event)
{
// 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());
}
// send the list
MessageEmbed embed = botInfo.generateEmbed(registeredCommandNames);
event.getHook().editOriginalEmbeds(embed).queue();
}
}