How can I delete all reactions?

How can i delete all reactions? I did cache the message, and channel.
18 Replies
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Fyphen
FyphenOP3y ago
Error: No Error
Syjalo
Syjalo3y ago
<Message>.reactions.removeAll()
Fyphen
FyphenOP3y ago
yes i tried it but TypeError: Cannot read properties of undefined (reading 'reactions')
Syjalo
Syjalo3y ago
So your message is undefined
Fyphen
FyphenOP3y ago
humm why?
Syjalo
Syjalo3y ago
Show the code
Fyphen
FyphenOP3y ago
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.'); }
Syjalo
Syjalo3y ago
Not all messages are cached. You should use fetch. await <TextBasedChannel>.messages.fetch(id)
Fyphen
FyphenOP3y ago
ohhhhh i see ok ill try it
Syjalo
Syjalo3y ago
And probably catch the error if the provided id is not correct
Fyphen
FyphenOP3y ago
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
Syjalo
Syjalo3y ago
No fetch() returns a promise
d.js docs
d.js docs3y ago
Resources to understand Promise: • MDN: learn more • Guide: learn more • JavaScript info: learn more
Fyphen
FyphenOP3y ago
upus how can i change this code 😦 I can't realize I need await?
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Fyphen
FyphenOP3y ago
wdum?
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server