While using discord.js version 12+, I encountered an error when trying to edit an embed sent by the bot. The error message displayed is as follows:
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)
Here is my code for 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'
}