我如何调用 module.exports 中的事件?

How do i call an event inside module.exports?

我正在尝试使用反应角色类型的命令,但我一直收到此错误。我正在尝试将反应添加到我的嵌入命令中。我试图在 index.js 中举办活动,但没有成功。任何帮助将不胜感激。

C:\Users\moham\OneDrive\Desktop\discord_bot\commands\reaction.js:25
    client.on('messageReactionAdd', async(reaction, user) => {

这是我的代码:

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;
        }
    });
}

}

不要在事件中添加新的客户端事件。而是等待消息的反应。

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}`)
  })

Message#awaitReactions