在 discord.js 上工作,我的机器人一直在发送相同的垃圾邮件
Working on discord.js, and my bot keeps spamming the same message
我一直在 discord.js 开发一个机器人,并制作了一个基本的机器人。每当我尝试使用 'dadjoke' 或 'dadpun' 命令时,它只会一遍又一遍地发送占位符消息。有帮助吗?
代码在这里:
} else if (message.content.startsWith(`${prefix}joke`)) {
var repl = rand[Math.floor(Math.random()*rand.length)];
message.channel.send(repl);
} else if (message.content.startsWith(`${prefix}pun`)) {
var repl2 = pun[Math.floor(Math.random()*pun.length)];
message.channel.send(repl2);
提前致谢!
尝试将此添加到 client.on("message", ...)
代码的顶部。
if (message.author.bot) return;
这可能会解决您的问题。
我一直在 discord.js 开发一个机器人,并制作了一个基本的机器人。每当我尝试使用 'dadjoke' 或 'dadpun' 命令时,它只会一遍又一遍地发送占位符消息。有帮助吗?
代码在这里:
} else if (message.content.startsWith(`${prefix}joke`)) {
var repl = rand[Math.floor(Math.random()*rand.length)];
message.channel.send(repl);
} else if (message.content.startsWith(`${prefix}pun`)) {
var repl2 = pun[Math.floor(Math.random()*pun.length)];
message.channel.send(repl2);
提前致谢!
尝试将此添加到 client.on("message", ...)
代码的顶部。
if (message.author.bot) return;
这可能会解决您的问题。