Im trying to create command that will and an embed that then reacts with an emoji. If someone clicks the emoji it adds a role, if they remove their reaction, then the role gets removed. I know how to create the embed and react with the emoji, I just need the code that could work.
I've tried:
const filter = (reaction, user) => {
return reaction.emoji.name === '✅' && user.id === message.author.id;
};
const collector = confirmation.createReactionCollector({filter});
collector.on('collect', async(reaction, user) => {
const role = await message.guild.roles.fetch("916861450281156678");
message.guild.members.fetch(user.id).then(member => {
member.roles.add(role);
member.roles.remove("916929706182459392");
});
});
yet, the reactionCollector returns with TypeError: Cannot read properties of undefined (reading 'createReactionCollector') so i'm not sure what the problem is. For reference here is the embed code.
const { MessageEmbed } = require('discord.js');
module.exports = {
name: 'rules',
description: 'Server Rules',
permission: "ADMINISTRATOR",
async execute(message) {
const rulemebed = new MessageEmbed()
.setColor('#ffc7fe')
.setTitle('Server Rules')
.setDescription('Please click the check mark ✅ to verfiy that you read the rules and gain access to other channels')
.setFooter('Abusing loop holes will result in fair punishment ')
.addFields(
{name: '#1', value:'...',},
);
const confirmation = await message.channel.send({ embeds: [rulemebed] }).then((sentMessage) => {
sentMessage.react("✅");
});
what i based the collector off