0

This is the start of my command. I tried if(member === bot) return message.channel.send("You can't rob bots") But it didnt work, any help would be appreciated

client.on('message', async message => {
  if(message.content.startsWith("$$rob")) {
const member = message.mentions.members.first()
if(!member) return message.channel.send("You need to mention a user to rob them")
ronan
  • 11
  • 2

2 Answers2

0

member === bot is not the right way to check if a member is a bot. Remember, the === sign checks if the variables on the two sides of it are equal (in the case of triple equals, also checks if they are of the same type). bot is not a variable that you have declared, so this isnt how you do it.

Instead, check the user property of the member, which is the user behind the member object. Checking the documentation you'll find that the user has a boolean property called bot which tells if you if it is a bot or not. Thus the right way to check if the member is a bot is by:

if(member.user.bot === true) {
    //Do stuff
}

Or of course, simplified:

if(member.user.bot) {
    //Do stuff
}
Pritt Balagopal
  • 1,476
  • 2
  • 18
  • 32
-1

Try this:

if(member.user.bot) {
    return message.channel.send("You can't rob bots")
}
Rafik Farhad
  • 1,182
  • 2
  • 12
  • 21