I'm coding a discord bot. I want to it to pick up in a json file a random item from a list. That's my json file :
{
"emailPass": ["email1:pass1", "email2:pass2"],
"capture": "capture1"
}
Now I want it to send a private message to the author, with the "capture" item, and one of the "emailPass" items, randomly chosen. So that's my js code :
message.author.send(Math.floor(jsonFile.emailPass.lenght*Math.random()) + "\n" + jsonFile.capture);
The bot sends the message, but instead of the "emailPass" item, it displays "NaN". Does someone know how to fix that ? I think the error is from the random command, but I don't know exactly why...
Aucun commentaire:
Enregistrer un commentaire