'Message.awaitReactions in a DM to user not collecting Discord.js v13

I am currently writing a bot that acts like a timeclock for a friend of mine. Currently I am trying to get the bot to message someone if they have been clocked in for more than 2 hours and have not "refreshed" their clock in time. More of just a reminder of, "hey did you forget to clock out".

Currently the bot sends a correct DM with the correct reaction to the user identified. However, it never detects when a user reacts to that message. My onMessageReactionAdd event fires, but i have blocked that if it is in a DM channel because I would like to perform a task if the user doesnt respond in time(clock them out). I would only like to collect the refresh attached to this method so I can keep methods separate.

I am suspecting i am awaiting on the wrong message, or not understanding exactly what is going on after reading through other answers.

    const refresh = require('../database/checkRefresh');
    const refrechClockin = require('../commands/refreshClockin');

    module.exports = async (client) =>{
        let users = [];
        const res = refresh.execute()
                        .then(res => {
                            console.log(`refresh query executed`);
                            if(res.rows.length > 0){
                                res.rows.forEach(row => {
                                    users.push(row.user_id);
                                })
                            }
                        })
                        .then( () => {
                            console.log(`users from refresh query: ${JSON.stringify(users)}`);
                            users.forEach(user => {
                                console.log(`user_id: ${user}`);
                                client.users.fetch(user)
                                            .then((user) => {
                                                var message = user.send('Did you forget to clock out? If you are still working click the little bell, after 5 minutes you will be clocked out.')                                            
                                                .then((message, user) => {
                                                    message.react('🔔');
                                                    const filter = (reaction, user) => reaction.emoji.name === '🔔';
                                                    message.awaitReactions(filter, {max:2, time: 5000})
                                                    .then(collected => {
                                                        console.log(`inside of new then method`);
                                                        console.log(`collected: ${JSON.stringify(collected)}`);
                                                    })
                                                    .catch(console.error)
                                                });
                                            });
                                            
                        });
        });
        
    }

After looking through other answers, I double checked my Intents and they seem to be correct.

const client = new Client({
    intents: [Intents.FLAGS.GUILDS, 
        Intents.FLAGS.GUILD_MESSAGES, 
        Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
        Intents.FLAGS.DIRECT_MESSAGES,
        Intents.FLAGS.DIRECT_MESSAGE_REACTIONS,
        Intents.FLAGS.DIRECT_MESSAGE_TYPING,
        ],
    partials: ['MESSAGE', 'CHANNEL', 'REACTION']
    });

UPDATE

I opted to change to a reactionCollector on the message. At first I was still having the same issue. After many console.logs, both in the filter and in the collector events, I discovered that my filter would not properly match the emoji that was being used. I even printed the reaction that was used(the bell) to console and copied from there to insert in the comparison and still will not match.

I would like to ultimately only allow them to respond using the bell, but for now I am ok with it. I have attached a default reaction from the bot so hopefully they see that and just click it. putting my updated code below. If anyone has any idea why I could not get the compare to work it would help. All of my other emoji comparisons are working correctly in my commands.

const refresh = require('../database/checkRefresh');
const refrechClockin = require('../commands/refreshClockin');

module.exports = async (client) =>{
    let users = [];
    const res = refresh.execute()
                    .then(async res => {
                        console.log(`refresh query executed`);
                        if(res.rows.length > 0){
                            res.rows.forEach(row => {
                                users.push(row.user_id);
                            })
                        }
                    })
                    .then( async () => {
                        console.log(`users from refresh query: ${JSON.stringify(users)}`);
                        users.forEach(user => {
                            console.log(`user_id: ${user}`);
                            client.users.fetch(user)
                                        .then(async (user) => {
                                            var message = await user.send('Did you forget to clock out? If you are still working click the little bell, after 5 minutes you will be clocked out.');
                                            message.react('🔔'); 
                                            const filter = (reaction, user) => {
                                                console.log(`reaction: ${JSON.stringify(reaction)}`);
                                                console.log(`Reaction Emoji: ${reaction.emoji.name}`);
                                                return (user.bot === false);
                                            }; 
                                            const collector = message.createReactionCollector({ filter, max: 1, time: 45_000 });
                                            collector.on('collect', r => console.log(`Collected ${r.emoji.name}`));
                                            collector.on('end', collected => console.log(`Collection ended with ${collected.size} Collected items`));
                                        });
                                        
                    });
    });
    
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source