I created a ReactionCollector for my Discord Bot, but if I want to send a message to the user the error user.send() is not a function comes up. My Discord.js version is v11.
const filter = (reaction, user) => {
return validEmojis.includes(reaction.emoji.name) && user.id !== bot.user.id;
};
const collector = message.createReactionCollector(filter)
collector.on('collect', (reaction, user) => {
if (reaction.emoji.name === "🔊") {
user.send("hello")
}
});
Log output of the reaction parameter in the ReactionCollector:
<ref *1> MessageReaction {
message: Message {
me: true,
count: 2,
users: Collection(1) [Map] {
'342000434514493440' => User {
id: '342000434514493440',
username: 'TFS_NerzDesmony',
discriminator: '7832',
avatar: 'b05491a41564a2f32811b55d4ea44103',
bot: false,
lastMessageID: null,
lastMessage: null
}
},
_emoji: ReactionEmoji {
reaction: [Circular *1],
name: '🔊',
id: null,
animated: false
}
}
Hope anyone can help me solve this problem
Replace user.send("hello") by reaction.users.first().send("hello") according to MessageReaction since you are using Discord.js v11.