使用discord.js,我的机器人不断发送垃圾邮件

时间:2019-02-24 03:26:52

标签: discord.js

我一直在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);

谢谢!

1 个答案:

答案 0 :(得分:0)

尝试将其添加到client.on("message", ...)代码的顶部。

if (message.author.bot) return;

这可能会解决您的问题。