在 Slash-Command 中添加多个可能的选项

Add multiple possible options in a Slash-Command

我遇到了以下问题:

我正在尝试使用可以像这样输入的 JDA 实现一个 Discord Slash-Command:

/user @User

或者像这样:

/user 277048745458401282

但是您应该需要使用其中一个选项。

我目前有一个带有 USER 选项类型的 /user 斜杠命令,但我的问题是如何添加另一个选项到它,但你必须只选择 2 个选项之一。

这是我当前的代码:

List<CommandData> cmds = new ArrayList<CommandData>();

cmds.add(new CommandData("user", "Shows information about a specific Discord User.")
                    .addOption(OptionType.USER, "user", "The user you want to get the information from."));

jda.getGuildById(712313516542918717L).updateCommands().addCommands(cmds).queue();

感谢Minn在评论中的回答。

The OptionType user accepts user ids too. You can just paste the id in the client.

这对我有用:D