嵌入消息循环不会停止

Embed message loop doesnt stop

如果我输入 pingtest,我的机器人会一遍又一遍地发送嵌入消息(无限循环)

if (message.content='pingtest') {
    message.channel.send({embed: {

            color: 000000,
            author: {
              name: client.user.username,
              icon_url: client.user.avatarURL
            },
            title: "A RAID HAS BEGUN (for the Dark Side)",
            description: "",
            fields: [{
                name: "------------------------------",
                value:"Write !raid to enter."
              }

            ],
            footer: {
              icon_url: client.user.avatarURL,
            }
          }
        });
}

问题: 在您的 if 语句中,您使用的是 assignment operator=.
解决方法:使用equality operator(即===)来比较message.content
说明:现在,您的代码是设置message.content而不是比较。这意味着无论 message.content 是什么,您都会收到 "pingtest." 的预期结果至于循环,我猜您在消息事件中允许来自其他机器人的消息.因此,当机器人看到自己的消息时,它会再次触发相同的错误代码,从而产生连锁反应。
修改后的代码:

if (message.author.bot) return; // bots will no longer trigger a command

if (message.content === 'pingtest') { // comparing message.content with ===
  // < your code for the 'pingtest' command >
}

您需要为

嵌入
if(message.content.startsWith('pingtest'))
   let embed = new Discord.Embed
       .setColor('color')
       .setTitle('title')
       .setAuthor(`${client.user.username}`)
       .setDescreption('Descreption')
       .addField('Field)
      message.channel.send(embed)