KSJaay
KSJaay

Reputation: 59

Checking array list for guild ID

So I've been creating a bot and I want some of the commands only to be available in specific servers (Servers of my friends) but I'm coming across a problem where I can't put more than 1 Server ID to make a list of servers which are allowed to use the commands. I've tried creating an array list but it didnt work and kept on saying that my server ID couldn't be found. Below you can see the code which I'm using to verify if the server is allowed to use the command or not.

    if(cmd.conf.friendOnly&& message.guild.id !== client.friendsList.friends.id){
        return message.channel.send(notFriendError);
    }

If I have my friendOnly premission set to true the bot still sends notFriendError message but if I only have 1 server ID it sends the command.

Upvotes: 0

Views: 166

Answers (1)

Nikhil
Nikhil

Reputation: 6641

message.guild.id !== client.friendsList.friends.id

If friendsList is an array, then you can't access it like you did, and can't compare it with a primitive type such as string, number, boolean etc.

To check if a value is present in an array, you can use any of the following methods based on your requirement:

Upvotes: 2

Related Questions