My Discord bot is acting up. It’s not showing the new commands I added to the Event listener. It only displays old ones and two that aren’t even in my code anymore. I tried fixing it by reinviting the bot and turning off Slash commands for a day. I even added a test command, but no luck.
Here’s what my setup looks like:
public class BotHandler extends ListenerAdapter {
private final PlaySong playSong;
private final ShowPlaylist showPlaylist;
private final NextSong nextSong;
// ... other command objects ...
@Override
public void onSlashCommandInteraction(SlashCommandInteractionEvent event) {
String cmd = event.getName();
try {
switch (BotCommands.valueOf(cmd)) {
case playsong:
playSong.run(event);
break;
case nextsong:
nextSong.run(event);
break;
// ... other cases ...
}
} catch (NullPointerException e) {
log.error("Command execution failed: " + e.getMessage());
}
}
}
My CommandCreator class:
public class CommandCreator {
public List<CommandData> cmdList = new ArrayList<>();
public CommandCreator(PlaySong playSong, ShowPlaylist showPlaylist, NextSong nextSong /* ... other params ... */) {
cmdList.add(Commands.slash(playSong.name(), playSong.description()).addOptions(playSong.options()));
cmdList.add(Commands.slash(nextSong.name(), nextSong.description()));
// ... other commands ...
}
public void addNew(IBotCommand cmd) {
cmdList.add(Commands.slash(cmd.name(), cmd.description()).addOptions(cmd.options()));
}
}
Any ideas on why the bot isn’t picking up the new commands?