Limiting commands to certain channels

how to restrict bots to certain channels
rhythm limit to channel
how to disable commands in discord
discord js command in specific channel
how to block bots on discord
discord bot
how to make pokecord only work in one channel
how to bind groovy to a channel

I'm trying to build a bot with Commando, but I can't figure out a way to make the bot ignore commands (or better, delete and ignore) commands that are not sent in a defined channel. For example, if you don't send the command in #botchat the message gets deleted.

I know that I could deny the read permission to the bot in the other channels, but I have other modules running, and they require reading channels.

I could add a check at the beginning of every run function, but this won't affect the default commands.

Is there a way to write a check function that is run for every command before the actual run function begins? (Maybe using the Command class?)

I found out: you can use Inhibitors. Thanks to Gawdl3y#4269 in the Discord.js guild

//in main file
client.dispatcher.addInhibitor(msg => {
  return (msg.channel.name == "blockme"); //you return whether the command should be blocked
})

Restrict bots to certain channels – Discord, you have in a server, the more tedious it becomes. I know that I could deny the read permission to the bot in the other channels, but I have other modules running, and they require reading channels. I could add a check at the beginning of every run function, but this won't affect the default commands.

are your commands inside an IF/ELSE IF tree?

If so, what I would do is as the very begining of that before it even checks for a command (but under the part where it runs on every message on the server) have a variable declared to be the channel of the message. Something like;

var ChannelID = message.channel.id

or if you wan't to do it by name

var ChannelName = message.channel.name

then, when your command is dependent on the channel do something like this:

if(command === "ChannelDependentCommand"){
    if(ChannelID !== "AllowedChannel"){
        message.delete();
    }ELSE {
        //**whatever you want the command to do**
    };
};

I hope this helps? Obviously if you are doing things differently the syntax may need tweaking, and disclaimer, this hasn't been tested at all but it should explain the logic and thinking behind it.

Also, for future reference, if you provide some of your code that you have already got it makes it easier to give a relevant answer :)

How to Add a Bot to a Discord Channel on a PC or Mac: 11 Steps, How do I assign a discord bot to a channel? Limiting certain commands to certain channels [Discord.js] be done in a certain channel you can check if the id of the channel were the message was sent is the id

All you need to do is:

var Channel = message.channel.name

if (message.content === "command") {
    if(Channel != "Channel name here") {
        message.channel.send('Cannot use command here, ' + message.author);
    } else {
        // Insert command code here
    }
}

Hope I helped! Thanks.

Configuration, to join certain voice channels, take away its permission to "Connect." Limiting access to text and voice channels. To restrict FredBoat from receiving commands from a certain text channel, simply revoke the bot's permission to "Send Messages" in that channel. Fredboat will only accept commands from a channel it can write to.

Limit command to certain channels, At the moment, the only way to restrict bots to one channel only is to it so you can edit channels and turn off the use of bot commands on them. In order to make Rythm commands just available to specific roles you need to: 1- Make a text channel that can only be seen by users with the specific role. 2- Blacklist all the other text channels in the server with Rythm’s Blacklist function. To blacklist channels use the following command format: !settings blacklist #channel

How can I restrict a bot to a specific text channel? : discordapp, Hi! I need a way to make a command only work in channels created by another command. (The use case is I have one command to make a  There’s no built in way to do this, but if you restrict PokeCord’s Send Messages permission by default, then only give it rights to post in specific channels, it can only post level ups (and commands) in those channels. Bugs. If you thought designing a robust, highly accurate pokemon game inside a Discord API sounds difficult, you’re right.

Locking the Bot to Specific Channels – Groovy Support, For example, I want people in my server to only be able to use the bots commands in one channel. I turned off "read messages" for the bot on all the channels I  Posting permissions can be set for any channel, except for channels that are shared with an external organization. Anyone on the workspace can manage a channel's setting. Enterprise Grid plan Posting permissions can be set for any channel, except for channels that are shared with an external organization. By default, anyone can manage a channel

Comments
  • I know how to do that in Discord.js, but I wanted to know how to deal with it using Commando... In Commando once the commands are loaded the run automatically
  • Ah, sorry, I missed the Commando bit, I am not sure what that is. Sorry!
  • Don't worry, it's not a problem! 😁