【发布时间】:2021-06-13 13:31:52
【问题描述】:
这就是我的 discord bot.js 的样子。
基本上,我认为当我输入“ten bot je fakt sračka”时,它会给出数组中的一个响应。
如果我输入“ahoj”,它会以几颗心做出回应。
而且当我输入“test”时,它应该回复“test”。
现在,当我运行机器人并输入三个消息中的任何一个时,如果只回复“测试”到“测试”。没有其他任何东西得到回应。我该怎么办?
const Discord = require("discord.js");
const client = new Discord.Client();
client.login("TOKEN");
client.on("ready", readyDiscord);
function readyDiscord() {
console.log("123");
}
const replies = ["Stop it!", "Bot lives matter! <:ragey:776017536973013003>", "no", "<:jakjestvbiblipsno:776002959665266709>"];
client.on("message", gotMessage);
function gotMessage(msg) {
console.log(msg.content);
if (msg.content === "ten bot je fakt sračka") {
const index = Math.floor(Math.random() * replies.length);
msg.channel.send(replies[index]);
}
}
function gotMessage(msg) {
console.log(msg.content);
if (msg.content === "ahoj") {
msg.reply("Ahoj <3<3<3");
}
}
function gotMessage(msg) {
console.log(msg.content);
if (msg.content === "test") {
msg.reply("test");
}
}
【问题讨论】:
标签: javascript node.js discord discord.js