Issue with Channel Restrictions
I’m having trouble limiting where my Discord bot’s slash commands can be used. I built a bot that has two main functions - a dice roller and a card display feature. Both use slash commands but I can’t seem to restrict them to only work in certain channels.
What I’ve Tried
I want these commands to only work in voice channel text rooms, but they’re showing up everywhere. Here’s what I attempted:
- Created a test server with just the bot
- Went to integration settings and disabled all channels
- Tried removing permissions for specific categories
- Bot still responds to commands in every channel
Current Setup
The server is pretty basic - no custom roles except what the bot made automatically. Even after turning off permissions in the integration panel, users can still trigger the commands anywhere.
Example Commands
// Dice rolling command
const rollCommand = {
name: 'roll',
description: 'Roll a dice',
execute(interaction) {
const result = Math.floor(Math.random() * 6) + 1;
interaction.reply(`You rolled: ${result}`);
}
};
// Card display command
const cardCommand = {
name: 'showcard',
description: 'Display a random card',
execute(interaction) {
const cards = ['ace', 'king', 'queen', 'jack'];
const randomCard = cards[Math.floor(Math.random() * cards.length)];
interaction.reply(`Your card: ${randomCard}`);
}
};
Why aren’t the Discord permission settings working to block these commands in restricted channels?
Those integration settings are confusing as hell - I know exactly what you’re dealing with. What you’re seeing is normal behavior. Those settings only control whether commands show up in autocomplete, not whether they actually work. Your commands will still run everywhere even if they don’t appear in suggestions. You need to add channel checks directly in your command code instead. Before your dice roll or card display runs, throw in something like if (interaction.channel.parentId !== 'your-voice-category-id') return interaction.reply('This command only works in voice channels');. You can also use interaction.channel.type to target specific channel types like voice text channels. I had to figure this out the hard way with my own moderation bot - Discord’s slash command permissions aren’t nearly as simple as the server settings make them look.
i had a similar issue! check if your bot has the right permissions in each channel. also, make sure your code is catching any permission errors from discord. sometimes it’s just a simple thing that gets missed.
Discord’s integration settings only control where slash commands show up in autocomplete - they don’t actually restrict where commands can run. Even if a command doesn’t appear in suggestions, users can still execute it from any channel once it’s registered globally. You’ll need to add channel validation directly in your command code. Just add a check at the start of your execute function to verify the channel type or ID before processing anything. Check if interaction.channel.type matches the voice channel types you want, or compare against your allowed channel IDs list. If it’s not a permitted channel, return early with an error message. This gives you full control over where commands actually work, regardless of what Discord’s UI shows.