Reputation: 5
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
Reputation: 79
Try
if (<muted.json>.find(x => x.id == message.author.id)) {
message.delete();
return;
}
Upvotes: 0
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