bot.on('message', async message => {
if(message.content.includes('stuff')) {
message.channel.send("*stuff*");
}
}
因此,如果有人在我的服务器上说了些有关东西的内容,则该机器人将无限地向与“重复。”我真的不知道为什么会这样。
正如其他评论者所提到的,您正在创建一个无限循环,因为您也在检查自己的机器人消息,该消息发送了您要检查的相同消息。忽略机器人客户端或一般所有机器人都可以:
bot.on('message', async message => {
// To ignore your own client:
if (message.author.id === bot.user.id) {
return;
}
// To ignore all bots (including your own):
if (message.author.bot) {
return;
}
if(message.content.includes('stuff')) {
message.channel.send("*stuff*");
}
}