首页 > 解决方案 > 如何向对消息做出反应的用户发送 dm [DISCORD.JS]

问题描述

我到处寻找,但我的问题从未得到回答。简单来说,这就是我想做的事情。
当用户对以下代码中的消息做出反应时,它会告诉他们“你做出了反应!”

collector.on('collect', (reaction, reactionCollector) => {
// I tried: reaction.author.send, doesn't work.
});

标签: node.jsdiscord.js

解决方案


拳头在一些触发后它的伟大反应收集器,然后处理表情符号。但这仅在一定时间内有效。

message.channel.send('Your Text').then(msg=> {
msg.react(`◀️`)
const filter = (reaction, user) => {
    return [`◀️`].includes(reaction.emoji.name) && user.id === message.author.id;
};
const collector = msg.createReactionCollector(filter, {time: 60000 });
collector.on('collect', (reaction, reactionCollector) => {
    reaction.users.last().send('Some')
    .catch(console.error)
});
})

如果您需要在特定消息中一直处理它,您可以监听事件reaction_add

bot.on('messageReactionAdd', (reaction, user) => {
    if(reaction.message.id !== 'YOUR MESSAGE ID') return
    user.send('Some')
    .catch(console.error)
  });

推荐阅读