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
JavaScript
x
31
31
1
client.on("message", (e, message) => {
2
//The point is here, I can’t get the uncertainty message behind the user’s message
3
if (e.content.startsWith(`!reaction ${args.substring(1)} ${args.substring(2)}`)) {
4
var emojiname = [`${args.substring(1)}`],
5
rolename = [`${args.substring(2)}`];
6
if (!e.channel.guild) return;
7
for (let o in emojiname) {
8
var n = [e.guild.emojis.find(e => e.name == emojiname[o])];
9
for (let o in n) e.react(n[o])
10
}
11
}
12
});
13
14
client.on("messageReactionAdd", (e, n, message) => {
15
if (n && !n.bot && e.message.channel.guild)
16
for (let o in emojiname)
17
if (e.emoji.name == emojiname[o]) {
18
let i = e.message.guild.roles.find(e => e.name == rolename[o]);
19
e.message.guild.member(n).addRole(i).catch(console.error)
20
}
21
});
22
23
client.on("messageReactionRemove", (e, n, message) => {
24
if (n && !n.bot && e.message.channel.guild)
25
for (let o in emojiname)
26
if (e.emoji.name == emojiname[o]) {
27
let i = e.message.guild.roles.find(e => e.name == rolename[o]);
28
e.message.guild.member(n).removeRole(i).catch(console.error)
29
}
30
});
31
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