Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
284 views
in Technique[技术] by (71.8m points)

node.js - Clear reactions edited embed message

I want to do is that when the embed message is changed, the reactions are reset, not deleted. I mean that when someone reacts to the emoji and embed its changed, the reaction returns to 1 and does not stay at 2. and when it returns to 1 I can send a third embed

enter image description here enter image description here

ty

This is the code I am using:

const embed = new MessageEmbed()
      .setTitle("Test1")
      .setFooter("Test1");
    message.channel.send(embed).then(sentEmbed => {
      sentEmbed.react("?");
      const filter = (reaction, user) => {
        return (
          ["?"].includes(reaction.emoji.name) &&
          user.id === message.author.id
        );
      };

      sentEmbed
        .awaitReactions(filter, { max: 1, time: 30000, errors: ["time"] })
        .then(collected => {
          const reaction = collected.first();

          if (reaction.emoji.name === "?") {

            const embed2 = new MessageEmbed()
            .setTitle('test2')
            .setDescription('test2')
             sentEmbed.edit(embed2);
          }
        })
    });
question from:https://stackoverflow.com/questions/66053048/clear-reactions-edited-embed-message

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can remove all reactions by using message.reactions.removeAll().catch(error => console.error('Failed to clear reactions: ', error)); and then add reactions back if you want. I would do this in a function so you don't have to add all the reactions over and over each time you want to update the embed.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...