Search code examples
discorddiscord.js

Discord.js slash command option


Im using WOKCommands, and want to make so you can only choice a voice channel. How can i do this?

options: [
        {
            name: 'channel',
            description: '🔊 Voice channel in which you want to play your activity',
            required: true,
            type: discord_js_1.default.Constants.ApplicationCommandOptionTypes.CHANNEL
            
        },
    ],

Solution

  • You can find the channel type id's in the official Discord documentation. With that given, you can specify specific channel types. In this example, channel_types: [2] = only voice channels.

    options: [
            {
                name: 'channel',
                description: '🔊 Voice channel in which you want to play your activity',
                required: true,
                type: discord_js_1.default.Constants.ApplicationCommandOptionTypes.CHANNEL
                channel_types: [2]
            },
        ],
    

    Hope This Helps