【问题标题】:Clear reactions edited embed message清除反应编辑的嵌入消息
【发布时间】:2021-05-09 04:35:53
【问题描述】:

我想做的是,当嵌入消息发生变化时,反应被重置,而不是被删除。 我的意思是,当有人对表情符号做出反应并嵌入其更改时,反应会返回 1 而不会停留在 2。 当它返回 1 时,我可以发送第三个嵌入

ty

这是我正在使用的代码:

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);
          }
        })
    });

【问题讨论】:

    标签: node.js discord.js embed


    【解决方案1】:

    您可以使用message.reactions.removeAll().catch(error => console.error('Failed to clear reactions: ', error)); 删除所有反应,然后根据需要添加回反应。我会在一个函数中执行此操作,这样您就不必在每次要更新嵌入时一遍又一遍地添加所有反应。

    【讨论】:

    • 你能帮我做吗?
    • “为你做”是什么意思?如果您希望我编写代码并编写所有程序,那么我不会这样做,因为该站点用于学习如何自己编写代码。转到discordjs.guide 并按照那里的教程进行操作。如果您只想要一个机器人而不需要自己完成工作,请转到 top.gg 并在那里寻找不和谐机器人。
    猜你喜欢
    • 2021-05-08
    • 2020-06-25
    • 2020-03-17
    • 1970-01-01
    • 2020-09-08
    • 2021-05-14
    • 2021-10-30
    • 2021-08-31
    • 2019-10-15
    相关资源
    最近更新 更多