In your code, you try to delete the same message twice.
First, in message.delete();
, and next in
message.channel.send(uptimeEmbed).then(message.delete({ timeout: 5000 })).catch(console.error)
For context, error code 10008 in the Discord API means that the message could not be found, which makes sense in the current situation.
In order to fix this, assuming that the second message.delete is trying to delete the uptimeEmbed message sent by the bot, you can do this:
module.exports.run = async (bot, message, args) => {
let channel = message.channel;
message.delete();
let totalSeconds = (bot.uptime / 1000);
totalSeconds %= 86400;
let hours = Math.floor(totalSeconds / 3600);
totalSeconds %= 3600;
let minutes = Math.floor(totalSeconds / 60);
let uptimeEmbed = new Discord.MessageEmbed()
.setDescription(`${bot.user.username} Bot Uptime`)
.setColor("#e56b00")
.addField("Hours", hours)
.addField("Minutes", minutes)
.setTimestamp()
.setFooter(`Lavet`)
channel.send(uptimeEmbed).then(msg => msg.delete({ timeout: 5000 })).catch(console.error);
}
Instead of attempting to delete the same message twice, this stores the channel in a variable, send the message to the channel, and then deletes its own message.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…