我正在使用discord.js v12 +,我正在尝试编辑由机器人发送的嵌入内容,但出现此错误:
Uncaught Promise Error:
DiscordAPIError: Cannot edit a message authored by another user
at RequestHandler.execute (c:\Users\Kazzu\Desktop\ImmortusMC\node_modules\discord.js\src\rest\RequestHandler.js:170:25)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
这是我的 ping.js 代码:
const { MessageEmbed } = require('discord.js')
module.exports = {
run: async(client, message, args) => {
const msg = new MessageEmbed()
.setTitle("Pong!")
.setColor(0xE67E22)
.setTimestamp()
.setDescription(`API:\nWeb Socket:`);
message.channel.send(msg)
.then(m =>m.edit(`API: ${m.createdTimestamp - message.createdTimestamp}ms.\nWeb Socket: ${Math.round(client.ws.ping)}ms.`))
message.edit(msg);
message.delete()
},
aliases: [],
description: 'Test API Latency'
}
答案 0 :(得分:0)
由于message.edit(msg);
,您正在收到错误消息,因为您正在尝试编辑触发命令的消息。
您需要更改嵌入的说明,然后使用更新后的嵌入编辑发送的邮件。
const { MessageEmbed } = require('discord.js')
module.exports = {
run: async (client, message, args) => {
const msg = new MessageEmbed()
.setTitle("Pong!")
.setColor(0xE67E22)
.setTimestamp()
.setDescription(`API:\nWeb Socket:`);
message.channel.send(msg)
.then(m => {
msg.setDescription(`API: ${m.createdTimestamp - message.createdTimestamp}ms.\nWeb Socket: ${Math.round(client.ws.ping)}ms.`)
m.edit(msg)
})
message.delete()
},
aliases: [],
description: 'Test API Latency'
}