Advertisement
xloxn

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

Dec 28th, 2023 (edited)
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.60 KB | None | 0 0
  1. module.exports = {
  2. type: "interactionCreate",
  3. code: `
  4.  
  5. $if[$checkContains[$customID;1first;1last;1page]==true;
  6.  
  7. $arrayLoad[customID;-;$replace[$customID;hop;$input[page]]]
  8. $let[nextlocation;$arrayAt[customID;1]]
  9. $let[current;$arrayAt[customID;2]]
  10. $let[pages;$arrayAt[customID;3]]
  11. $let[dataperpage;$arrayAt[customID;4]]
  12. $let[separator;$arrayAt[customID;5]]
  13. $let[authorOnly;$arrayAt[customID;7]]
  14. $let[pageJumping;$arrayAt[customID;8]]
  15. $let[data;$getVar[1data;$authorID;]]
  16.  
  17. $if[$checkContains[$customID;hop]==true;
  18. $ifx[ $if[$isNumber[$input[page]]==false;$interactionReply[$ephemeral
  19. $description[Please input a valid page number]
  20. $color[#2c2d31]] $stop]
  21.  
  22. $elseif[$isInteger[$input[page]]==false;
  23. $interactionReply[$ephemeral
  24. $description[Please input a valid page number]
  25. $color[#2c2d31]] $stop]
  26.  
  27. $elseif[$or[$input[page]>$get[pages];$input[page]<=0]==true;
  28. $interactionReply[$ephemeral
  29. $description[Please input a valid page number]
  30. $color[#2c2d31]] $stop]
  31.  
  32. ]]
  33.  
  34. $arrayLoad[data;$get[separator];$get[data]]
  35.  
  36. $ifx[
  37. $if[$and[$get[authorOnly]==true;$checkContains[$customID;$authorID]==false]==true;
  38. $interactionReply[$ephemeral
  39. $description[This isn't for you]
  40. $color[#2c2d31]]]
  41.  
  42. $elseif[$and[$get[pageJumping]==true;$checkContains[$customID;jump]==true]==true;
  43. $modal[$replace[$customID;jump;hop];Input a Page]
  44. $addTextInput[page;Page Number;Short;true;$get[current] / $get[pages];$get[current];1;3]]
  45.  
  46. $else[
  47.  
  48. $let[sum;$math[($get[dataperpage]*$get[nextlocation])-$get[dataperpage]]]
  49.  
  50.  
  51. $if[$checkContains[$divide[$arrayLength[data];$get[dataperpage]];.]==true;
  52. $arrayLoad[pages;.;$divide[$arrayLength[data];$get[dataperpage]]]
  53. $let[pages;$sum[$arrayAt[pages;0];1]]
  54. ;
  55. $let[pages;$divide[$arrayLength[data];$get[dataperpage]]]]
  56.  
  57.  
  58.  
  59. $interactionUpdate[
  60. $description[
  61. $trimStart[$trimEnd[
  62. $if[$get[dataperpage]>=1;
  63. $arrayAt[data;$sum[$get[sum];0]]]
  64. $if[$get[dataperpage]>=2;
  65. $arrayAt[data;$sum[$get[sum];1]]]
  66. $if[$get[dataperpage]>=3;
  67. $arrayAt[data;$sum[$get[sum];2]]]
  68. $if[$get[dataperpage]>=4;
  69. $arrayAt[data;$sum[$get[sum];3]]]
  70. $if[$get[dataperpage]>=5;
  71. $arrayAt[data;$sum[$get[sum];4]]]
  72. $if[$get[dataperpage]>=6;
  73. $arrayAt[data;$sum[$get[sum];5]]]
  74. $if[$get[dataperpage]>=7;
  75. $arrayAt[data;$sum[$get[sum];6]]]
  76. $if[$get[dataperpage]>=8;
  77. $arrayAt[data;$sum[$get[sum];7]]]
  78. $if[$get[dataperpage]>=9;
  79. $arrayAt[data;$sum[$get[sum];8]]]
  80. $if[$get[dataperpage]>=10;
  81. $arrayAt[data;$sum[$get[sum];9]]]
  82. ]]
  83. ]
  84.  
  85. $footer[Page $get[nextlocation] of $get[pages]]
  86. $color[#2c2d31]
  87.  
  88. $deleteActionRow[1]
  89. $addActionRow
  90. $if[$get[nextlocation]==1;
  91. $let[ldisabled;true];
  92. $let[ldisabled;false]]
  93.  
  94. $addButton[1first-1-$get[nextlocation]-$get[pages]-$get[dataperpage]-$get[separator]-$authorID-$get[authorOnly]-$get[pageJumping]; ;Secondary;⏪;$get[ldisabled]]
  95. $addButton[1page-$sub[$get[nextlocation];1]-$get[nextlocation]-$get[pages]-$get[dataperpage]-$get[separator]-$authorID-$get[authorOnly]-$get[pageJumping]; ;Secondary;⬅️;$get[ldisabled]]
  96.  
  97. $if[$get[pageJumping]==true;
  98. $addButton[1page-jump-$get[nextlocation]-$get[pages]-$get[dataperpage]-$get[separator]-$authorID-$get[authorOnly]-$get[pageJumping];$get[nextlocation] / $get[pages];Primary]]
  99.  
  100. $if[$get[nextlocation]==$get[pages];
  101. $let[rdisabled;true];
  102. $let[rdisabled;false]]
  103.  
  104. $addButton[1page-$sum[$get[nextlocation];1]-$get[nextlocation]-$get[pages]-$get[dataperpage]-$get[separator]-$authorID-$get[authorOnly]-$get[pageJumping]; ;Secondary;➡️;$get[rdisabled]]
  105. $addButton[1last-$get[pages]-$get[nextlocation]-$get[pages]-$get[dataperpage]-$get[separator]-$authorID-$get[authorOnly]-$get[pageJumping]; ;Secondary;⏩;$get[rdisabled]]
  106.  
  107. ]]]]
  108.  
  109. `}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement