Ian Liao
Ian Liao

Reputation: 13

Figuring out how to execute a command within a specific channel

The entire command works fine, when executed it shows what expected, however it can be executed in any channel when it should only be executable within a specific channel.

Ive tried basically everything that popped into my mind

const Discord = require('discord.js');
const guilds = require('../data/guilds.json');

module.exports.run = async (bot, message, args) => {
    if (!message.channel.id === guilds[message.guild.id].botChannelID) 
        return;
    var img
    if (args[0] == 'aea') {
        img = bot.utils.randomSelection([

I'm really stupid and probably made a dumb mistake so if anyone could please help me with this that would be great

Upvotes: 1

Views: 178

Answers (1)

Gilles Heinesch
Gilles Heinesch

Reputation: 2980

Try to replace:

if (!message.channel.id === guilds[message.guild.id].botChannelID)

To:

if (message.channel.id !== guilds[message.guild.id].botChannelID)

You used a „!“ in front of the message.channel.id although you should use it in your „===“.

Upvotes: 1

Related Questions