我目前正在制作一个不一致机器人,它记录以前的消息,然后在它们被删除/编辑时发送它们,我完成了所有的代码,但现在我的终端充满了错误,如下所示
at Function.normalizeField (C:\NewCrackHeadsBot\node_modules\discord.js\src\structures\MessageEmbed.js:425:23)
at C:\NewCrackHeadsBot\node_modules\discord.js\src\structures\MessageEmbed.js:445:14
at Array.map (<anonymous>)
at Function.normalizeFields (C:\NewCrackHeadsBot\node_modules\discord.js\src\structures\MessageEmbed.js:444:8)
at MessageEmbed.addFields (C:\NewCrackHeadsBot\node_modules\discord.js\src\structures\MessageEmbed.js:259:42)
at MessageEmbed.addField (C:\NewCrackHeadsBot\node_modules\discord.js\src\structures\MessageEmbed.js:250:17)
at module.exports (C:\NewCrackHeadsBot\Events\messageUpdate.js:8:2)
at Client.<anonymous> (C:\NewCrackHeadsBot\index.js:26:38)
at Client.emit (events.js:315:20)
at Object.module.exports [as MESSAGE_UPDATE] (C:\NewCrackHeadsBot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_UPDATE.js:14:12)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:8396) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:8396) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.这个错误淹没了我的终端,我不确定如何修复它。
这是我认为错误所在的代码,但我是一个初学者,所以我不确定是否需要任何其他代码,我可以展示
bot.on('messageUpdate', async(oldMessage,newMessage) => {
require('./Events/messageUpdate')(oldMessage,newMessage)
})
bot.on('messageDelete', async(message) =>{
require('./Events/messageDelete')(message)
})这是我的messageDelete文件中的代码
const {MessageEmbed} = require('discord.js')
module.exports=async(message)=>{
let embed = new MessageEmbed()
.setTitle(`New message deleted!`)
.setDescription(`**The user ${message.author} has deleted a message in <#${message.channel.id}>**`)
.addField(`content`,message.content,true)
.setColor(`RED`)
let channel = message.guild.channels.cache.find(ch=>ch.name==="bot-log")
if(!channel)return;
channel.send(embed)
}这是我的消息更新文件中的代码
const {MessageEmbed} = require(`discord.js`)
module.exports=async(oldMessage,newMessage)=>{
let embed = new MessageEmbed()
.setTitle(`New message edited`)
.setColor(`GREEN`)
.setDescription(`**The user ${oldMessage.author} has edited a message in <#${oldMessage.channel.id}>**`)
.addField(`Old Content`,oldMessage.content,true)
.addField(`New Content`,newMessage.content,true)
let channel = oldMessage.guild.channels.cache.find(ch=>ch.name==="bot-log")
if(!channel)return;
channel.send(embed)
}发布于 2020-05-14 08:00:53
不太确定,但我认为你需要等待,因为你有异步。
你的代码的其他部分也有错误吗?如果是这样,你可能也想把它放在问题上。(对不起,我还不能评论)
https://stackoverflow.com/questions/61786310
复制相似问题