这个不和谐的机器人不断重复说它连接两个字符串!请帮忙!
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 + "!***")
}
答案 0 :(得分:0)
我找到了答案,每次机器人说话时都会触发,因为条件是相同的。
答案 1 :(得分:0)
正如您所知,消息事件会检查输入机器人公会的每条消息。为了避免它获取机器人的消息,您可以使用
if (msg.author.bot) return;
或类似的东西。 :)