Discord.js我不知道该如何创建随机答案

时间:2020-08-01 22:51:31

标签: javascript node.js discord.js

我是编程的新手,我想知道如何在编写程序时创建机器人!Random回答了我在想,两分钟后他回答了Hello,Hi,Welcome之间的随机响应。 谢谢大家 我不需要完整的代码,但可能需要一些建议

1 个答案:

答案 0 :(得分:0)

// Creating an array with answers.
const Answers = ["RandomAnswer1", "RandomAnswer2", "RandomAnswer3", "RandomAnswer4"];

// Picking a random answer every 1 second and logging it.
setInterval(() => {
    console.log(Answers[Math.floor(Math.random() * Answers.length)]);
}, 1000);