问题
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!
回答1:
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
来源:https://stackoverflow.com/questions/51584617/discord-js-bot-command-that-says-a-sentence-from-a-random-list-of-premade-ones