1

When I try to put multiple id's into an if it only registers the first one.

if (message.author.id != '196568585202565121' || '110324497353052160') return message.reply("You don't have the perms")

It will only reply to the first id and not the second one. The second one will get the mssage you don't have the perms.

staen
  • 25
  • 2

4 Answers4

1
if (message.author.id != '196568585202565121' || '110324497353052160') return message.reply("You don't have the perms")

This states:
If the message author's ID is not 196568585202565121 or 110324497353052160.

What you want it to say is:
if the message author's ID is not 196568585202565121 or if the message author's ID is not 196568585202565121.

Change up your line to:

if (message.author.id !== '196568585202565121' || message.author.id !== '110324497353052160')

Also notice that the != was replaced with a double equal. !==. In JavaScript, != is not strict enough. We need to use !==

1

You have to make the comparison in both parts of the if like this:

if (message.author.id !== '196568585202565121' || message.author.id !== '110324497353052160') return message.reply("You don't have the perms")

You could also add the ids to an array and filter the array.

let arr = ['196568585202565121', '110324497353052160']

let filter = arr.filter ( e => e === message.author.id)

arr.length > 0 return message.reply("You don't have the perms")
Floro Varela
  • 69
  • 1
  • 8
1

You can use array with .includes() method.

if(!['196568585202565121','110324497353052160'].includes(message.author.id)) {
  // to the things...
}

Read more: Array.prototype.includes()

vovchisko
  • 2,049
  • 1
  • 22
  • 26
0

In order return message if non of the id's match, do this:

  if (message.author.id !== '196568585202565121' || message.author.id !== '110324497353052160') {
      return message.reply("You don't have the perms");
  }
Or Assayag
  • 5,662
  • 13
  • 57
  • 93