How to have a trigger only in a specific channel

I have come up with

if (message) {
if (message.channel.id === 'channel ID') return;
message.react('676180589895876611').then(() => message.react('676180565434695747'));
}

it’s doing the opposite of what I whant it to do. anyone help? and it wont reply at all

btw its a suggustinon thingy

discord.js v11 thats what im using

Take away the return.

I think you should also always use braces. It helps you be aware of what statements belong to what conditionals.

yeah, i found a fix, its

if (message.channel.id != '691339333894144121') return;
message.react('676180565434695747').then(() => message.react('676180589895876611'));
  message.author.send('Thanks for the suggestion!')
}
});

A better way to write it would be

if (message.channel.id === "691339333894144121") {
    message.react("…").then(() => {
        message.react("…").then(() => {
            message.author.send("…");
        });
    });
}

I noticed you used a triple equals sign in your first snippet but a single inequality operator in your second snippet. Double up on the equals sign in cases like that (e.g., name !== "Jeff").

1 Like

nah its fine, can you help out at Is there a way to convert discord.js v11 to v12?

Do something like this:

if (message) {
	if (!message.channel.id === 'channel ID') return;
	message.react('676180589895876611').then(() => message.react('676180565434695747'));
}

The ! is the bang operator. it converts the input from true to false and false to true