Hello members of the Stack Overflow community,
I have been working on a function that activates when a moderator approves a user using Auttaja's gatekeeper. Basically, the new user gets to choose between two server emoji reactions, which will give him/her the roles. But I have been having difficulties with the role and emoji constants.
Here's my code:
const ApprovalEmbed = new Discord.MessageEmbed()
.setColor('RED')
.setTitle('Hi there new user!')
.setDescription('Please react to this message with either one of the emojis in order to get a role.')
.addFields(
{ name: '\u200B', value: '\u200B' },
{ name: 'The Boomer emoji gives you the "Les boomers normaux" role, and the rat emoji gives you the "The normal Rat Haven dwellers" role.'},
{ name: '\u200B', value: '\u200B' },
{ name: 'Selecting the Boomer emoji will give you access to only the Boomer Haven compartment, and the rat emoji will give you access to the Rat Haven compartment. '},
{ name: '\u200B', value: '\u200B' },
{name: 'To get access to both of these compartments, please consider using the command "^AccessToBoth" to receive the "Access to both compartments" role.'},
)
.setTimestamp()
.setFooter('Time to pick a role!');
const roleOne = guild.roles.cache.find((role) => role.name === "The normal Rat Haven dwellers")
const roleTwo = guild.roles.cache.find((role) => role.name === "Les boomers normaux")
const BoomerEmoji = message.guild.emojis.cache.find(emoji => emoji.name === 'boomer');
const RatEmoji = message.guild.emojis.cache.find(emoji => emoji.name === 'robincutmoment');
client.on('message', async message => {
let AdminRole = message.member.roles.cache.find(role => role.name === "Server Moderators")
let RulerRole = message.member.roles.cache.find(role => role.name === "The Supreme Boomers")
let RatRole = message.member.roles.cache.find(role => role.name === "Rat Majesty Robin")
if (message.member.roles.cache.has(AdminRole)) {
} else if (message.member.roles.cache.has(RulerRole)) {
} else if (message.member.roles.cache.has(RatRole)) {}
if (message.content === `-approve`) {
message.channel.send(BoomerEmoji)
const reactionMessage = await message.channel.send(ApprovalEmbed);
message.channel.send(ApprovalEmbed).then(reactionMessage.react(BoomerEmoji), reactionMessage.react(RatEmoji))
}
const filter = (reaction, user) => {
return [(BoomerEmoji), (RatEmoji)].includes(reaction.emoji.name) && user.id === message.author.id;
};
message.awaitReactions(filter, { max: 1, time: 60000, errors: ['time'] })
.then(collected => {
const reaction = collected.first();
if (reaction.emoji.name === (BoomerEmoji)) {
message.member.roles.add(roleOne)
} else if (reaction.emoji.name === (RatEmoji)) {
message.member.roles.add(roleTwo)
}
})
});