I'm working on a "small" bot for fun and currently trying to create a blackjack command. The first half works fine, but the problem appears when I want to update the embed that was already posted by the bot. I keep getting an error:
UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot edit a message authored by another user
Here is part of the code:
const embd = new Discord.MessageEmbed()
.addFields(
{ name: 'Dealer cards: ' + botCards + ' + ?'},
{ name: 'Your cards: ' + userCards},
)
message.channel.send(embd).then(embdReact => {
embdReact.react('🟩');
embdReact.react('🟥');
const filter = (reaction, user) => {
return ['🟩','🟥'].includes(reaction.emoji.name) && user.id === message.author.id;
};
embdReact.awaitReactions(filter, { max: 1, time: 60000})
.then(collected => {
const reaction = collected.first();
if (reaction.emoji.name === '🟩'){
const newEmbd = new Discord.MessageEmbed()
.setTitle("Wow");
message.edit(newEmbd);
}
else {
message.reply('boo');
}
})
})
For testing I tried to change just the title, but in the perfect world a corresponding field would be updated. Ex: "Your cards:" field.
You're editing the wrong message :
The line :
message.edit(newEmbd);
should be :
embdReact.edit(newEmbd);
Hope this will help you to fix your issue !
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With