Reputation: 113
How can I make the bot to send a DM message to the users who clicked the reaction?
client.on("message", (msg) => {
if (msg.guild && msg.content.startsWith("!test")) {
client.channels.cache.get("813782841187631126").send("Test-1")
.then((sentMessage) => {
sentMessage.react('811140592762486805')
const filter = (r) => r.emoji.id == '811140592762486805';
const collector = sentMessage.createReactionCollector(filter, {time: 60000});
collector.on('collect', (r) => {
reaction.author.send("Test-2");
});
});
}
});
Upvotes: 0
Views: 50
Reputation: 23161
The collect event on ReactionCollector takes two parameters; reaction
and user
. You can simply use the send()
method on the user to send them a DM.
Also, you should not collect the bot's reaction. You'll need to update your filter
and add && !user.bot
, so you won't try to send the bot a message.
const filter = (reaction, user) =>
reaction.emoji.id === '811140592762486805' && !user.bot;
const collector = sentMessage.createReactionCollector(filter, {
time: 60000,
});
collector.on('collect', (reaction, user) => {
user.send('Test-2');
});
Upvotes: 1