rajat_cj

BDFD • Rolemenu

Jul 17th, 2022 (edited)
975
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.94 KB | None | 0 0
  1. "RoleMenu for BDFD
  2. - Code by Rajat#1004
  3.  
  4.  
  5.  
  6.  
  7. Code 1
  8. --------------------------------------------------------------------------------
  9. Trigger : $onInteraction
  10. Language : BDScript 2
  11. Code :
  12. "
  13.  
  14.  
  15.  
  16. $nomention
  17.  
  18. $if[.$isSlash.$customID.==.true..]
  19.   $onlyAdmin[Only admin can create rolemenu!]
  20.   $c[Create Embed]
  21.   $try
  22.     $var[msgid;$sendEmbedMessage[$channelID;;$message[title];;$message[description];$replaceText[$replaceText[$isValidHex[$message[color]];true;$message[color]];false;ff8888];;;$message[footer];;$message[thumbnail];$message[image];no;yes]]
  23.   $catch
  24.     $var[msgid;$sendEmbedMessage[$channelID;;Get some roles from the menu below.;;$message[description];$replaceText[$replaceText[$isValidHex[$message[color]];true;$message[color]];false;ff8888];;;$message[footer];;$message[thumbnail];$message[image];no;yes]]
  25.   $endtry
  26.   $addButton[no;rolemenu•add•$authorID;Add Options;primary;no;🏷️;$var[msgid]]
  27.   $addButton[no;rolemenu•conf•$authorID;Confirm;success;no;📑;$var[msgid]]
  28.   $ephemeral
  29.   ✏️ **RoleMenu created.** Use button to add options.
  30.   ` -Code by Rajat#1004 `
  31.  
  32. $else
  33.  
  34.   $onlyIf[$checkContains[$customID;rolemenu;roleisgay]==true;]
  35.   $textSplit[$customID;•]
  36.  
  37.   $c[Add options to the menu]
  38.   $if[$splitText[2]•$splitText[3]==add•$authorID]
  39.     $newModal[rolemenu•newrole•$messageID;Add Role Options]
  40.     $addTextInput[name;short;Option Name;;;yes;;Get This Role]
  41.     $addTextInput[role;short;Role ID/Name;;;yes;;ID/Name of the role.]
  42.     $addTextInput[emo;short;Add Emoji;;;no;;🙂 or <:emoji:1234567890>]
  43.     $addTextInput[req;short;Require Role;;;no;;ID/Name of the requirement role.]
  44.     $addTextInput[bl;short;Blacklisted Role;;;no;;ID/Name of the blacklisted role.]
  45.   $endif
  46.  
  47.   $if[$splitText[2]==newrole]
  48.     $onlyIf[$roleExists[$findRole[$input[role]]]==true;❗ Role with Name/ID ` $input[role] ` doesn't exist!]
  49.    $ephemeral
  50.    $removeButtons
  51.    $removeComponent[roleisgay]
  52.    $if[$rolePosition[$highestRole[$botID]]<$rolePosition[$findRole[$input[role]]]]
  53.      $if[$input[req]!=]
  54.        $onlyIf[$roleExists[$findRole[$input[req]]]==true;❗ Requirement Role with Name/ID ` $input[req] ` doesn't exist!]
  55.       $endif
  56.       $if[$input[bl]!=]
  57.         $onlyIf[$roleExists[$findRole[$input[bl]]]==true;❗ Blacklisted Role with Name/ID ` $input[bl] ` doesn't exist!]
  58.      $endif
  59.      $try
  60.        $addSelectMenuOption[roleisgay;$input[name];$findRole[$input[role]].$findRole[$input[req]].$findRole[$input[bl]];@$roleName[$findRole[$input[role]]]$if[$input[req]!=] (ℹ️ @$roleName[$findRole[$input[req]]])$endif$if[$input[bl]!=] (❌ @$roleName[$findRole[$input[bl]]])$endif;no;$input[emo];$splitText[3]]
  61.      $catch
  62.        $newSelectMenu[roleisgay;1;1;Get Roles;$splitText[3]]
  63.        $addSelectMenuOption[roleisgay;Click to Add/Remove roles;mytrashcan;ℹ️ : Required Role, ❌ : Blacklisted Role;no;;$splitText[3]]
  64.        $addSelectMenuOption[roleisgay;$input[name];$findRole[$input[role]].$findRole[$input[req]].$findRole[$input[bl]];@$roleName[$findRole[$input[role]]]$if[$input[req]!=] (ℹ️ @$roleName[$findRole[$input[req]]])$endif$if[$input[bl]!=] (❌ @$roleName[$findRole[$input[bl]]])$endif;no;$input[emo];$splitText[3]]
  65.      $endtry
  66.      ✅ Role <@&$findRole[$input[role]]> added to the options.
  67.    $else
  68.      ❗ **Discord's Military Hierarchy returned an error!** The role <@&$findRole[$input[role]]> should be below Bot's highest role <@&$highestRole[$botID]> for the bot to be able to assign this role!
  69.    $endif
  70.  $endif
  71.  
  72.  
  73.  $c[Buttons are gay]
  74.  $if[$splitText[2]•$splitText[3]==conf•$authorID]
  75.    $async[butt]
  76.      $removeButtons[$messageID]
  77.    $endasync
  78.    $removeButtons
  79.    $removeComponent[roleisgay]
  80.    $ephemeral
  81.    🎆 The rolemenu is created successfully.
  82.  $endif
  83.  
  84.  
  85.  $c[Get/Remove Role]
  86.  $if[$customID==roleisgay]
  87.    $onlyIf[$message!=mytrashcan;]
  88.    $textSplit[$message;.]
  89.    $color[$getRoleColor[$splitText[1]]]
  90.    $removeComponent[$customID]
  91.    $removeButtons
  92.    $ephemeral
  93.    $if[$hasRole[$authorID;$splitText[1]]==false]
  94.      $if[$splitText[3]!=]
  95.        $if[$hasRole[$authorID;$splitText[3]]==true]
  96.          $description[**⚠️ Access Denied!** You have a role <@&$splitText[3]> which can not access <@&$splitText[1]>!]
  97.          $stop
  98.        $endif
  99.      $endif
  100.      $try
  101.        $if[$splitText[2]!=]
  102.          $if[$hasRole[$authorID;$splitText[2]]==false]
  103.            $description[**❓ Requirement Role Missing** : You need to have <@&$splitText[2]> to access <@&$splitText[1]>!]
  104.            $stop
  105.          $endif
  106.        $endif
  107.      $endtry
  108.      $giveRole[$authorID;$splitText[1]]
  109.      $description[**✅ Role <@&$splitText[1]> added successfully.**]
  110.      $image[https://singlecolorimage.com/get/$getRoleColor[$splitText[1]]/1000x8]
  111.    $else
  112.      $takeRole[$authorID;$splitText[1]]
  113.      $description[**❌ Role <@&$splitText[1]> removed successfully.**]
  114.    $endif
  115.  $endif
  116. $endif
  117.  
Add Comment
Please, Sign In to add comment