rez
rez

Reputation: 331

If command is being executed in wrong channel return

If the command was executed in wrong channel bot should detect it and return message.reply("wrong channel")

With code below, I want to make bots channel be the main channel for a bot to run its commands

Code:

if(!message.guild.channels.cache.find(channel => channel.name === "bots")) return message.reply("wrong channel")

Code is not working.

Upvotes: 0

Views: 236

Answers (1)

rez
rez

Reputation: 331

I managed to find an issue and fix it.

Old code:

if(!message.guild.channels.cache.find(channel => channel.name === "bots")) return message.reply("wrong channel")

New Code:

  var ChannelName = message.channel.name
  if(ChannelName !== "bots") return message.reply("wrong channel")

Hopefully this helps.

Upvotes: 1

Related Questions