discord.js代码工作不正常

discord.js代码工作不正常,discord.js,Discord.js,我编写代码是为了在discord中代表机器人编写代码。但是,当我在主通道中写入,以便bot将我的消息发送到另一个通道时,我的bot会在我编写消息的地方写入,并开始发送垃圾邮件,添加自己的内容,尽管在代码中我指出的不是他,而是写这条消息的人 这就是代码的样子 bot.on('message',异步消息=>{ 如果(message.channel.id==“735573900251102244”){ 设csl1=message.channel.name.split(“-”[0]; 设csl2=m

我编写代码是为了在discord中代表机器人编写代码。但是,当我在主通道中写入,以便bot将我的消息发送到另一个通道时,我的bot会在我编写消息的地方写入,并开始发送垃圾邮件,添加自己的内容,尽管在代码中我指出的不是他,而是写这条消息的人

这就是代码的样子

bot.on('message',异步消息=>{
如果(message.channel.id==“735573900251102244”){
设csl1=message.channel.name.split(“-”[0];
设csl2=message.channel.name.split(“-”[1];
让logs=bot.guilds.cache.get(“61121239726491904”).channels.cache.get(“611215326566416416”);
如果(message.author.id==“546359252575322122”){
message.channel.send(message.content);
}否则{
message.channel.send(`+`${message.content}`);
}
回来
}
if(message.author.bot)返回;
if(message.channel.type==“dm”)返回;
设args=message.content.slice(prefix.length.trim().split(“”);
让help=args.shift().toLowerCase();
让cmd;
如果(!message.content.startsWith(prefix))返回;
if(bot.commands.has(help)){
cmd=bot.commands.get(帮助);
}否则{
cmd=bot.commands.get(bot.aliases.get(help));
}
if(cmd)cmd.run(bot、message、args);

});您必须将对message.author.bot的检查重新排序到seblor提到的函数开头

此外,
message.channel
指的是bot接收消息的通道。要将消息发送到其他频道,您必须执行以下操作:

// https://discord.js.org/#/docs/main/stable/class/ChannelManager?scrollTo=fetch
bot.channels.fetch(targetchannelid).then((chan) => {
    chan.send("blah blah blah");
});

您需要重新排序您的条件,在ID之前检查作者和频道类型问题是,当条件的顺序更改时,bot停止重新激活bot.on('message',async messageif您移动
if(message.author.bot)将
返回到bot.on回调的开头,它将阻止您的bot在自身或其他bot上触发。