2
votes

I understand the client reads all messages as below

client.on("message", (message)=>{});

But could you limit the client to read messages only from a specific channel?

2

2 Answers

1
votes

Either you remove the bot from specific channels or you might have to check the ID or name of the channel and do / don't handle it accordingly. As you already figured out, you have a message object for every message event. You can see in the discord.js#message docs whats available to you

So you could easily check either the ID of the channel via if(message.channel.id), check the name via if(message.channel.name) or pretty much any other available property and handle it to your liking.

As an example for the test channel.

if (message.channel.name === 'test')
  return;
0
votes

apologies for the super late response. You can try this:

if (message.channel.id === "channel_id"){}