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

╄→尐↘猪︶ㄣ 提交于 2021-01-07 02:57:00

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!