Advertisement
gaber-elsayed

role reaction button

Oct 6th, 2021
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. const Discord = require('discord.js');
  2. const client = new Discord.Client();
  3. require('discord-buttons')(client);
  4. const { MessageButton, MessageActionRow } = require("discord-buttons");
  5. const PREFIX = '-'
  6.  
  7. let btn1 = new MessageButton()
  8. .setStyle("blurple")
  9. .setEmoji("✌️")
  10. .setID("1")
  11. let btn2 = new MessageButton()
  12. .setStyle("blurple")
  13. .setEmoji("👊")
  14. .setID("2")
  15. let btn3 = new MessageButton()
  16. .setStyle("blurple")
  17. .setEmoji("👌")
  18. .setID("3")
  19. let row = new MessageActionRow()
  20. .addComponent(btn1)
  21. .addComponent(btn2)
  22. .addComponent(btn3);
  23. client.on('message', message => {
  24. if(message.content.startsWith(PREFIX +'add')) {
  25.  
  26. message.channel.send(`✨ | **react for free roles!\n 1- youtube role \n 2- anime role \n 3- games role**`, {
  27. component: row,
  28. })
  29. }
  30. });
  31. ////////////////////////////////
  32.  
  33.  
  34. client.on('clickButton', async (button) => {
  35. await button.defer();
  36. let guild = client.guilds.cache.get("740890983666810920")//ايدي سرفرك
  37. let roles = button.guild.roles;
  38. let role1 = button.guild.roles.cache.find(role => role.name == "youtube")// اسم الرتبه واحد
  39. let role2 = button.guild.roles.cache.find(role => role.name == "anime")//اسم الرتبه الثانيه
  40. let role3 = button.guild.roles.cache.find(role => role.name == "games")// اسم الرتبه الثالثه
  41. if(button.id === '1') {
  42. button.clicker.member.roles.add(role1)
  43. button.clicker.member.send(`you got the role **youtube**`)
  44. }
  45. if(button.id == '2') {
  46. button.clicker.member.roles.add(role2)
  47. button.clicker.member.send(`you got the role **anime**`)
  48. }
  49. if(button.id == '3') {
  50. button.clicker.member.roles.add(role3)
  51. button.clicker.member.send(`you got the role **games**`)
  52.  
  53. }
  54. /////////////////////////
  55. if(button.id === '1') {
  56. if(button.clicker.member.roles.cache.has('ايدي الرتبه الاولئ')) {
  57. button.clicker.member.roles.remove(role1)
  58. button.clicker.member.send(`you removed the role **youtube**`)
  59. }
  60. }
  61. if(button.id == '2') {
  62. if(button.clicker.member.roles.cache.has('ايدي الرتبه الثانيه')) {
  63. button.clicker.member.roles.remove(role2)
  64. button.clicker.member.send(`you removed the role **anime**`)
  65. }
  66. }
  67. if(button.id == '3') {
  68. if(button.clicker.member.roles.cache.has('ايدي الرتبه الثالثه')) {
  69. button.clicker.member.roles.remove(role3)
  70. button.clicker.member.send(`you removed the role **games**`)
  71. }
  72. }
  73. });
  74.  
  75.  
  76.  
  77. client.login('توكن البوت');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement