Kamyar Zolfkhani
Kamyar Zolfkhani

Reputation: 5

not able to mute someone in discord.js - node.js

I want to mute someone manually in discord.js by adding:

if(message.author == /*muted list*/){
message.delete();
return;
}

and I need to extract the list from a json file (and I did)

{
  "muted":[
    //someone's ID,
    //someone else's ID
    ]
}

I got the the IDs in a variable. and logged it into console to see if I did it correct console output:

[  some id , some else id ]

so I put the variable in the /*muted list*/ in the js file. but it did nothing. help pls

Upvotes: 0

Views: 52

Answers (2)

WOLF
WOLF

Reputation: 79

Try

if (<muted.json>.find(x => x.id == message.author.id)) {
    message.delete();
    return;
}

Upvotes: 0

Lofn
Lofn

Reputation: 940

If you got JSON converted into list you can simply check string from the list with .includes()

if (yourlist.includes(message.author.id)) {

}

Upvotes: 1

Related Questions