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
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.