Estoy tratando de tener un tipo de comando de rol de reacción, pero sigo recibiendo este error. Estoy tratando de agregar una reacción a mi comando de inserción. Traté de tener el evento en index.js pero ofc no funcionó. Cualquier ayuda sería apreciada.
C:\Users\moham\OneDrive\Desktop\discord_bot\commands\reaction.js:25 client.on('messageReactionAdd', async(reaction, user) => {Este es mi código:
module.exports = { name: 'reactionrole', description: "Sets up a reaction role message!", async execute(message, args, Discord, client) { const channel = 'YOUR_CHANNEL'; const yellowTeamRole = message.guild.roles.cache.find(role => role.name === "YOUR_ROLE"); const blueTeamRole = message.guild.roles.cache.find(role => role.name === "YOUR_ROLE"); const yellowTeamEmoji = 'YOUR_EMOJI'; const blueTeamEmoji = 'YOUR_EMOJI'; let embed = new Discord.MessageEmbed() .setColor('#e42643') .setTitle('Choose a team to play on!') .setDescription('Choosing a team will allow you to interact with your teammates!\n\n' + `${yellowTeamEmoji} for yellow team\n` + `${blueTeamEmoji} for blue team`); let messageEmbed = await message.channel.send(embed); messageEmbed.react(yellowTeamEmoji); messageEmbed.react(blueTeamEmoji); client.on('messageReactionAdd', async (reaction, user) => { if (reaction.message.partial) await reaction.message.fetch(); if (reaction.partial) await reaction.fetch(); if (user.bot) return; if (!reaction.message.guild) return; if (reaction.message.channel.id == channel) { if (reaction.emoji.name === yellowTeamEmoji) { await reaction.message.guild.members.cache.get(user.id).roles.add(yellowTeamRole); } if (reaction.emoji.name === blueTeamEmoji) { await reaction.message.guild.members.cache.get(user.id).roles.add(blueTeamRole); } } else { return; } }); client.on('messageReactionRemove', async (reaction, user) => { if (reaction.message.partial) await reaction.message.fetch(); if (reaction.partial) await reaction.fetch(); if (user.bot) return; if (!reaction.message.guild) return; if (reaction.message.channel.id == channel) { if (reaction.emoji.name === yellowTeamEmoji) { await reaction.message.guild.members.cache.get(user.id).roles.remove(yellowTeamRole); } if (reaction.emoji.name === blueTeamEmoji) { await reaction.message.guild.members.cache.get(user.id).roles.remove(blueTeamRole); } } else { return; } }); }}
No agregue nuevos eventos de clientes dentro de un evento. En su lugar, espere las reacciones de un mensaje.
const filter = (reaction, user) => user.id === message.author.id; message.awaitReactions({filter, time: 60000}) .then(reactions => reactions.first()) .then(reaction => { console.log(`${message.author.tag} reacted with ${reaction.emoji.name}`) })