不和谐JDA机器人不响应斜杠命令-



我的Discord Bot不响应我的斜杠命令消息。希望你能帮助我。这是我的代码:主类

public class dcbot1 {
public static void main(String[] args) throws LoginException, InterruptedException {
JDA jda = JDABuilder.createDefault("TOKEN")
.setActivity(Activity.listening("Testen"))
.addEventListeners(new TestSlashCommand())
.build().awaitReady();
Guild guild = jda.getGuildById("GUILDID");
if (guild != null) {
guild.upsertCommand("test", "Testet den ersten SlashCommand").queue();
}
}
}

和Command类:

public class TestSlashCommand extends ListenerAdapter {
public void onSlashCommand(SlashCommandInteractionEvent event) {
if(event.getName().equals("test")) {
event.reply("Drücke die Knöpfe zum ausprobieren!").queue();
}
}
}

您没有正确地覆盖ListenerAdapter的方法。这是onSlashCommandInteraction而不是onSlashCommand

最新更新