Discord.JS-循环嵌入从反应编辑

时间:2019-12-08 18:47:51

标签: node.js discord.js

我正在创建一个计时器,当将命令键入不和谐时,它会在下面创建带有反应的嵌入,单击反应时,它将编辑嵌入并更新时间。

奇怪的是,有时我最多可以单击反应10次,它将更新嵌入内容,有时我只能单击一次或两次。我曾尝试将max参数更改为多个数字,但我不知道这是否实际上影响了该功能。

client.on('message', message => {


    if (message.content === `${prefix}k`) {

          // Time & Date
          var dateFormat = require('dateformat');
          var KillTime=dateFormat(new Date(), "longTime");
          var KillTimeDay=dateFormat(new Date(), "mm-dd ");

        var embed = new Discord.RichEmbed()
        .setColor('#0099ff')
        .setTitle('///')
        .setDescription("@everyone " + "Last Killed: " + KillTimeDay + " - " + KillTime)

        // Images & Credit
        .setAuthor('///', 'https://#', 'https://#')
        .setThumbnail('https://#')

        message.channel.send(embed)
        .then(m => {
        m.react('☠️');

    const filter = (reaction, user) => reaction.emoji.name === '☠️' && user.id === message.author.id;
    const collector = m.createReactionCollector(filter, { max: 600, time: 0 }); // 5 min

    collector.on('collect', () => {
      m.clearReactions();

         // Time & Date
          var dateFormat = require('dateformat');
          var KillTime=dateFormat(new Date(), "longTime");
          var KillTimeDay=dateFormat(new Date(), "mm-dd ");

      var embed = new Discord.RichEmbed()
      .setColor('#0099ff')
      .setTitle('///')
      .setDescription("@everyone " + "Last Killed: " + KillTimeDay + " - " + KillTime)

      // Images & Credit
      .setAuthor('///', 'https://#', 'https://#')
      .setThumbnail('https://#')

      m.edit(embed);
      m.react('☠️');
    });
})
  .catch(err => console.error(err));
}
});

0 个答案:

没有答案