Advertisement
xloxn

Infinite Button Pages v2 w/ ForgeScript & ForgeDB (1/2)

Dec 28th, 2023 (edited)
366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.36 KB | None | 0 0
  1. module.exports = {
  2. name: "pages",
  3. type: "messageCreate",
  4. code: `
  5.  
  6. $let[authorOnly;true] $c[Setting this to “true” enables interactions exclusively for the author.]
  7. $let[pageJumping;true] $c[Setting this to “true” enables page jumping, allowing you to navigate through pages effortlessly.]
  8.  
  9. $let[separator;|] $c[Specifies the separator character to use for dividing data.]
  10. $let[dataperpage;1] $c[Defines the maximum number of data entries per page, with a limit of 10.]
  11. $let[data;page1|page2|page3|page4|page5|page6...] $c[Allows for an unlimited number of pages, enabling continuous pagination.]
  12. $arrayLoad[data;$get[separator];$get[data]]
  13.  
  14. $description[
  15. $trimStart[$trimEnd[
  16. $if[$get[dataperpage]>=1;
  17. $arrayAt[data;0]]
  18. $if[$get[dataperpage]>=2;
  19. $arrayAt[data;1]]
  20. $if[$get[dataperpage]>=3;
  21. $arrayAt[data;2]]
  22. $if[$get[dataperpage]>=4;
  23. $arrayAt[data;3]]
  24. $if[$get[dataperpage]>=5;
  25. $arrayAt[data;4]]
  26. $if[$get[dataperpage]>=6;
  27. $arrayAt[data;5]]
  28. $if[$get[dataperpage]>=7;
  29. $arrayAt[data;6]]
  30. $if[$get[dataperpage]>=8;
  31. $arrayAt[data;7]]
  32. $if[$get[dataperpage]>=9;
  33. $arrayAt[data;8]]
  34. $if[$get[dataperpage]>=10;
  35. $arrayAt[data;9]]
  36. ]]
  37. ]
  38.  
  39. $if[$checkContains[$divide[$arrayLength[data];$get[dataperpage]];.]==true;
  40. $arrayLoad[pages;.;$divide[$arrayLength[data];$get[dataperpage]]]
  41. $let[pages;$sum[$arrayAt[pages;0];1]]
  42. ;
  43. $let[pages;$divide[$arrayLength[data];$get[dataperpage]]] ]
  44.  
  45. $footer[Page 1 of $get[pages]]
  46.  
  47. $color[#2c2d31]
  48.  
  49. $addActionRow
  50.  
  51. $addButton[1first-1-1-$get[pages]-$get[dataperpage]-$get[separator]-$authorID-$get[authorOnly]-$get[pageJumping]; ;Secondary;⏪;true]
  52. $addButton[1page-1-1-$get[pages]-$get[dataperpage]-$get[separator]-$authorID-$get[authorOnly]-$get[pageJumping]; ;Secondary;⬅️;true]
  53.  
  54. $if[$get[pageJumping]==true;
  55. $addButton[1page-jump-1-$get[pages]-$get[dataperpage]-$get[separator]-$authorID-$get[authorOnly]-$get[pageJumping];1 / $get[pages];Primary;;false]]
  56.  
  57. $if[$or[$arrayAt[data;0]==;$arrayAt[data;$sum[$get[dataperpage];1]]==]==true;
  58. $let[rdisabled;true];
  59. $let[rdisabled;false]]
  60.  
  61. $addButton[1page-2-1-$get[pages]-$get[dataperpage]-$get[separator]-$authorID-$get[authorOnly]-$get[pageJumping]; ;Secondary;➡️;$get[rdisabled]]
  62. $addButton[1last-$get[pages]-1-$get[pages]-$get[dataperpage]-$get[separator]-$authorID-$get[authorOnly]-$get[pageJumping]; ;Secondary;⏩;$get[rdisabled]]
  63.  
  64. $setVar[1data;$authorID;$get[data]]
  65.  
  66. `}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement