How can I delete all reactions?
How can i delete all reactions? I did cache the message, and channel.
18 Replies
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Error: No Error
<Message>.reactions.removeAll()
yes i tried it
but
TypeError: Cannot read properties of undefined (reading 'reactions')
So your message is
undefined
humm
why?
Show the code
if (interaction.commandName === "reactdel") {
await interaction.deferReply({ephemeral:true});
let id = interaction.options.getString('msgid');
id = parseInt(id,10);
let msgchannel = interaction.channel;
const delmsg = msgchannel.messages.cache.get(id);
await delmsg.reactions.removeAll();
await interaction.editReply('Delete all reaction of message.');
}
Not all messages are cached. You should use fetch.
await <TextBasedChannel>.messages.fetch(id)
ohhhhh i see
ok ill try it
And probably catch the error if the provided id is not correct
if (interaction.commandName === "reactdel") {
await interaction.deferReply({ephemeral:true});
let id = interaction.options.getString('msgid');
id = parseInt(id,10);
let msgchannel = interaction.channel;
await msgchannel.messages.fetch(id).reactions.removeAll();
await interaction.editReply('Delete all reaction of message.');
}
is this correct?
i had an error
No
fetch() returns a promise
Resources to understand Promise:
• MDN: learn more
• Guide: learn more
• JavaScript info: learn more
upus
how can i change this code 😦
I can't realize
I need await?
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
wdum?
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View