英文:
Discord4J - Slash Command only in a specific channel
问题
我目前正在使用Java中的Discord4J库开发一个Discord机器人,并且我想创建一个仅在特定频道可用且不在其他频道建议的斜杠命令。
目前,我已经成功实现了斜杠命令,并且它在机器人活动的所有频道中都显示出来。然而,我希望该命令仅在特定频道中建议,并且不会出现在其他频道中。
我已经像其他命令一样实现了该命令,使用了以下代码。然而,它在每个频道中都显示出来,而不仅仅是在特定频道中,这与预期不符:
List<CommandData> commandData = new ArrayList<>();
commandData.add(Commands.slash("poll", "创建一个投票")
.setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.ADMINISTRATOR))
.setGuildOnly(true));
非常感谢您的帮助!
英文:
I am currently working on a Discord bot using the Discord4J library in Java, and I would like to create a slash command that is only available in a specific channel and is not suggested in other channels.
Currently, I have successfully implemented the slash command and it shows up in all channels where the bot is active. However, I would like the command to be suggested only in a specific channel and not appear in other channels.
I have implemented the command as any other already with the following code. However, there it is displayed in every channel and not only in a specific one as expected:
`List<CommandData> commandData = new ArrayList<>();
commandData.add(Commands.slash("poll", "Erstelle eine Umfrage")
.setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.ADMINISTRATOR))
.setGuildOnly(true));`
Thanks in advance for your help!
答案1
得分: 1
你可以在服务器设置中禁用特定频道的命令。
不幸的是,你无法通过API进行编辑(这不是Discord4J的问题,而是Discord的限制)。
-
转到“集成”设置
-
选择要编辑的机器人
-
选择要禁用的命令
-
点击“添加频道”
-
选择要禁用的频道,然后有效地禁用该命令
英文:
You can disable the command from the server settings for certain channels.
Unfortunately, you can't edit this via the API (not a Discord4J issue, it's a Discord restriction).
- Go to the "integrations" settings
- Select the bot you want to edit
- Select the command you want to disable
- Click on "add channel"
- Select the channel(s) you want to disable, then effectively disable the command
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论