JDA Discord使用模式(斜杠命令)仅在调试模式下工作



我在JDA上使用第一次不协调模态(斜杠命令)。当我导出bot并打开它时,命令出现在/下(斜杠命令)它们不起作用,它显示"应用程序不响应">

JDA jda = JDABuilder.createDefault(token)
.setActivity(Activity.listening("TEST"))
.addEventListeners(new TestCommand())
.build().awaitReady();


Guild guild = jda.getGuildById("SERVER_ID");

if (guild != null){
guild.upsertCommand("test", "test command").queue();
}

TestCommand

@Override
public void onSlashCommandInteraction(@NotNull SlashCommandInteractionEvent event) {
if (event.getName().equals("test")){
TextInput test_name = TextInput.create("test-name", "Name", TextInputStyle.SHORT)
.setPlaceholder("test text")
.setMinLength(1)
.setRequired(true)
.build();
TextInput message = TextInput.create("test-message","Message", TextInputStyle.PARAGRAPH)
.setMinLength(10)
.setMaxLength(100)
.setRequired(true)
.setValue("test text.")
.build();
Modal modal = Modal.create("test-modal", "test text")
.addActionRows(ActionRow.of(name), ActionRow.of(message))
.build();
event.replyModal(modal).queue();

如果打开IntelliJ调试模式并启用bot而不导出,斜杠命令/正常工作

修改如下:

Modal modal = Modal.create("test-modal", "test text")
.addActionRows(ActionRow.of(test_name), ActionRow.of(message))
.build();

最新更新