Discord4J - Slash Command only in a specific channel

345 Views Asked by At

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 = new ArrayList<>();

    commandData.add(Commands.slash("poll", "Erstelle eine Umfrage")
            .setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.ADMINISTRATOR))
            .setGuildOnly(true));`

Thanks in advance for your help!

1

There are 1 best solutions below

0
Azn9 On BEST ANSWER

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).

  1. Go to the "integrations" settings

"Integrations settings menu"

  1. Select the bot you want to edit

Select the bot

  1. Select the command you want to disable

Select the command you want to disable

  1. Click on "add channel"

Click on "add channel"

  1. Select the channel(s) you want to disable, then effectively disable the command

Select the channel(s) you want to disable, then effectively disable the command