Console.log(user) returns undefined

Well, this problem has been bothering me for some time now, and I’ve kept putting it off, but now it’s time to get rid of this error.

I am trying to add some users to an array, in a way that makes it easy to just pull them forth and used them as mentions. Right now I have a reaction collector, and I’'m trying to pull out the users from there with two exceptions; the user and the bot. The reason the user isn’t going to matter, is because they should already be a part of the array.

For some context, I’m making a racing game, where you join by reacting and then after 60 seconds the game start and you hope to win. I’ve made a collector using the example on the Collectors | Discord.js Guide-site, but whenever I try to get the user who sent the message, and only the one who sent the message just then (Because the bot appears for every time I log reaction.users, even though it only reacts once). I’ve tried logging user, reaction.user, users and reaction.users.

And also, the collected.size gave me -1

Edit: Forgot to add some referencing code, but here you go

players.push( => {
const filter = (reaction, user) => {
return === ‘:racing_car:’;
const collector = sentEmbed.createReactionCollector(filter, { time: 15000 });
collector.on(‘collect’, (reaction => {
collector.on(‘end’, collected => {
let track = new Discord.RichEmbed()
.setTitle(“Owned by the Monimuffin Server”)
.setAuthor(“Formuffina 1”, “”)
.setDescription(“It’s a beautiful day outside. Birds are singing, flowers are blooming… \n We are here on the Monimuffin racing track, Sponsored by the Monimuffin server!”)
.addField(“Instructions”, “Attend the race by reacting with” + car + “\nDepending on your car, you have a varying chance of success\nThis is a very dangerous race, and many will not finish\n Only those who manage to finish the race will be rewarded”)
.setFooter(“Current players: 1”);

Anyways, all help would be greatly appreciated. So as always, thanks in advance, and have a marvelous day!

The way I do reaction roles on my bot for my discord server - I have channel the message is being sent to, completely cleared when the bot starts, then it sends the message, react for this blah blah, then I have a messageReactionAdd event, which the start of it, looks like this:

const { RichEmbed } = require('discord.js'); = async(client, messageReaction, user) => {
	const { message, emoji } = messageReaction;
	if ( return; // Dont include bots
	if ( === '480421483575902208' || // The bots id - So it does not include the bot !== '612438538000138240' || // Make sure its only in the channel the message was sent at the start !== '📥') return; // Make sure the emoji is correct

Hope that helps at all!

1 Like

It won’t let me pass the I’ve used console log on both sides, only the first one returns, meaning the code stops working right there. If you could explain to me a little bit how that part works, I may be able to find a workaround though, so thanks

Nvm, found a solution.

For anyone who also wonders about this, here’s my solution:

client.on(‘messageReactionAdd’, (reaction, user) => {
if( === candy && reaction.users.last() === user1) {//user1 is a variable I used earlier to find the mention, and candy is another variable
[Your code here]
} else if( === trick && reaction.users.last() === user1 && {//trick is also another variable
[Your code here]

This checks for two different reactions, and if the user reaction is the specified user. If there is anything just comment and I will answer as soon as I can.

1 Like