Advertisement
Danulsan

Untitled

Jun 25th, 2023
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.71 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 row1 = 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.  
  59. const row2 = new ActionRowBuilder()
  60. .addComponents(
  61. new ButtonBuilder()
  62. .setCustomId('button6')
  63. .setLabel(`${role6.name}`)
  64. .setStyle(ButtonStyle.Secondary),
  65.  
  66. new ButtonBuilder()
  67. .setCustomId('button7')
  68. .setLabel(`${role7.name}`)
  69. .setStyle(ButtonStyle.Secondary),
  70.  
  71. new ButtonBuilder()
  72. .setCustomId('button8')
  73. .setLabel(`${role8.name}`)
  74. .setStyle(ButtonStyle.Secondary),
  75.  
  76. new ButtonBuilder()
  77. .setCustomId('button9')
  78. .setLabel(`${role9.name}`)
  79. .setStyle(ButtonStyle.Secondary),
  80. );
  81.  
  82. const embed = new EmbedBuilder()
  83. .setColor("Blue")
  84. .setTitle(`Reaction Roles`)
  85. .setDescription(`React with the buttons below to get the specified roles! (${role1}, ${role2}, ${role3})`)
  86. .setAuthor({
  87. name: 'LynxBot',
  88. iconURL: 'https://media.discordapp.net/attachments/756409814145302548/1121212048135704606/lynx2_.png?width=786&height=675',
  89. url: 'https://www.zlg.gg'
  90. })
  91.  
  92.  
  93. await interaction.reply({
  94. embeds: [embed],
  95. components: [
  96. { type: 'ACTION_ROW', components: row1 },
  97. { type: 'ACTION_ROW', components: row2 }
  98. ],
  99. });
  100.  
  101. const collector = await interaction.channel.createMessageComponentCollector();
  102.  
  103. collector.on('collect', async (i) => {
  104.  
  105. const member = i.member;
  106.  
  107. if (i.guild.members.me.roles.highest.position < role1.position) {
  108. 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: [] });
  109. return;
  110. } else if (i.guild.members.me.roles.highest.position < role2.position) {
  111. 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: [] });
  112. return;
  113. } else if (i.guild.members.me.roles.highest.position < role3.position) {
  114. 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: [] });
  115. return;
  116. }
  117.  
  118. if (i.customId === 'button1') {
  119. member.roles.add(role1);
  120. i.reply({ content: `You now have the role : ${role1.name}`, ephemeral: true });
  121. }
  122.  
  123. if (i.customId === 'button2') {
  124. member.roles.add(role2);
  125. i.reply({ content: `You now have the role : ${role2.name}`, ephemeral: true });
  126. }
  127.  
  128. if (i.customId === 'button3') {
  129. member.roles.add(role3);
  130. i.reply({ content: `You now have the role : ${role3.name}`, ephemeral: true });
  131. }
  132.  
  133. if (i.customId === 'button4') {
  134. member.roles.add(role4);
  135. i.reply({ content: `You now have the role : ${role4.name}`, ephemeral: true });
  136. }
  137.  
  138. if (i.customId === 'button5') {
  139. member.roles.add(role5);
  140. i.reply({ content: `You now have the role : ${role5.name}`, ephemeral: true });
  141. }
  142.  
  143. // if (i.customId === 'button6') {
  144. // member.roles.add(role6);
  145. // i.reply({ content: `You now have the role : ${role6.name}`, ephemeral: true });
  146. // }
  147.  
  148. // if (i.customId === 'button7') {
  149. // member.roles.add(role7);
  150. // i.reply({ content: `You now have the role : ${role7.name}`, ephemeral: true });
  151. // }
  152.  
  153. // if (i.customId === 'button8') {
  154. // member.roles.add(role8);
  155. // i.reply({ content: `You now have the role : ${role8.name}`, ephemeral: true });
  156. // }
  157.  
  158. // if (i.customId === 'button9') {
  159. // member.roles.add(role9);
  160. // i.reply({ content: `You now have the role : ${role9.name}`, ephemeral: true });
  161. // }
  162. })
  163. }
  164. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement