Reputation: 43
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?
Upvotes: 2
Views: 3533
Reputation: 977
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;
Upvotes: 1