I dont know why but i followed the guide in discord.js about awaiting reactions but it seems it doesnt work on mine. I dont know why. Whenever i hit the emoji it doesnt collect it. I pretty much goes to every answered question here in stackoverflow but i still cannot fix it.
const { Client, Message, MessageEmbed } = require("discord.js");
module.exports = {
name: "error",
/**
* @param {Client} client
* @param {Message} message
* @param {String[]} args
*/
run: async (client, message, args) => {
message.delete({ timeout:2000 })
var randstr = Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5);
var randnum = Math.floor(Math.random() * 100);
var comb = randstr + randnum;
var sayEmbed = new MessageEmbed()
.setTitle('Console Error #'+ '`' + comb + '`' + ' sent by ' + message.member.user.tag)
.setDescription('```' + args.join(" ") + '```')
.setTimestamp()
.setColor("BLACK")
.setTimestamp()
.setFooter("Copyright ©️ 2022, Mythic Realms, or its associates. All Rights Reserved.")
message.channel.send({embed: sayEmbed}).then(embedMessage => {
embedMessage.react('✅');
})
const filter = (reaction, user) => reaction.emoji.name === '✅' && user.id === message.author.id;
const collector = message.createReactionCollector(filter, { max: 1, time: 5 * 60 * 1000 });
collector.on('collect', () => {
message.clearReactions();
console.log('SUCCESS');
});
},
};
Please help with this bot :< thank you.
You're creating a message collector at message whereas the reaction itself is at embedMessage.
embedMessage.createReactionCollector would be the correct.
Plus, said embedMessage is within the scope of the message.send().then()
You can either assign the return value of the message.send() promise to embedMessage on the same level so it is accessible by the collector or set the collector inside the then() function from message.send()
const embedMessage = await message.send(...);
const collector = embedMessage.createReactionCollector(...);
or
message.send(...).then(embedMessage => {
const collector = embedMessage.createReactionCollector(...);
});