我试图要求bot在执行命令时向控制台聊天发送报告,但我最终出现了意外错误。我认为错误将在主文件中,但错误来自node_modules
下面是
的代码(部分)var CommandName1 = message.content
var CommandName2 = CommandName1.replace(prefix, "")
let time = await date.toLocaleString('en-US');
var user = message.author.tag
var UserProfile = message.author.avatarURL()
var UserID = message.author.id
var MessageID = message.channel.id
let report = new Discord.MessageEmbed()
.setTitle("Report From Main Core File")
.setColor("DARK_BUT_NOT_BLACK")
.setDescription("command: `" + `${CommandName2}` + "` n" + "execution: `successful` nreport path: `Bot Core Assets/SCP bot assets/main.js` ntime: `" + `${time}` + "` n" + "user: `" + `${user}` + "`n" + "user profile: `" + `${UserProfile}` + "`n" + "user ID: " + `${UserID}n` + "message ID: " + `${MessageID}`)
clients.channels.cache.get("890166184979361792").send({embeds: [report]})
我得到的错误
C:Users1loveDropboxMy PC (DESKTOP-MEST1TS)DesktopBot Core AssetsSCP bot assetsnode_modulesdiscord.jssrcrestRequestHandler.js:298
throw new DiscordAPIError(data, res.status, request);
^
DiscordAPIError: Cannot send an empty message
at RequestHandler.execute (C:Users1loveDropboxMy PC (DESKTOP-MEST1TS)DesktopBot Core AssetsSCP bot assetsnode_modulesdiscord.jssrcrestRequestHandler.js:298:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (C:Users1loveDropboxMy PC (DESKTOP-MEST1TS)DesktopBot Core AssetsSCP bot assetsnode_modulesdiscord.jssrcrestRequestHandler.js:50:14)
at async TextChannel.send (C:Users1loveDropboxMy PC (DESKTOP-MEST1TS)DesktopBot Core AssetsSCP bot assetsnode_modulesdiscord.jssrcstructuresinterfacesTextBasedChannel.js:171:15) {
method: 'post',
code: 50006,
httpStatus: 400,
requestData: {
json: {
content: undefined,
tts: false,
nonce: undefined,
embeds: undefined,
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined
},
files: []
}
}
检查您的discord.js
版本。我怀疑,你还在使用V12,因为我复制了你的代码,它对我来说是完美的。
运行
检查discord.js
版本npm list discord.js
如果仍然显示v12,运行
npm install discord.js@latest
请确保安装了v16.6.0
或更高版本的节点。