Advertisement
Aouchan

User's Roles Sorting (Using API)

Apr 17th, 2024 (edited)
983
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 2.29 KB | Source Code | 0 0
  1. $nomention
  2.  
  3. $if[$message==]
  4.     $var[member;$authorID]
  5. $elseif[$findUser[$message;no]==]
  6.         $var[member;$message]
  7.         $onlyIf[$userExists[$var[member]]==true;`❌` User or Member `"$message"` not found.]
  8. $else
  9.     $var[member;$findUser[$message;no]]
  10. $endif
  11.  
  12. $httpAddHeader[apikey;$getVar[ApiKey]]
  13. $httpAddHeader[bot-token;$getVar[BotToken]]
  14. $httpAddHeader[guild-id;$guildID]
  15. $httpAddHeader[member;$var[member]]
  16.  
  17. $httpGet[https://bdfddata.rickyjs.xyz/release/guild/members]
  18. $jsonParse[$httpResult]
  19.  
  20. $var[user.roles.length;$jsonArrayCount[details;roles]]
  21.  
  22. $if[$json[details;message]==Unknown Member]
  23.     That user isn't in this server.
  24. $else
  25.    $if[$var[user.roles.length]==0]
  26.        $username[$var[member]] has no roles.
  27.    $else
  28.        $textSplit[$jsonJoinArray[details;roles;-];-]
  29.        $var[user.roles.length;$getTextSplitLength]
  30.        
  31.        $jsonParse[{ "sorted.roles": [\] }]
  32.        
  33.        $var[x;1]
  34.        $var[code;%{DOL}%var[role-id\;%{DOL}%splitText[%{DOL}%var[x\]\]\]%{DOL}%jsonSetString[%{DOL}%rolePosition[%{DOL}%var[role-id\]\]\;%{DOL}%var[role-id\]\]%{DOL}%var[x\;%{DOL}%calculate[%{DOL}%var[x\] + 1\]\]]
  35.        
  36.        $if[$var[user.roles.length]<=100]
  37.            $var[loop;$replaceText[$cropText[$repeatMessage[10;$repeatMessage[10;@]];$var[user.roles.length];];@;$var[code]]]
  38.        $else
  39.            $var[loop;$replaceText[$cropText[$repeatMessage[10;$repeatMessage[10;$repeatMessage[10;#]]];$var[user.roles.length];];#;$var[code]]]
  40.        $endif
  41.        
  42.        $eval[$var[loop]]
  43.        
  44.        $var[n;1]
  45.        $var[code;%{DOL}%if[%{DOL}%jsonArrayCount[sorted.roles\]==%{DOL}%var[user.roles.length\]\]%{DOL}%stop%{DOL}%endif%{DOL}%if[%{DOL}%json[%{DOL}%var[n\]\]!=\]%{DOL}%jsonArrayAppend[sorted.roles\;"%{DOL}%json[%{DOL}%var[n\]\]"\]%{DOL}%endif%{DOL}%var[n\;%{DOL}%calculate[%{DOL}%var[n\] + 1\]\]]
  46.        
  47.        $eval[$replaceText[$cropText[$repeatMessage[10;$repeatMessage[10;$repeatMessage[3;~]]];250;];~;$var[code]]]
  48.        
  49.        $var[separator;, ]
  50.        $var[final.result;<@&$replaceText[$jsonJoinArray[sorted.roles;>$var[separator]<@&]>;";]]
  51.        
  52.        $description[$var[final.result]]
  53.        $color[8fdbd7]
  54.        $footer[$username[$var[member]] has $jsonArrayCount[sorted.roles] roles]
  55.    $endif
  56. $endif
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement