node.js - 如何向对消息做出反应的用户发送 dm [DISCORD.JS]
问题描述
我到处寻找,但我的问题从未得到回答。简单来说,这就是我想做的事情。
当用户对以下代码中的消息做出反应时,它会告诉他们“你做出了反应!”
collector.on('collect', (reaction, reactionCollector) => {
// I tried: reaction.author.send, doesn't work.
});
解决方案
拳头在一些触发后它的伟大反应收集器,然后处理表情符号。但这仅在一定时间内有效。
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)
});
推荐阅读
- r - R:如何为每个主题创建一个排名变量,不包括 NA 值
- excel - 逗号分隔 MsgBox 中的分隔值以拥有行?
- sql - 从表中删除具有两个重复列的最旧条目 - SQL
- python - 我在尝试格式化数据集中的时间戳时遇到错误
- c# - 使用“使用”时正在处理单元测试的只读对象
- ios - 当用户在 iOS 上打开推送通知时,有没有办法将收据发送回 Firebase?
- php - 在 Woocommerce 管理面板中显示自定义字段
- google-apps-script - 谷歌脚本 - 解析 json 响应
- python - 如何在图像上插入 UTF-8 字符
- javascript - 将带有JS的php变量拆分为数组