Brett
Brett

Reputation: 7

Discord.js Bot Command that says a sentence from a random list of premade ones

So basically, I'm trying to make a certain command for my bot, and I was going to see if any of you could help write something up. I want to make a command where a user types the command and then the bot will randomly choose from a list of prewritten sentences. I'm trying to make a fact command where when you do !fact it responds with a random fact.

Note: This would be for my command handler.

Thanks if any of you can help!

Upvotes: 0

Views: 8692

Answers (1)

Gilles Heinesch
Gilles Heinesch

Reputation: 2980

var facts = ["Your facts", "...", "..."];
var fact = Math.floor(Math.random() * facts.length);
message.channel.send(facts[fact]);

Here's a command that will do this as you described it in your question!

Best regards, Monkeyyy11

Upvotes: 1

Related Questions