javascript - 机器人不断重复

标签 javascript node.js bots discord discord.js

这个不和谐的机器人不断重复它刚才所说的连接两个字符串!请帮忙!

const Discord = require('discord.js');
const client = new Discord.Client();
const prefix = "*";

client.on('message', (message) => {
    if (message.content == prefix + 'test') {
        message.channel.sendMessage("```User Bot is a way to get more users in your discord server. When you first invite the bot, it will create a channel called #invites. You can put your message in #invites by doing the command *message <message>. Doing this command will make the bot broadcast your message and your invite link so all people with the bot in there #invites channel will get the message.```");
    } else if (message.content == prefix + 'setup') {
        message.channel.sendMessage("```To setup User Bot, you must join the user bot discord listed here. https://discord.gg/amuzrvr, then in #bots type your message!");
    } else if (message.channel.guild.name == 'UserBot' && message.channel.name == 'bots') {
        channel(message);
    }

});

function channel(message) {
    message.channel.sendMessage("***A server! " + message.content + "!***")
}

最佳答案

我找到了一个答案,每次机器人说话时都会触发它,因为条件是相同的。

关于javascript - 机器人不断重复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49204248/

相关文章:

javascript - 如何在 android 上运行我的 node.js 项目?

javascript - 前端访问 MongoDb

Azure Bot 下载源代码按钮不起作用

javascript - 检索存储在存储在 JSON 中的数组中的字符串值仅返回字符串的第一个字符

javascript - 验证表单上的两个字段

javascript - 序列化多对多查询问题

javascript - Node.js 中使用 Javascript 的 Discord Bot - 如何从公会或 channel 获取所有用户?

javascript - 没有元素跳转的jQuery定位页脚

javascript - Jquery/JavaScript : How to append the data by column dynamically to each row in jquery?