Advertisement
Danulsan

Untitled

Jun 25th, 2023
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.43 KB | None | 0 0
  1. const { SlashCommandBuilder } = require('@discordjs/builders');
  2. const { PermissionsBitField, ButtonStyle, ActionRowBuilder, ButtonBuilder, EmbedBuilder } = require(`discord.js`);
  3.  
  4. module.exports = {
  5. data: new SlashCommandBuilder()
  6. .setName('reactrole')
  7. .setDescription(`This is the reaction role message command`)
  8. .addRoleOption(option => option.setName(`role1`).setDescription(`This is the first role you want to set up`).setRequired(true))
  9. .addRoleOption(option => option.setName(`role2`).setDescription(`This is the second role you want to set up`).setRequired(true))
  10. .addRoleOption(option => option.setName(`role3`).setDescription(`This is the third role you want to set up`).setRequired(true))
  11. .addRoleOption(option => option.setName(`role4`).setDescription(`This is the first role you want to set up`).setRequired(true))
  12. .addRoleOption(option => option.setName(`role5`).setDescription(`This is the second role you want to set up`).setRequired(true)),
  13. // .addRoleOption(option => option.setName(`role6`).setDescription(`This is the third role you want to set up`).setRequired(true))
  14. // .addRoleOption(option => option.setName(`role7`).setDescription(`This is the first role you want to set up`).setRequired(true))
  15. // .addRoleOption(option => option.setName(`role8`).setDescription(`This is the second role you want to set up`).setRequired(true))
  16. // .addRoleOption(option => option.setName(`role9`).setDescription(`This is the third role you want to set up`).setRequired(true)),
  17. async execute(interaction, client) {
  18.  
  19. const role1 = interaction.options.getRole(`role1`);
  20. const role2 = interaction.options.getRole(`role2`);
  21. const role3 = interaction.options.getRole(`role3`);
  22. const role4 = interaction.options.getRole(`role4`);
  23. const role5 = interaction.options.getRole(`role5`);
  24. // const role6 = interaction.options.getRole(`role6`);
  25. // const role7 = interaction.options.getRole(`role7`);
  26. // const role8 = interaction.options.getRole(`role8`);
  27. // const role9 = interaction.options.getRole(`role9`);
  28.  
  29. 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 });
  30.  
  31. const button = new ActionRowBuilder()
  32. .addComponents(
  33. new ButtonBuilder()
  34. .setCustomId('button1')
  35. .setLabel(`${role1.name}`)
  36. .setStyle(ButtonStyle.Secondary),
  37.  
  38. new ButtonBuilder()
  39. .setCustomId('button2')
  40. .setLabel(`${role2.name}`)
  41. .setStyle(ButtonStyle.Secondary),
  42.  
  43. new ButtonBuilder()
  44. .setCustomId('button3')
  45. .setLabel(`${role3.name}`)
  46. .setStyle(ButtonStyle.Secondary),
  47.  
  48. new ButtonBuilder()
  49. .setCustomId('button4')
  50. .setLabel(`${role4.name}`)
  51. .setStyle(ButtonStyle.Secondary),
  52.  
  53. new ButtonBuilder()
  54. .setCustomId('button5')
  55. .setLabel(`${role5.name}`)
  56. .setStyle(ButtonStyle.Secondary),
  57.  
  58. // new ButtonBuilder()
  59. // .setCustomId('button6')
  60. // .setLabel(`${role6.name}`)
  61. // .setStyle(ButtonStyle.Secondary),
  62.  
  63. // new ButtonBuilder()
  64. // .setCustomId('button7')
  65. // .setLabel(`${role7.name}`)
  66. // .setStyle(ButtonStyle.Secondary),
  67.  
  68. // new ButtonBuilder()
  69. // .setCustomId('button8')
  70. // .setLabel(`${role8.name}`)
  71. // .setStyle(ButtonStyle.Secondary),
  72.  
  73. // new ButtonBuilder()
  74. // .setCustomId('button9')
  75. // .setLabel(`${role9.name}`)
  76. // .setStyle(ButtonStyle.Secondary),
  77.  
  78. )
  79.  
  80. const embed = new EmbedBuilder()
  81. .setColor("Blue")
  82. .setTitle(`Reaction Roles`)
  83. .setDescription(`React with the buttons below to get the specified roles! (${role1}, ${role2}, ${role3})`)
  84. .setAuthor('LynxBot', 'https://media.discordapp.net/attachments/756409814145302548/1121212048135704606/lynx2_.png?width=786&height=675', 'https://www.zlg.gg')
  85.  
  86. await interaction.reply({ embeds: [embed], components: [button] });
  87.  
  88. const collector = await interaction.channel.createMessageComponentCollector();
  89.  
  90. collector.on('collect', async (i) => {
  91.  
  92. const member = i.member;
  93.  
  94. if (i.guild.members.me.roles.highest.position < role1.position) {
  95. 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: [] });
  96. return;
  97. } else if (i.guild.members.me.roles.highest.position < role2.position) {
  98. 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: [] });
  99. return;
  100. } else if (i.guild.members.me.roles.highest.position < role3.position) {
  101. 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: [] });
  102. return;
  103. }
  104.  
  105. if (i.customId === 'button1') {
  106. member.roles.add(role1);
  107. i.reply({ content: `You now have the role : ${role1.name}`, ephemeral: true });
  108. }
  109.  
  110. if (i.customId === 'button2') {
  111. member.roles.add(role2);
  112. i.reply({ content: `You now have the role : ${role2.name}`, ephemeral: true });
  113. }
  114.  
  115. if (i.customId === 'button3') {
  116. member.roles.add(role3);
  117. i.reply({ content: `You now have the role : ${role3.name}`, ephemeral: true });
  118. }
  119.  
  120. if (i.customId === 'button4') {
  121. member.roles.add(role4);
  122. i.reply({ content: `You now have the role : ${role4.name}`, ephemeral: true });
  123. }
  124.  
  125. if (i.customId === 'button5') {
  126. member.roles.add(role5);
  127. i.reply({ content: `You now have the role : ${role5.name}`, ephemeral: true });
  128. }
  129.  
  130. // if (i.customId === 'button6') {
  131. // member.roles.add(role6);
  132. // i.reply({ content: `You now have the role : ${role6.name}`, ephemeral: true });
  133. // }
  134.  
  135. // if (i.customId === 'button7') {
  136. // member.roles.add(role7);
  137. // i.reply({ content: `You now have the role : ${role7.name}`, ephemeral: true });
  138. // }
  139.  
  140. // if (i.customId === 'button8') {
  141. // member.roles.add(role8);
  142. // i.reply({ content: `You now have the role : ${role8.name}`, ephemeral: true });
  143. // }
  144.  
  145. // if (i.customId === 'button9') {
  146. // member.roles.add(role9);
  147. // i.reply({ content: `You now have the role : ${role9.name}`, ephemeral: true });
  148. // }
  149. })
  150. }
  151. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement