Home > Software design >  How can I put 2 discord ids inside a if(message.author.id !=) statement
How can I put 2 discord ids inside a if(message.author.id !=) statement

Time:02-15

Hello ive been trying to run this code and tried recoding it multiple times but when ever I try to put 2 ids inside of the if(message.author.id != ownerid) return message.channel.send("You don't have access to this command"); it only registers 1 of the ids heres my current code:

client.on('message', message => {
    if (message.content === prefix   'listservers') {
    if(message.author.id != ownerid && altid) return message.channel.send("You don't have access to this command");
//rest of the code

}})

CodePudding user response:

You've got a few different options. Here's how I'd do it, using an array and Array.includes():

const allowedUsers = ["user id 1", "user id 2"]

client.on('message', message => {
    if (message.content === prefix   'listservers') {
    if(!allowedUsers.includes(message.author.id)) return message.channel.send("You don't have access to this command");
//rest of the code

}})
  • Related