Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { SlashCommandBuilder } = require('@discordjs/builders');
- const { PermissionsBitField, ButtonStyle, ActionRowBuilder, ButtonBuilder, EmbedBuilder } = require(`discord.js`);
- module.exports = {
- data: new SlashCommandBuilder()
- .setName('reactrole')
- .setDescription(`This is the reaction role message command`)
- .addRoleOption(option => option.setName(`role1`).setDescription(`This is the first role you want to set up`).setRequired(true))
- .addRoleOption(option => option.setName(`role2`).setDescription(`This is the second role you want to set up`).setRequired(true))
- .addRoleOption(option => option.setName(`role3`).setDescription(`This is the third role you want to set up`).setRequired(true))
- .addRoleOption(option => option.setName(`role4`).setDescription(`This is the first role you want to set up`).setRequired(true))
- .addRoleOption(option => option.setName(`role5`).setDescription(`This is the second role you want to set up`).setRequired(true)),
- // .addRoleOption(option => option.setName(`role6`).setDescription(`This is the third role you want to set up`).setRequired(true))
- // .addRoleOption(option => option.setName(`role7`).setDescription(`This is the first role you want to set up`).setRequired(true))
- // .addRoleOption(option => option.setName(`role8`).setDescription(`This is the second role you want to set up`).setRequired(true))
- // .addRoleOption(option => option.setName(`role9`).setDescription(`This is the third role you want to set up`).setRequired(true)),
- async execute(interaction, client) {
- const role1 = interaction.options.getRole(`role1`);
- const role2 = interaction.options.getRole(`role2`);
- const role3 = interaction.options.getRole(`role3`);
- const role4 = interaction.options.getRole(`role4`);
- const role5 = interaction.options.getRole(`role5`);
- // const role6 = interaction.options.getRole(`role6`);
- // const role7 = interaction.options.getRole(`role7`);
- // const role8 = interaction.options.getRole(`role8`);
- // const role9 = interaction.options.getRole(`role9`);
- if (!interaction.member.permissions.has(PermissionsBitField.Flags.Administrator)) return await interaction.reply({ content: "You must have admin perms to create a reaction role message", ephemeral: true });
- const button = new ActionRowBuilder()
- .addComponents(
- new ButtonBuilder()
- .setCustomId('button1')
- .setLabel(`${role1.name}`)
- .setStyle(ButtonStyle.Secondary),
- new ButtonBuilder()
- .setCustomId('button2')
- .setLabel(`${role2.name}`)
- .setStyle(ButtonStyle.Secondary),
- new ButtonBuilder()
- .setCustomId('button3')
- .setLabel(`${role3.name}`)
- .setStyle(ButtonStyle.Secondary),
- new ButtonBuilder()
- .setCustomId('button4')
- .setLabel(`${role4.name}`)
- .setStyle(ButtonStyle.Secondary),
- new ButtonBuilder()
- .setCustomId('button5')
- .setLabel(`${role5.name}`)
- .setStyle(ButtonStyle.Secondary),
- // new ButtonBuilder()
- // .setCustomId('button6')
- // .setLabel(`${role6.name}`)
- // .setStyle(ButtonStyle.Secondary),
- // new ButtonBuilder()
- // .setCustomId('button7')
- // .setLabel(`${role7.name}`)
- // .setStyle(ButtonStyle.Secondary),
- // new ButtonBuilder()
- // .setCustomId('button8')
- // .setLabel(`${role8.name}`)
- // .setStyle(ButtonStyle.Secondary),
- // new ButtonBuilder()
- // .setCustomId('button9')
- // .setLabel(`${role9.name}`)
- // .setStyle(ButtonStyle.Secondary),
- )
- const embed = new EmbedBuilder()
- .setColor("Blue")
- .setTitle(`Reaction Roles`)
- .setDescription(`React with the buttons below to get the specified roles! (${role1}, ${role2}, ${role3})`)
- .setAuthor('LynxBot', 'https://media.discordapp.net/attachments/756409814145302548/1121212048135704606/lynx2_.png?width=786&height=675', 'https://www.zlg.gg')
- await interaction.reply({ embeds: [embed], components: [button] });
- const collector = await interaction.channel.createMessageComponentCollector();
- collector.on('collect', async (i) => {
- const member = i.member;
- if (i.guild.members.me.roles.highest.position < role1.position) {
- i.update({ content: "My role is below the roles that I'm trying to give; I have shut this reaction role message down.", embeds: [], components: [] });
- return;
- } else if (i.guild.members.me.roles.highest.position < role2.position) {
- i.update({ content: "My role is below the roles that I'm trying to give; I have shut this reaction role message down.", embeds: [], components: [] });
- return;
- } else if (i.guild.members.me.roles.highest.position < role3.position) {
- i.update({ content: "My role is below the roles that I'm trying to give; I have shut this reaction role message down.", embeds: [], components: [] });
- return;
- }
- if (i.customId === 'button1') {
- member.roles.add(role1);
- i.reply({ content: `You now have the role : ${role1.name}`, ephemeral: true });
- }
- if (i.customId === 'button2') {
- member.roles.add(role2);
- i.reply({ content: `You now have the role : ${role2.name}`, ephemeral: true });
- }
- if (i.customId === 'button3') {
- member.roles.add(role3);
- i.reply({ content: `You now have the role : ${role3.name}`, ephemeral: true });
- }
- if (i.customId === 'button4') {
- member.roles.add(role4);
- i.reply({ content: `You now have the role : ${role4.name}`, ephemeral: true });
- }
- if (i.customId === 'button5') {
- member.roles.add(role5);
- i.reply({ content: `You now have the role : ${role5.name}`, ephemeral: true });
- }
- // if (i.customId === 'button6') {
- // member.roles.add(role6);
- // i.reply({ content: `You now have the role : ${role6.name}`, ephemeral: true });
- // }
- // if (i.customId === 'button7') {
- // member.roles.add(role7);
- // i.reply({ content: `You now have the role : ${role7.name}`, ephemeral: true });
- // }
- // if (i.customId === 'button8') {
- // member.roles.add(role8);
- // i.reply({ content: `You now have the role : ${role8.name}`, ephemeral: true });
- // }
- // if (i.customId === 'button9') {
- // member.roles.add(role9);
- // i.reply({ content: `You now have the role : ${role9.name}`, ephemeral: true });
- // }
- })
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement