How can I delete all reactions?

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