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.