Skip to content
Advertisement

Discord.js reaction roles user uncertainty message

I want to make reaction roles, but I can’t get the uncertain information behind the content posted by the user.I have searched online many times, but I can’t find relevant information

Below is my program

client.on("message", (e, message) => {
  //The point is here, I can’t get the uncertainty message behind the user’s message
    if (e.content.startsWith(`!reaction ${args.substring(1)} ${args.substring(2)}`)) {
      var emojiname = [`${args.substring(1)}`],
      rolename = [`${args.substring(2)}`];
        if (!e.channel.guild) return;
        for (let o in emojiname) {  
            var n = [e.guild.emojis.find(e => e.name == emojiname[o])];
            for (let o in n) e.react(n[o])
        }
    }
});

client.on("messageReactionAdd", (e, n, message) => {
    if (n && !n.bot && e.message.channel.guild)
        for (let o in emojiname)
            if (e.emoji.name == emojiname[o]) {
                let i = e.message.guild.roles.find(e => e.name == rolename[o]);
                e.message.guild.member(n).addRole(i).catch(console.error)
            }
});

client.on("messageReactionRemove", (e, n, message) => {
    if (n && !n.bot && e.message.channel.guild)
        for (let o in emojiname)
            if (e.emoji.name == emojiname[o]) {
                let i = e.message.guild.roles.find(e => e.name == rolename[o]);
                e.message.guild.member(n).removeRole(i).catch(console.error)
            }
});

My English is bad, please forgive me

Advertisement

Answer

There is a package called reaction-role. Here is the link: https://www.npmjs.com/package/reaction-role

ReactionRole is a module that allows you to create Discord reaction role easily. Here is an example to how to use package: https://github.com/barbarbar338/reaction-role-example

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement