Reputation: 95
I'm trying to "moderate" a channel, in this one should only be able to send certain commands, and when they send a command or message different from the one allowed, then I would send a message warning about it. The logic of moderation I have with the conditions, but my problem is that I can not get the messages that are sent on that channel (of anyone who writes on that specific channel)
When executing the code it does not show me anything in the console, which means that it is not recognizing the messages that they send in that channel :(
Code:
client.on("message", (message) => {
if (message.author.tag === "NAME#1234") {
if (message.content.startsWith(prefix + "on")) {
console.log(message.channel.id)
if (message.channel.id == "361344824500289538") {
//If the channel where they send the message has the id that I have set, then show me the messages that are sent
console.log(message.content)
} else {
console.log(message.content)
}
}
}
});
Upvotes: 1
Views: 83
Reputation: 144
Let’s say you want to have a command only to be used in one channel (this could be /meme for a channel called “memes”). If the command is used elsewhere the bot will say “Command Not Allowed Here!”
Here Is The Code:
client.on("message", message => {
if (message.content.startsWith('/meme') {
if (message.channels.find(c => c.name ===! 'memes') {
message.reply("Command Not Allowed Here!")
} else {rest of meme command script}
}
}
Upvotes: 1