邮件收集器不收集DM中的邮件

时间:2020-09-23 13:20:34

标签: javascript node.js discord discord.js

因此,我试图在直接消息中执行琐事命令。但是该漫游器不会收集用户的消息。僵尸程序会向用户DM,控制台中没有错误,该僵尸程序应该记录该消息,但没有。 这是我使用的代码

    const channel = await message.author.createDM();
    const collector = channel.createMessageCollector(filter, { max: 1, time: 60000 }) // Wait 15 seconds
    collector.on('collect', msg => {
      console.log("Collected message: " + message.content);
      if (answers.includes(msg.content.trim().toLowerCase().replace(/\.|'|-|\s/g, ''))) {
        winner = msg.author;
        collector.stop();
      }
    });
    collector.on('end', () => {
      const answerEmbed = new MessageEmbed()
        .setTitle('Solo Trivia')
        .setFooter(message.member.displayName,  message.author.displayAvatarURL({ dynamic: true }))
        .setTimestamp()
        .setColor(message.guild.me.displayHexColor);
      if (winner) 
        message.member.send(answerEmbed.setDescription(`Congratulations ${winner}, you gave the correct answer!`));
      else message.member.send(answerEmbed
        .setDescription(`Sorry ${message.member}, time's up! Better luck next time.`)
        .addField('Correct Answers', origAnswers.join('\n'))
      );
    });

0 个答案:

没有答案