@duque.edits/sdk 1.1.2 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (350) hide show
  1. package/dist/{index-BPxglVSk.d.ts → index-0BFrnm6S.d.ts} +437 -193
  2. package/dist/index.d.ts +2 -1
  3. package/dist/index.js +10 -4225
  4. package/dist/index.js.map +1 -0
  5. package/dist/managers/automaticmessage/AutomaticMessageManager.d.ts +2 -1
  6. package/dist/managers/automaticmessage/AutomaticMessageManager.js +42 -739
  7. package/dist/managers/automaticmessage/AutomaticMessageManager.js.map +1 -0
  8. package/dist/managers/base.d.ts +2 -1
  9. package/dist/managers/base.js +8 -89
  10. package/dist/managers/base.js.map +1 -0
  11. package/dist/managers/bet/GuildBetManager.d.ts +2 -1
  12. package/dist/managers/bet/GuildBetManager.js +21 -901
  13. package/dist/managers/bet/GuildBetManager.js.map +1 -0
  14. package/dist/managers/betuser/GuildBetUserManager.d.ts +2 -1
  15. package/dist/managers/betuser/GuildBetUserManager.js +22 -444
  16. package/dist/managers/betuser/GuildBetUserManager.js.map +1 -0
  17. package/dist/managers/buffer/BufferManager.d.ts +2 -1
  18. package/dist/managers/buffer/BufferManager.js +8 -192
  19. package/dist/managers/buffer/BufferManager.js.map +1 -0
  20. package/dist/managers/guild/GuildManager.d.ts +2 -1
  21. package/dist/managers/guild/GuildManager.js +38 -3704
  22. package/dist/managers/guild/GuildManager.js.map +1 -0
  23. package/dist/managers/index.d.ts +2 -1
  24. package/dist/managers/index.js +40 -3937
  25. package/dist/managers/index.js.map +1 -0
  26. package/dist/managers/logs/LogManager.d.ts +2 -1
  27. package/dist/managers/logs/LogManager.js +16 -673
  28. package/dist/managers/logs/LogManager.js.map +1 -0
  29. package/dist/managers/match/GuildMatchManager.d.ts +2 -1
  30. package/dist/managers/match/GuildMatchManager.js +26 -1225
  31. package/dist/managers/match/GuildMatchManager.js.map +1 -0
  32. package/dist/managers/mediator/GuildMediatorManager.d.ts +2 -1
  33. package/dist/managers/mediator/GuildMediatorManager.js +23 -365
  34. package/dist/managers/mediator/GuildMediatorManager.js.map +1 -0
  35. package/dist/managers/message/MessagesManager.d.ts +2 -1
  36. package/dist/managers/message/MessagesManager.js +5 -88
  37. package/dist/managers/message/MessagesManager.js.map +1 -0
  38. package/dist/managers/minesgame/MinesGameManager.d.ts +2 -1
  39. package/dist/managers/minesgame/MinesGameManager.js +16 -655
  40. package/dist/managers/minesgame/MinesGameManager.js.map +1 -0
  41. package/dist/managers/permission/GuildPermissionManager.d.ts +2 -1
  42. package/dist/managers/permission/GuildPermissionManager.js +22 -212
  43. package/dist/managers/permission/GuildPermissionManager.js.map +1 -0
  44. package/dist/managers/player/PlayerManager.d.ts +2 -1
  45. package/dist/managers/player/PlayerManager.js +4 -87
  46. package/dist/managers/player/PlayerManager.js.map +1 -0
  47. package/dist/managers/product/ProductManager.d.ts +22 -0
  48. package/dist/managers/product/ProductManager.js +101 -0
  49. package/dist/managers/product/ProductManager.js.map +1 -0
  50. package/dist/managers/shop/ShopManager.d.ts +22 -0
  51. package/dist/managers/shop/ShopManager.js +99 -0
  52. package/dist/managers/shop/ShopManager.js.map +1 -0
  53. package/dist/managers/ticket/TicketManager.d.ts +2 -1
  54. package/dist/managers/ticket/TicketManager.js +25 -707
  55. package/dist/managers/ticket/TicketManager.js.map +1 -0
  56. package/dist/managers/ticketpanel/TicketPanelManager.d.ts +22 -0
  57. package/dist/managers/ticketpanel/TicketPanelManager.js +82 -0
  58. package/dist/managers/ticketpanel/TicketPanelManager.js.map +1 -0
  59. package/dist/managers/tournament/TournamentManager.d.ts +2 -1
  60. package/dist/managers/tournament/TournamentManager.js +33 -686
  61. package/dist/managers/tournament/TournamentManager.js.map +1 -0
  62. package/dist/managers/user/GuildUserManager.d.ts +2 -1
  63. package/dist/managers/user/GuildUserManager.js +24 -502
  64. package/dist/managers/user/GuildUserManager.js.map +1 -0
  65. package/dist/managers/vipmember/VipMemberManager.d.ts +2 -1
  66. package/dist/managers/vipmember/VipMemberManager.js +30 -425
  67. package/dist/managers/vipmember/VipMemberManager.js.map +1 -0
  68. package/dist/rest/APIEndpoints.js +4 -5
  69. package/dist/rest/APIEndpoints.js.map +1 -0
  70. package/dist/rest/REST.d.ts +2 -1
  71. package/dist/rest/REST.js +57 -3932
  72. package/dist/rest/REST.js.map +1 -0
  73. package/dist/rest/Routes.d.ts +79 -87
  74. package/dist/rest/Routes.js +9 -18
  75. package/dist/rest/Routes.js.map +1 -0
  76. package/dist/rest/index.d.ts +2 -1
  77. package/dist/rest/index.js +8 -4027
  78. package/dist/rest/index.js.map +1 -0
  79. package/dist/structures/Collection.js +6 -7
  80. package/dist/structures/Collection.js.map +1 -0
  81. package/dist/structures/automaticmessage/AutomaticMessage.d.ts +3 -2
  82. package/dist/structures/automaticmessage/AutomaticMessage.js +51 -531
  83. package/dist/structures/automaticmessage/AutomaticMessage.js.map +1 -0
  84. package/dist/structures/bet/GuildBet.d.ts +2 -1
  85. package/dist/structures/bet/GuildBet.js +21 -696
  86. package/dist/structures/bet/GuildBet.js.map +1 -0
  87. package/dist/structures/betuser/GuildBetUser.d.ts +2 -1
  88. package/dist/structures/betuser/GuildBetUser.js +32 -130
  89. package/dist/structures/betuser/GuildBetUser.js.map +1 -0
  90. package/dist/structures/guild/Guild.d.ts +5 -4
  91. package/dist/structures/guild/Guild.js +195 -3321
  92. package/dist/structures/guild/Guild.js.map +1 -0
  93. package/dist/structures/index.d.ts +2 -1
  94. package/dist/structures/index.js +34 -3772
  95. package/dist/structures/index.js.map +1 -0
  96. package/dist/structures/logentry/LogEntry.d.ts +2 -1
  97. package/dist/structures/logentry/LogEntry.js +24 -497
  98. package/dist/structures/logentry/LogEntry.js.map +1 -0
  99. package/dist/structures/match/GuildMatch.d.ts +2 -1
  100. package/dist/structures/match/GuildMatch.js +56 -950
  101. package/dist/structures/match/GuildMatch.js.map +1 -0
  102. package/dist/structures/mediator/GuildMediator.d.ts +2 -1
  103. package/dist/structures/mediator/GuildMediator.js +19 -123
  104. package/dist/structures/mediator/GuildMediator.js.map +1 -0
  105. package/dist/structures/minesgame/MinesGame.d.ts +2 -1
  106. package/dist/structures/minesgame/MinesGame.js +15 -496
  107. package/dist/structures/minesgame/MinesGame.js.map +1 -0
  108. package/dist/structures/product/Product.d.ts +22 -0
  109. package/dist/structures/product/Product.js +120 -0
  110. package/dist/structures/product/Product.js.map +1 -0
  111. package/dist/structures/shop/Shop.d.ts +22 -0
  112. package/dist/structures/shop/Shop.js +125 -0
  113. package/dist/structures/shop/Shop.js.map +1 -0
  114. package/dist/structures/ticket/Ticket.d.ts +3 -2
  115. package/dist/structures/ticket/Ticket.js +30 -517
  116. package/dist/structures/ticket/Ticket.js.map +1 -0
  117. package/dist/structures/ticketpanel/TicketPanel.d.ts +22 -0
  118. package/dist/structures/ticketpanel/TicketPanel.js +177 -0
  119. package/dist/structures/ticketpanel/TicketPanel.js.map +1 -0
  120. package/dist/structures/tournament/Tournament.d.ts +2 -1
  121. package/dist/structures/tournament/Tournament.js +14 -493
  122. package/dist/structures/tournament/Tournament.js.map +1 -0
  123. package/dist/structures/user/GuildUser.d.ts +2 -1
  124. package/dist/structures/user/GuildUser.js +148 -136
  125. package/dist/structures/user/GuildUser.js.map +1 -0
  126. package/dist/structures/vipmember/VipMember.d.ts +2 -1
  127. package/dist/structures/vipmember/VipMember.js +12 -116
  128. package/dist/structures/vipmember/VipMember.js.map +1 -0
  129. package/dist/types/RestTypes.d.ts +2 -1
  130. package/dist/types/RestTypes.js +1 -2
  131. package/dist/types/RestTypes.js.map +1 -0
  132. package/dist/types/api/APIAdvert.js +1 -2
  133. package/dist/types/api/APIAdvert.js.map +1 -0
  134. package/dist/types/api/APIAutomaticMessage.d.ts +2 -1
  135. package/dist/types/api/APIAutomaticMessage.js +1 -2
  136. package/dist/types/api/APIAutomaticMessage.js.map +1 -0
  137. package/dist/types/api/APIBaseChannel.js +1 -2
  138. package/dist/types/api/APIBaseChannel.js.map +1 -0
  139. package/dist/types/api/APIBetChannel.js +1 -2
  140. package/dist/types/api/APIBetChannel.js.map +1 -0
  141. package/dist/types/api/APICode.js +1 -2
  142. package/dist/types/api/APICode.js.map +1 -0
  143. package/dist/types/api/APIGiveaway.js +1 -2
  144. package/dist/types/api/APIGiveaway.js.map +1 -0
  145. package/dist/types/api/APIGuild.d.ts +5 -4
  146. package/dist/types/api/APIGuild.js +2 -2
  147. package/dist/types/api/APIGuild.js.map +1 -0
  148. package/dist/types/api/APIGuildAdvert.js +1 -2
  149. package/dist/types/api/APIGuildAdvert.js.map +1 -0
  150. package/dist/types/api/APIGuildBet.d.ts +2 -1
  151. package/dist/types/api/APIGuildBet.js +1 -2
  152. package/dist/types/api/APIGuildBet.js.map +1 -0
  153. package/dist/types/api/APIGuildBetUser.d.ts +2 -1
  154. package/dist/types/api/APIGuildBetUser.js +1 -2
  155. package/dist/types/api/APIGuildBetUser.js.map +1 -0
  156. package/dist/types/api/APIGuildChannel.js +1 -2
  157. package/dist/types/api/APIGuildChannel.js.map +1 -0
  158. package/dist/types/api/APIGuildGroupedChannel.d.ts +2 -1
  159. package/dist/types/api/APIGuildGroupedChannel.js +1 -2
  160. package/dist/types/api/APIGuildGroupedChannel.js.map +1 -0
  161. package/dist/types/api/APIGuildMatch.d.ts +2 -1
  162. package/dist/types/api/APIGuildMatch.js +1 -2
  163. package/dist/types/api/APIGuildMatch.js.map +1 -0
  164. package/dist/types/api/APIGuildMediator.js +1 -2
  165. package/dist/types/api/APIGuildMediator.js.map +1 -0
  166. package/dist/types/api/APIGuildPermissions.d.ts +18 -2
  167. package/dist/types/api/APIGuildPermissions.js +18 -3
  168. package/dist/types/api/APIGuildPermissions.js.map +1 -0
  169. package/dist/types/api/APIGuildShop.d.ts +6 -1
  170. package/dist/types/api/APIGuildShop.js +1 -2
  171. package/dist/types/api/APIGuildShop.js.map +1 -0
  172. package/dist/types/api/APIGuildTicket.js +1 -2
  173. package/dist/types/api/APIGuildTicket.js.map +1 -0
  174. package/dist/types/api/APIGuildUser.d.ts +2 -1
  175. package/dist/types/api/APIGuildUser.js +1 -2
  176. package/dist/types/api/APIGuildUser.js.map +1 -0
  177. package/dist/types/api/APILogEntry.d.ts +4 -2
  178. package/dist/types/api/APILogEntry.js +4 -3
  179. package/dist/types/api/APILogEntry.js.map +1 -0
  180. package/dist/types/api/APIMessage.d.ts +2 -0
  181. package/dist/types/api/APIMessage.js +1 -2
  182. package/dist/types/api/APIMessage.js.map +1 -0
  183. package/dist/types/api/APIMinesGame.js +1 -2
  184. package/dist/types/api/APIMinesGame.js.map +1 -0
  185. package/dist/types/api/APIPlayer.js +1 -2
  186. package/dist/types/api/APIPlayer.js.map +1 -0
  187. package/dist/types/api/APIProduct.d.ts +1 -1
  188. package/dist/types/api/APIProduct.js +2 -2
  189. package/dist/types/api/APIProduct.js.map +1 -0
  190. package/dist/types/api/APITicketPanel.d.ts +22 -0
  191. package/dist/types/api/APITicketPanel.js +17 -0
  192. package/dist/types/api/APITicketPanel.js.map +1 -0
  193. package/dist/types/api/APITournament.d.ts +6 -1
  194. package/dist/types/api/APITournament.js +1 -2
  195. package/dist/types/api/APITournament.js.map +1 -0
  196. package/dist/types/api/APIVipMember.js +1 -2
  197. package/dist/types/api/APIVipMember.js.map +1 -0
  198. package/dist/types/api/index.d.ts +2 -1
  199. package/dist/types/api/index.js +63 -110
  200. package/dist/types/api/index.js.map +1 -0
  201. package/dist/types/index.d.ts +2 -1
  202. package/dist/types/index.js +6 -154
  203. package/dist/types/index.js.map +1 -0
  204. package/dist/utils/Assertion.js +3 -4
  205. package/dist/utils/Assertion.js.map +1 -0
  206. package/dist/utils/getRandomNumber.js +1 -2
  207. package/dist/utils/getRandomNumber.js.map +1 -0
  208. package/dist/utils/isSameDayUTC.d.ts +3 -0
  209. package/dist/utils/isSameDayUTC.js +34 -0
  210. package/dist/utils/isSameDayUTC.js.map +1 -0
  211. package/dist/utils/randomKeyGenerator.js +1 -2
  212. package/dist/utils/randomKeyGenerator.js.map +1 -0
  213. package/package.json +4 -5
  214. package/dist/index-DjHimKUy.d.mts +0 -1431
  215. package/dist/index.d.mts +0 -23
  216. package/dist/index.mjs +0 -4196
  217. package/dist/managers/automaticmessage/AutomaticMessageManager.d.mts +0 -21
  218. package/dist/managers/automaticmessage/AutomaticMessageManager.mjs +0 -796
  219. package/dist/managers/base.d.mts +0 -21
  220. package/dist/managers/base.mjs +0 -107
  221. package/dist/managers/bet/GuildBetManager.d.mts +0 -21
  222. package/dist/managers/bet/GuildBetManager.mjs +0 -958
  223. package/dist/managers/betuser/GuildBetUserManager.d.mts +0 -21
  224. package/dist/managers/betuser/GuildBetUserManager.mjs +0 -502
  225. package/dist/managers/buffer/BufferManager.d.mts +0 -21
  226. package/dist/managers/buffer/BufferManager.mjs +0 -223
  227. package/dist/managers/guild/GuildManager.d.mts +0 -21
  228. package/dist/managers/guild/GuildManager.mjs +0 -3786
  229. package/dist/managers/index.d.mts +0 -21
  230. package/dist/managers/index.mjs +0 -3934
  231. package/dist/managers/logs/LogManager.d.mts +0 -21
  232. package/dist/managers/logs/LogManager.mjs +0 -738
  233. package/dist/managers/match/GuildMatchManager.d.mts +0 -21
  234. package/dist/managers/match/GuildMatchManager.mjs +0 -1305
  235. package/dist/managers/mediator/GuildMediatorManager.d.mts +0 -21
  236. package/dist/managers/mediator/GuildMediatorManager.mjs +0 -430
  237. package/dist/managers/message/MessagesManager.d.mts +0 -21
  238. package/dist/managers/message/MessagesManager.mjs +0 -134
  239. package/dist/managers/minesgame/MinesGameManager.d.mts +0 -21
  240. package/dist/managers/minesgame/MinesGameManager.mjs +0 -721
  241. package/dist/managers/permission/GuildPermissionManager.d.mts +0 -21
  242. package/dist/managers/permission/GuildPermissionManager.mjs +0 -256
  243. package/dist/managers/player/PlayerManager.d.mts +0 -21
  244. package/dist/managers/player/PlayerManager.mjs +0 -155
  245. package/dist/managers/ticket/TicketManager.d.mts +0 -21
  246. package/dist/managers/ticket/TicketManager.mjs +0 -827
  247. package/dist/managers/tournament/TournamentManager.d.mts +0 -21
  248. package/dist/managers/tournament/TournamentManager.mjs +0 -745
  249. package/dist/managers/user/GuildUserManager.d.mts +0 -21
  250. package/dist/managers/user/GuildUserManager.mjs +0 -567
  251. package/dist/managers/vipmember/VipMemberManager.d.mts +0 -21
  252. package/dist/managers/vipmember/VipMemberManager.mjs +0 -513
  253. package/dist/rest/APIEndpoints.d.mts +0 -12
  254. package/dist/rest/APIEndpoints.mjs +0 -19
  255. package/dist/rest/REST.d.mts +0 -21
  256. package/dist/rest/REST.mjs +0 -4021
  257. package/dist/rest/Routes.d.mts +0 -104
  258. package/dist/rest/Routes.mjs +0 -104
  259. package/dist/rest/index.d.mts +0 -23
  260. package/dist/rest/index.mjs +0 -4036
  261. package/dist/structures/Collection.d.mts +0 -19
  262. package/dist/structures/Collection.mjs +0 -87
  263. package/dist/structures/automaticmessage/AutomaticMessage.d.mts +0 -21
  264. package/dist/structures/automaticmessage/AutomaticMessage.mjs +0 -609
  265. package/dist/structures/bet/GuildBet.d.mts +0 -21
  266. package/dist/structures/bet/GuildBet.mjs +0 -881
  267. package/dist/structures/betuser/GuildBetUser.d.mts +0 -21
  268. package/dist/structures/betuser/GuildBetUser.mjs +0 -326
  269. package/dist/structures/guild/Guild.d.mts +0 -21
  270. package/dist/structures/guild/Guild.mjs +0 -3690
  271. package/dist/structures/index.d.mts +0 -21
  272. package/dist/structures/index.mjs +0 -3773
  273. package/dist/structures/logentry/LogEntry.d.mts +0 -21
  274. package/dist/structures/logentry/LogEntry.mjs +0 -575
  275. package/dist/structures/match/GuildMatch.d.mts +0 -21
  276. package/dist/structures/match/GuildMatch.mjs +0 -1191
  277. package/dist/structures/mediator/GuildMediator.d.mts +0 -21
  278. package/dist/structures/mediator/GuildMediator.mjs +0 -246
  279. package/dist/structures/minesgame/MinesGame.d.mts +0 -21
  280. package/dist/structures/minesgame/MinesGame.mjs +0 -579
  281. package/dist/structures/ticket/Ticket.d.mts +0 -21
  282. package/dist/structures/ticket/Ticket.mjs +0 -626
  283. package/dist/structures/tournament/Tournament.d.mts +0 -21
  284. package/dist/structures/tournament/Tournament.mjs +0 -585
  285. package/dist/structures/user/GuildUser.d.mts +0 -21
  286. package/dist/structures/user/GuildUser.mjs +0 -382
  287. package/dist/structures/vipmember/VipMember.d.mts +0 -21
  288. package/dist/structures/vipmember/VipMember.mjs +0 -250
  289. package/dist/types/RestTypes.d.mts +0 -21
  290. package/dist/types/RestTypes.mjs +0 -0
  291. package/dist/types/api/APIAdvert.d.mts +0 -13
  292. package/dist/types/api/APIAdvert.mjs +0 -0
  293. package/dist/types/api/APIAutomaticMessage.d.mts +0 -21
  294. package/dist/types/api/APIAutomaticMessage.mjs +0 -0
  295. package/dist/types/api/APIBaseChannel.d.mts +0 -12
  296. package/dist/types/api/APIBaseChannel.mjs +0 -0
  297. package/dist/types/api/APIBetChannel.d.mts +0 -12
  298. package/dist/types/api/APIBetChannel.mjs +0 -0
  299. package/dist/types/api/APICode.d.mts +0 -12
  300. package/dist/types/api/APICode.mjs +0 -0
  301. package/dist/types/api/APIGiveaway.d.mts +0 -29
  302. package/dist/types/api/APIGiveaway.mjs +0 -0
  303. package/dist/types/api/APIGuild.d.mts +0 -21
  304. package/dist/types/api/APIGuild.mjs +0 -46
  305. package/dist/types/api/APIGuildAdvert.d.mts +0 -10
  306. package/dist/types/api/APIGuildAdvert.mjs +0 -0
  307. package/dist/types/api/APIGuildBet.d.mts +0 -21
  308. package/dist/types/api/APIGuildBet.mjs +0 -8
  309. package/dist/types/api/APIGuildBetUser.d.mts +0 -21
  310. package/dist/types/api/APIGuildBetUser.mjs +0 -0
  311. package/dist/types/api/APIGuildChannel.d.mts +0 -12
  312. package/dist/types/api/APIGuildChannel.mjs +0 -0
  313. package/dist/types/api/APIGuildGroupedChannel.d.mts +0 -21
  314. package/dist/types/api/APIGuildGroupedChannel.mjs +0 -0
  315. package/dist/types/api/APIGuildMatch.d.mts +0 -21
  316. package/dist/types/api/APIGuildMatch.mjs +0 -14
  317. package/dist/types/api/APIGuildMediator.d.mts +0 -16
  318. package/dist/types/api/APIGuildMediator.mjs +0 -0
  319. package/dist/types/api/APIGuildPermissions.d.mts +0 -15
  320. package/dist/types/api/APIGuildPermissions.mjs +0 -13
  321. package/dist/types/api/APIGuildShop.d.mts +0 -15
  322. package/dist/types/api/APIGuildShop.mjs +0 -0
  323. package/dist/types/api/APIGuildTicket.d.mts +0 -19
  324. package/dist/types/api/APIGuildTicket.mjs +0 -0
  325. package/dist/types/api/APIGuildUser.d.mts +0 -21
  326. package/dist/types/api/APIGuildUser.mjs +0 -0
  327. package/dist/types/api/APILogEntry.d.mts +0 -32
  328. package/dist/types/api/APILogEntry.mjs +0 -20
  329. package/dist/types/api/APIMessage.d.mts +0 -13
  330. package/dist/types/api/APIMessage.mjs +0 -0
  331. package/dist/types/api/APIMinesGame.d.mts +0 -15
  332. package/dist/types/api/APIMinesGame.mjs +0 -0
  333. package/dist/types/api/APIPlayer.d.mts +0 -10
  334. package/dist/types/api/APIPlayer.mjs +0 -0
  335. package/dist/types/api/APIProduct.d.mts +0 -22
  336. package/dist/types/api/APIProduct.mjs +0 -0
  337. package/dist/types/api/APITournament.d.mts +0 -16
  338. package/dist/types/api/APITournament.mjs +0 -0
  339. package/dist/types/api/APIVipMember.d.mts +0 -22
  340. package/dist/types/api/APIVipMember.mjs +0 -0
  341. package/dist/types/api/index.d.mts +0 -21
  342. package/dist/types/api/index.mjs +0 -135
  343. package/dist/types/index.d.mts +0 -21
  344. package/dist/types/index.mjs +0 -135
  345. package/dist/utils/Assertion.d.mts +0 -34
  346. package/dist/utils/Assertion.mjs +0 -52
  347. package/dist/utils/getRandomNumber.d.mts +0 -3
  348. package/dist/utils/getRandomNumber.mjs +0 -7
  349. package/dist/utils/randomKeyGenerator.d.mts +0 -3
  350. package/dist/utils/randomKeyGenerator.mjs +0 -8
@@ -1,3773 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __typeError = (msg) => {
8
- throw TypeError(msg);
9
- };
10
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
12
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
13
- }) : x)(function(x) {
14
- if (typeof require !== "undefined") return require.apply(this, arguments);
15
- throw Error('Dynamic require of "' + x + '" is not supported');
16
- });
17
- var __commonJS = (cb, mod) => function __require2() {
18
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
19
- };
20
- var __copyProps = (to, from, except, desc) => {
21
- if (from && typeof from === "object" || typeof from === "function") {
22
- for (let key of __getOwnPropNames(from))
23
- if (!__hasOwnProp.call(to, key) && key !== except)
24
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
- }
26
- return to;
27
- };
28
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
- // If the importer is in node compatibility mode or this is not an ESM
30
- // file that has been converted to a CommonJS file using a Babel-
31
- // compatible transform (i.e. "__esModule" has not been set), then set
32
- // "default" to the CommonJS "module.exports" for node compatibility.
33
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
- mod
35
- ));
36
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
37
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
38
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
39
- var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
40
-
41
- // node_modules/dotenv/package.json
42
- var require_package = __commonJS({
43
- "node_modules/dotenv/package.json"(exports, module) {
44
- module.exports = {
45
- name: "dotenv",
46
- version: "16.6.1",
47
- description: "Loads environment variables from .env file",
48
- main: "lib/main.js",
49
- types: "lib/main.d.ts",
50
- exports: {
51
- ".": {
52
- types: "./lib/main.d.ts",
53
- require: "./lib/main.js",
54
- default: "./lib/main.js"
55
- },
56
- "./config": "./config.js",
57
- "./config.js": "./config.js",
58
- "./lib/env-options": "./lib/env-options.js",
59
- "./lib/env-options.js": "./lib/env-options.js",
60
- "./lib/cli-options": "./lib/cli-options.js",
61
- "./lib/cli-options.js": "./lib/cli-options.js",
62
- "./package.json": "./package.json"
63
- },
64
- scripts: {
65
- "dts-check": "tsc --project tests/types/tsconfig.json",
66
- lint: "standard",
67
- pretest: "npm run lint && npm run dts-check",
68
- test: "tap run --allow-empty-coverage --disable-coverage --timeout=60000",
69
- "test:coverage": "tap run --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",
70
- prerelease: "npm test",
71
- release: "standard-version"
72
- },
73
- repository: {
74
- type: "git",
75
- url: "git://github.com/motdotla/dotenv.git"
76
- },
77
- homepage: "https://github.com/motdotla/dotenv#readme",
78
- funding: "https://dotenvx.com",
79
- keywords: [
80
- "dotenv",
81
- "env",
82
- ".env",
83
- "environment",
84
- "variables",
85
- "config",
86
- "settings"
87
- ],
88
- readmeFilename: "README.md",
89
- license: "BSD-2-Clause",
90
- devDependencies: {
91
- "@types/node": "^18.11.3",
92
- decache: "^4.6.2",
93
- sinon: "^14.0.1",
94
- standard: "^17.0.0",
95
- "standard-version": "^9.5.0",
96
- tap: "^19.2.0",
97
- typescript: "^4.8.4"
98
- },
99
- engines: {
100
- node: ">=12"
101
- },
102
- browser: {
103
- fs: false
104
- }
105
- };
106
- }
107
- });
108
-
109
- // node_modules/dotenv/lib/main.js
110
- var require_main = __commonJS({
111
- "node_modules/dotenv/lib/main.js"(exports, module) {
112
- "use strict";
113
- var fs = __require("fs");
114
- var path = __require("path");
115
- var os = __require("os");
116
- var crypto = __require("crypto");
117
- var packageJson = require_package();
118
- var version = packageJson.version;
119
- var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
120
- function parse(src) {
121
- const obj = {};
122
- let lines = src.toString();
123
- lines = lines.replace(/\r\n?/mg, "\n");
124
- let match;
125
- while ((match = LINE.exec(lines)) != null) {
126
- const key = match[1];
127
- let value = match[2] || "";
128
- value = value.trim();
129
- const maybeQuote = value[0];
130
- value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
131
- if (maybeQuote === '"') {
132
- value = value.replace(/\\n/g, "\n");
133
- value = value.replace(/\\r/g, "\r");
134
- }
135
- obj[key] = value;
136
- }
137
- return obj;
138
- }
139
- function _parseVault(options) {
140
- options = options || {};
141
- const vaultPath = _vaultPath(options);
142
- options.path = vaultPath;
143
- const result = DotenvModule.configDotenv(options);
144
- if (!result.parsed) {
145
- const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
146
- err.code = "MISSING_DATA";
147
- throw err;
148
- }
149
- const keys = _dotenvKey(options).split(",");
150
- const length = keys.length;
151
- let decrypted;
152
- for (let i = 0; i < length; i++) {
153
- try {
154
- const key = keys[i].trim();
155
- const attrs = _instructions(result, key);
156
- decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
157
- break;
158
- } catch (error) {
159
- if (i + 1 >= length) {
160
- throw error;
161
- }
162
- }
163
- }
164
- return DotenvModule.parse(decrypted);
165
- }
166
- function _warn(message) {
167
- console.log(`[dotenv@${version}][WARN] ${message}`);
168
- }
169
- function _debug(message) {
170
- console.log(`[dotenv@${version}][DEBUG] ${message}`);
171
- }
172
- function _log(message) {
173
- console.log(`[dotenv@${version}] ${message}`);
174
- }
175
- function _dotenvKey(options) {
176
- if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
177
- return options.DOTENV_KEY;
178
- }
179
- if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
180
- return process.env.DOTENV_KEY;
181
- }
182
- return "";
183
- }
184
- function _instructions(result, dotenvKey) {
185
- let uri;
186
- try {
187
- uri = new URL(dotenvKey);
188
- } catch (error) {
189
- if (error.code === "ERR_INVALID_URL") {
190
- const err = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
191
- err.code = "INVALID_DOTENV_KEY";
192
- throw err;
193
- }
194
- throw error;
195
- }
196
- const key = uri.password;
197
- if (!key) {
198
- const err = new Error("INVALID_DOTENV_KEY: Missing key part");
199
- err.code = "INVALID_DOTENV_KEY";
200
- throw err;
201
- }
202
- const environment = uri.searchParams.get("environment");
203
- if (!environment) {
204
- const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
205
- err.code = "INVALID_DOTENV_KEY";
206
- throw err;
207
- }
208
- const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
209
- const ciphertext = result.parsed[environmentKey];
210
- if (!ciphertext) {
211
- const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
212
- err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
213
- throw err;
214
- }
215
- return { ciphertext, key };
216
- }
217
- function _vaultPath(options) {
218
- let possibleVaultPath = null;
219
- if (options && options.path && options.path.length > 0) {
220
- if (Array.isArray(options.path)) {
221
- for (const filepath of options.path) {
222
- if (fs.existsSync(filepath)) {
223
- possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
224
- }
225
- }
226
- } else {
227
- possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
228
- }
229
- } else {
230
- possibleVaultPath = path.resolve(process.cwd(), ".env.vault");
231
- }
232
- if (fs.existsSync(possibleVaultPath)) {
233
- return possibleVaultPath;
234
- }
235
- return null;
236
- }
237
- function _resolveHome(envPath) {
238
- return envPath[0] === "~" ? path.join(os.homedir(), envPath.slice(1)) : envPath;
239
- }
240
- function _configVault(options) {
241
- const debug = Boolean(options && options.debug);
242
- const quiet = options && "quiet" in options ? options.quiet : true;
243
- if (debug || !quiet) {
244
- _log("Loading env from encrypted .env.vault");
245
- }
246
- const parsed = DotenvModule._parseVault(options);
247
- let processEnv = process.env;
248
- if (options && options.processEnv != null) {
249
- processEnv = options.processEnv;
250
- }
251
- DotenvModule.populate(processEnv, parsed, options);
252
- return { parsed };
253
- }
254
- function configDotenv(options) {
255
- const dotenvPath = path.resolve(process.cwd(), ".env");
256
- let encoding = "utf8";
257
- const debug = Boolean(options && options.debug);
258
- const quiet = options && "quiet" in options ? options.quiet : true;
259
- if (options && options.encoding) {
260
- encoding = options.encoding;
261
- } else {
262
- if (debug) {
263
- _debug("No encoding is specified. UTF-8 is used by default");
264
- }
265
- }
266
- let optionPaths = [dotenvPath];
267
- if (options && options.path) {
268
- if (!Array.isArray(options.path)) {
269
- optionPaths = [_resolveHome(options.path)];
270
- } else {
271
- optionPaths = [];
272
- for (const filepath of options.path) {
273
- optionPaths.push(_resolveHome(filepath));
274
- }
275
- }
276
- }
277
- let lastError;
278
- const parsedAll = {};
279
- for (const path2 of optionPaths) {
280
- try {
281
- const parsed = DotenvModule.parse(fs.readFileSync(path2, { encoding }));
282
- DotenvModule.populate(parsedAll, parsed, options);
283
- } catch (e) {
284
- if (debug) {
285
- _debug(`Failed to load ${path2} ${e.message}`);
286
- }
287
- lastError = e;
288
- }
289
- }
290
- let processEnv = process.env;
291
- if (options && options.processEnv != null) {
292
- processEnv = options.processEnv;
293
- }
294
- DotenvModule.populate(processEnv, parsedAll, options);
295
- if (debug || !quiet) {
296
- const keysCount = Object.keys(parsedAll).length;
297
- const shortPaths = [];
298
- for (const filePath of optionPaths) {
299
- try {
300
- const relative = path.relative(process.cwd(), filePath);
301
- shortPaths.push(relative);
302
- } catch (e) {
303
- if (debug) {
304
- _debug(`Failed to load ${filePath} ${e.message}`);
305
- }
306
- lastError = e;
307
- }
308
- }
309
- _log(`injecting env (${keysCount}) from ${shortPaths.join(",")}`);
310
- }
311
- if (lastError) {
312
- return { parsed: parsedAll, error: lastError };
313
- } else {
314
- return { parsed: parsedAll };
315
- }
316
- }
317
- function config(options) {
318
- if (_dotenvKey(options).length === 0) {
319
- return DotenvModule.configDotenv(options);
320
- }
321
- const vaultPath = _vaultPath(options);
322
- if (!vaultPath) {
323
- _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
324
- return DotenvModule.configDotenv(options);
325
- }
326
- return DotenvModule._configVault(options);
327
- }
328
- function decrypt(encrypted, keyStr) {
329
- const key = Buffer.from(keyStr.slice(-64), "hex");
330
- let ciphertext = Buffer.from(encrypted, "base64");
331
- const nonce = ciphertext.subarray(0, 12);
332
- const authTag = ciphertext.subarray(-16);
333
- ciphertext = ciphertext.subarray(12, -16);
334
- try {
335
- const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
336
- aesgcm.setAuthTag(authTag);
337
- return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
338
- } catch (error) {
339
- const isRange = error instanceof RangeError;
340
- const invalidKeyLength = error.message === "Invalid key length";
341
- const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
342
- if (isRange || invalidKeyLength) {
343
- const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
344
- err.code = "INVALID_DOTENV_KEY";
345
- throw err;
346
- } else if (decryptionFailed) {
347
- const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
348
- err.code = "DECRYPTION_FAILED";
349
- throw err;
350
- } else {
351
- throw error;
352
- }
353
- }
354
- }
355
- function populate(processEnv, parsed, options = {}) {
356
- const debug = Boolean(options && options.debug);
357
- const override = Boolean(options && options.override);
358
- if (typeof parsed !== "object") {
359
- const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
360
- err.code = "OBJECT_REQUIRED";
361
- throw err;
362
- }
363
- for (const key of Object.keys(parsed)) {
364
- if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
365
- if (override === true) {
366
- processEnv[key] = parsed[key];
367
- }
368
- if (debug) {
369
- if (override === true) {
370
- _debug(`"${key}" is already defined and WAS overwritten`);
371
- } else {
372
- _debug(`"${key}" is already defined and was NOT overwritten`);
373
- }
374
- }
375
- } else {
376
- processEnv[key] = parsed[key];
377
- }
378
- }
379
- }
380
- var DotenvModule = {
381
- configDotenv,
382
- _configVault,
383
- _parseVault,
384
- config,
385
- decrypt,
386
- parse,
387
- populate
388
- };
389
- module.exports.configDotenv = DotenvModule.configDotenv;
390
- module.exports._configVault = DotenvModule._configVault;
391
- module.exports._parseVault = DotenvModule._parseVault;
392
- module.exports.config = DotenvModule.config;
393
- module.exports.decrypt = DotenvModule.decrypt;
394
- module.exports.parse = DotenvModule.parse;
395
- module.exports.populate = DotenvModule.populate;
396
- module.exports = DotenvModule;
397
- }
398
- });
399
-
400
- // src/structures/Collection.ts
401
- var Collection = class _Collection extends Map {
402
- constructor(key, data) {
403
- super();
404
- __publicField(this, "key");
405
- this.key = key;
406
- if (data && Array.isArray(data) && key) {
407
- if (data.length > 0) return;
408
- for (let v of data) this.set(key, v);
409
- }
410
- }
411
- at(index) {
412
- if (index < 0 || index >= this.size) {
413
- return void 0;
414
- }
415
- let i = 0;
416
- for (let [, value] of this) {
417
- if (i === index) {
418
- return value;
419
- }
420
- i++;
421
- }
422
- }
423
- has(key) {
424
- return this.get(key) !== void 0 ? true : false;
425
- }
426
- get first() {
427
- return this.values().next().value;
428
- }
429
- get last() {
430
- return [...this.values()].at(-1);
431
- }
432
- get length() {
433
- return this.toArray().length;
434
- }
435
- find(predicate) {
436
- for (const [key, value] of this) {
437
- if (predicate(value, key, this)) return value;
438
- }
439
- return void 0;
440
- }
441
- filter(predicate) {
442
- const results = new _Collection(this.key, []);
443
- for (const [key, value] of this) {
444
- if (predicate(value, key, this)) results.set(key, value);
445
- }
446
- return results;
447
- }
448
- some(predicate) {
449
- const results = new _Collection(this.key, []);
450
- for (const [key, value] of this) {
451
- if (predicate(value, key, this)) results.set(key, value);
452
- }
453
- return results;
454
- }
455
- map(callback) {
456
- return [...this].map(([key, val]) => callback(val, key, this));
457
- }
458
- toArray() {
459
- return [...this.values()];
460
- }
461
- toJSON() {
462
- let obj = {};
463
- for (let [k, v] of this.entries()) {
464
- obj[`${k}`] = v;
465
- }
466
- return obj;
467
- }
468
- sort(compareFunction) {
469
- const sortedEntries = [...this.entries()].sort((ab, ba) => {
470
- return compareFunction(ab[1], ba[1], this);
471
- });
472
- const coll = new _Collection();
473
- for (let [k, v] of sortedEntries) coll.set(k, v);
474
- return coll;
475
- }
476
- toString() {
477
- return `${this.size}`;
478
- }
479
- };
480
-
481
- // src/managers/base.ts
482
- var BaseManager = class {
483
- constructor(guild) {
484
- /** This url of the manager */
485
- __publicField(this, "base_url");
486
- /** The rest client */
487
- __publicField(this, "rest");
488
- /** The guild of the manager */
489
- __publicField(this, "guild");
490
- /** Cache */
491
- __publicField(this, "cache");
492
- this.guild = guild;
493
- this.rest = guild.rest;
494
- this.cache = new Collection();
495
- }
496
- toJSON() {
497
- return [...this.cache.values()].map((m) => m && "toJSON" in m && typeof m.toJSON === "function" ? m.toJSON() : m);
498
- }
499
- };
500
-
501
- // src/rest/Routes.ts
502
- var Routes = {
503
- base: "http://localhost:80/api/v1",
504
- //base: "https://duqueapi.shardweb.app/api/v1",
505
- field: (field) => `/${field}`,
506
- fields: (...fields) => `${fields.join("/")}`,
507
- guilds: {
508
- create: () => `/guilds`,
509
- get: (guildId) => `/guilds/${guildId}`,
510
- getAll: () => `/guilds`,
511
- delete: (guildId) => `/guilds/${guildId}`,
512
- deleteAll: () => `/guilds`,
513
- resource: (guildId, ...resources) => `/guilds/${guildId}/manage/${resources.join("/")}`,
514
- resources: (guildId, ...resources) => `/guilds/${guildId}/manage/${resources.join("/")}`,
515
- users: {
516
- create: (guildId) => `/guilds/${guildId}/users`,
517
- update: (guildId, userId) => `/guilds/${guildId}/users/${userId}`,
518
- getAll: (guildId) => `/guilds/${guildId}/users`,
519
- get: (guildId, userId) => `/guilds/${guildId}/users/${userId}`,
520
- delete: (guildId, userId) => `/guilds/${guildId}/users/${userId}`,
521
- deleteAll: (guildId) => `/guilds/${guildId}/users`,
522
- resource: (guildId, userId, ...resource) => `/guilds/${guildId}/users/${userId}/${resource.join("/")}`
523
- },
524
- betusers: {
525
- getAll: (guildId) => `/guilds/${guildId}/betusers`,
526
- get: (guildId, userId) => `/guilds/${guildId}/betusers/${userId}`,
527
- create: (guildId) => `/guilds/${guildId}/betusers`,
528
- update: (guildId, userId) => `/guilds/${guildId}/betusers/${userId}`,
529
- delete: (guildId, userId) => `/guilds/${guildId}/betusers/${userId}`,
530
- deleteAll: (guildId) => `/guilds/${guildId}/betusers`,
531
- resource: (guildId, userId, resourceName) => `/guilds/${guildId}/betusers/${userId}/${resourceName}`
532
- },
533
- matches: {
534
- getAll: (guildId) => `/guilds/${guildId}/matches`,
535
- get: (guildId, matchId) => `/guilds/${guildId}/matches/${matchId}`,
536
- create: (guildId) => `/guilds/${guildId}/matches`,
537
- update: (guildId, matchId) => `/guilds/${guildId}/matches/${matchId}`,
538
- delete: (guildId, matchId) => `/guilds/${guildId}/matches/${matchId}`,
539
- deleteAll: (guildId) => `/guilds/${guildId}/matches`,
540
- resource: (guildId, matchId, ...resources) => `/guilds/${guildId}/matches/${matchId}/${resources.join("/")}`
541
- },
542
- bets: {
543
- getAll: (guildId) => `/guilds/${guildId}/bets`,
544
- get: (guildId, betId) => `/guilds/${guildId}/bets/${betId}`,
545
- create: (guildId) => `/guilds/${guildId}/bets`,
546
- update: (guildId, betId) => `/guilds/${guildId}/bets/${betId}`,
547
- delete: (guildId, betId) => `/guilds/${guildId}/bets/${betId}`,
548
- deleteAll: (guildId) => `/guilds/${guildId}/bets`,
549
- resource: (guildId, betId, ...resources) => `/guilds/${guildId}/bets/${betId}/${resources.join("/")}`
550
- },
551
- tickets: {
552
- getAll: (guildId) => `/guilds/${guildId}/tickets`,
553
- get: (guildId, ticketId) => `/guilds/${guildId}/tickets/${ticketId}`,
554
- create: (guildId) => `/guilds/${guildId}/tickets`,
555
- update: (guildId, ticketId) => `/guilds/${guildId}/tickets/${ticketId}`,
556
- delete: (guildId, ticketId) => `/guilds/${guildId}/tickets/${ticketId}`,
557
- deleteAll: (guildId) => `/guilds/${guildId}/tickets`,
558
- resource: (guildId, ticketId, ...resources) => `/guilds/${guildId}/tickets/${ticketId}/${resources.join("/")}`
559
- },
560
- mediators: {
561
- getAll: (guildId) => `/guilds/${guildId}/mediators`,
562
- get: (guildId, mediatorId) => `/guilds/${guildId}/mediators/${mediatorId}`,
563
- create: (guildId) => `/guilds/${guildId}/mediators`,
564
- update: (guildId, mediatorId) => `/guilds/${guildId}/mediators/${mediatorId}`,
565
- delete: (guildId, mediatorId) => `/guilds/${guildId}/mediators/${mediatorId}`,
566
- deleteAll: (guildId) => `/guilds/${guildId}/mediators`,
567
- resource: (guildId, mediatorId, ...resources) => `/guilds/${guildId}/mediators/${mediatorId}/${resources.join("/")}`
568
- },
569
- shop: {
570
- get: (guildId) => `/guilds/${guildId}/manage/shop`,
571
- update: (guildId) => `/guilds/${guildId}/manage/shop`,
572
- delete: (guildId) => `/guilds/${guildId}/manage/shop/ `,
573
- resource: (guildId, ...resources) => `/guilds/${guildId}/manage/shop/${resources.join("/")}`,
574
- products: {
575
- getAll: (guildId) => `/guilds/${guildId}/manage/shop/products`,
576
- get: (guildId, productId) => `/guilds/${guildId}/manage/shop/${productId}/products`,
577
- create: (guildId) => `/guilds/${guildId}/manage/shop/products`,
578
- update: (guildId, productId) => `/guilds/${guildId}/manage/shop/products/${productId}`,
579
- delete: (guildId, productId) => `/guilds/${guildId}/manage/shop/products/${productId}`,
580
- deleteAll: (guildId) => `/guilds/${guildId}/products/shop`,
581
- resource: (guildId, productId, ...resources) => `/guilds/${guildId}/manage/shop/products/${productId}/${resources.join("/")}`
582
- }
583
- }
584
- },
585
- vipmembers: {
586
- get: (guildId, memberId) => `/guilds/${guildId}/vipmembers/${memberId}`,
587
- getAll: (guildId) => `/guilds/${guildId}/vipmembers`,
588
- deleteAll: (guildId) => `/guilds/${guildId}/vipmembers`,
589
- create: (guildId) => `/guilds/${guildId}/vipmembers`,
590
- update: (guildId, memberId) => `/guilds/${guildId}/vipmembers/${memberId}`,
591
- delete: (guildId, memberId) => `/guilds/${guildId}/vipmembers/${memberId}`
592
- },
593
- giveaways: {
594
- get: (giveawayId) => `/giveaways/${giveawayId}`,
595
- getAll: () => `/giveaways`,
596
- deleteAll: () => `/giveaways`,
597
- create: () => `/giveaways`,
598
- update: (giveawayId) => `/giveaways/${giveawayId}`,
599
- delete: (giveawayId) => `/giveaways/${giveawayId}`
600
- }
601
- };
602
-
603
- // src/rest/REST.ts
604
- var import_dotenv = __toESM(require_main());
605
-
606
- // src/utils/Assertion.ts
607
- var Assertion = class {
608
- constructor() {
609
- }
610
- /**
611
- * Tests if given key is a string
612
- * @param key Key to test
613
- */
614
- static assertString(key) {
615
- if (typeof key !== "string") throw new Error(`${key} must be a string`);
616
- if (!key || key === "") throw new Error(`${key} must be a string`);
617
- return true;
618
- }
619
- /**
620
- * Tests if given key is a number
621
- * @param key Key to test
622
- */
623
- static assertNumber(key) {
624
- if (typeof key !== "number") throw new Error(`${key} must be a number`);
625
- return true;
626
- }
627
- /**
628
- * Tests if given key is a boolean
629
- * @param key Key to test
630
- */
631
- static assertBoolean(key) {
632
- if (typeof key !== "boolean") throw new Error(`${key} must be a boolean`);
633
- return true;
634
- }
635
- /**
636
- * Tests if given key is an array
637
- * @param key Key to test
638
- */
639
- static assertArray(key) {
640
- if (!Array.isArray(key)) throw new Error(`${key} must be an array`);
641
- return true;
642
- }
643
- /**
644
- * Tests if given key is an object
645
- * @param key Key to test
646
- */
647
- static assertObject(key) {
648
- if (typeof key !== "object") throw new Error(`${key} must be an object`);
649
- return true;
650
- }
651
- toString() {
652
- return "string, number, boolean, array, object";
653
- }
654
- };
655
-
656
- // src/rest/REST.ts
657
- import { request, Headers } from "undici";
658
-
659
- // src/structures/betuser/GuildBetUser.ts
660
- var _GuildBetUser_instances, updateInternals_fn;
661
- var _GuildBetUser = class _GuildBetUser {
662
- /**
663
- * Bet user
664
- * @param data The user's data
665
- * @param manager The manager
666
- * @param rest The rest client
667
- */
668
- constructor(data, manager) {
669
- __privateAdd(this, _GuildBetUser_instances);
670
- /** User daily */
671
- __publicField(this, "daily");
672
- __publicField(this, "profile");
673
- /** User's name */
674
- __publicField(this, "id");
675
- __publicField(this, "guild_id");
676
- /** User's credit */
677
- __publicField(this, "credit");
678
- /** User's wins */
679
- __publicField(this, "wins");
680
- /** User's mvps */
681
- __publicField(this, "mvps");
682
- /** User's losses */
683
- __publicField(this, "losses");
684
- /** User's games */
685
- __publicField(this, "games");
686
- /** User's blacklist */
687
- __publicField(this, "blacklist");
688
- /** User's coins */
689
- __publicField(this, "coins");
690
- __publicField(this, "spins");
691
- /** Creation Date */
692
- __publicField(this, "createdAt");
693
- /** Updated Date */
694
- __publicField(this, "updatedAt");
695
- __publicField(this, "consecutive_wins");
696
- /** The given manager */
697
- __publicField(this, "manager");
698
- /** The rest client */
699
- __publicField(this, "rest");
700
- __publicField(this, "guild");
701
- this.id = data?.id;
702
- this.guild_id = data?.guild_id;
703
- this.manager = manager;
704
- this.rest = manager.rest;
705
- this.guild = manager.guild;
706
- this.wins = data?.wins;
707
- this.coins = data?.coins;
708
- this.losses = data?.losses;
709
- this.credit = data?.credit;
710
- this.spins = data?.spins;
711
- this.daily = data?.daily;
712
- this.games = data?.games;
713
- this.blacklist = data?.blacklist;
714
- this.consecutive_wins = data?.consecutive_wins;
715
- this.profile = data?.profile;
716
- this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
717
- this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
718
- }
719
- /** String representation of this user */
720
- toString() {
721
- return `<@${this.id}>`;
722
- }
723
- /**
724
- * Fetches the user
725
- * @returns New Instance of the user
726
- */
727
- async fetch() {
728
- const route = Routes.guilds.betusers.get(this.manager.guild.id, this.id);
729
- const response = await this.rest.request({
730
- method: "get",
731
- url: route
732
- });
733
- const user = new _GuildBetUser(response, this.manager);
734
- this.manager.cache.set(user.id, user);
735
- this.rest.betusers.set(user.id, user);
736
- return user;
737
- }
738
- /**
739
- * Set the user blacklist
740
- * @param value Value to set to
741
- * @returns GuildBetUser
742
- */
743
- async setBlacklist(value) {
744
- const route = Routes.guilds.betusers.resource(this.manager.guild.id, this.id, "blacklist");
745
- const payload = { set: value };
746
- await this.rest.request({
747
- method: "patch",
748
- url: route,
749
- payload
750
- });
751
- this.blacklist = value;
752
- this.manager.cache.set(this.id, this);
753
- this.rest.betusers.set(this.id, this);
754
- return this;
755
- }
756
- async reset() {
757
- const route = Routes.guilds.betusers.get(this.manager.guild.id, this.id);
758
- const payload = { reset: true };
759
- const response = await this.rest.request({
760
- method: "DELETE",
761
- url: route,
762
- payload
763
- });
764
- return __privateMethod(this, _GuildBetUser_instances, updateInternals_fn).call(this, response);
765
- }
766
- async updateProfile(data) {
767
- const _data = {
768
- profile: {
769
- avatarUrl: data.avatarUrl || this.profile.avatarUrl || "",
770
- bannerUrl: data.bannerUrl || this.profile.bannerUrl || "",
771
- bio: data.bio || this.profile.bio || "Melhor da minha aldeia (use !bio para alterar)",
772
- name: data.name || this.profile.name || "",
773
- textColor: data.textColor || this.profile.textColor || "#ffffff",
774
- primaryColor: data.primaryColor || this.profile.primaryColor || "#272727",
775
- secondaryColor: data.secondaryColor || this.profile.secondaryColor || "#151515"
776
- }
777
- };
778
- const route = Routes.guilds.betusers.update(this.manager.guild.id, this.id);
779
- const response = await this.rest.request({
780
- method: "patch",
781
- url: route,
782
- payload: _data
783
- });
784
- return __privateMethod(this, _GuildBetUser_instances, updateInternals_fn).call(this, response);
785
- }
786
- /**
787
- * Update certain property
788
- * @param data The new data to update with
789
- * @returns
790
- */
791
- async update(data) {
792
- if (!data?.type) data.type = "add";
793
- const route = Routes.guilds.betusers.get(this.manager.guild.id, this.id);
794
- let payload = {};
795
- const numericFields = ["wins", "credit", "losses", "mvps", "games", "coins", "spins", "consecutive_wins"];
796
- const arrayFields = ["items", "original_channels", "adverts", "accessories"];
797
- if (data?.type === "add" || data?.type === "remove") {
798
- for (const key in data) {
799
- if (key === "type") continue;
800
- const value = data[key];
801
- if (numericFields.includes(key)) {
802
- const current = this[key] || 0;
803
- const num = value || 0;
804
- payload[key] = Math.max(0, data?.type === "add" ? current + num : current - num);
805
- } else if (key === "blacklist") {
806
- payload["blacklist"] = value;
807
- } else if (key === "profile") {
808
- payload["profile"] = value;
809
- } else if (arrayFields.includes(key)) {
810
- const current = this[key];
811
- const incoming = value;
812
- payload[key] = data?.type === "add" ? [.../* @__PURE__ */ new Set([...current, ...incoming])] : current.filter((x) => !incoming.includes(x));
813
- }
814
- }
815
- }
816
- const response = await this.rest.request({
817
- method: "patch",
818
- url: route,
819
- payload
820
- });
821
- return __privateMethod(this, _GuildBetUser_instances, updateInternals_fn).call(this, response);
822
- }
823
- async _update(data) {
824
- const route = Routes.guilds.betusers.get(this.manager.guild.id, this.id);
825
- let payload = {};
826
- const response = await this.rest.request({
827
- method: "put",
828
- url: route,
829
- payload
830
- });
831
- return __privateMethod(this, _GuildBetUser_instances, updateInternals_fn).call(this, response);
832
- }
833
- async delete() {
834
- const route = Routes.guilds.betusers.delete(this.manager.guild.id, this.id);
835
- const response = await this.rest.request({
836
- method: "DELETE",
837
- url: route
838
- });
839
- this.rest.emit("betuserDelete", this);
840
- this.manager.cache.delete(this.id);
841
- return response;
842
- }
843
- toJSON() {
844
- let json = {};
845
- for (const [key, value] of Object.entries(this)) {
846
- const exclude = ["rest", "guilds", "guild", "manager"];
847
- if (exclude.includes(key)) continue;
848
- if (typeof value !== "function") {
849
- json[key] = value;
850
- }
851
- }
852
- return json;
853
- }
854
- };
855
- _GuildBetUser_instances = new WeakSet();
856
- updateInternals_fn = function(data) {
857
- for (let key in data) {
858
- if (key === "id" || key === "createdAt") continue;
859
- if (key in this) {
860
- this[key] = data[key];
861
- }
862
- }
863
- this.updatedAt = /* @__PURE__ */ new Date();
864
- this.createdAt = new Date(data.createdAt);
865
- this.manager.set(this);
866
- this.rest.emit("betuserUpdate", this);
867
- return this;
868
- };
869
- var GuildBetUser = _GuildBetUser;
870
-
871
- // src/managers/betuser/GuildBetUserManager.ts
872
- var GuildBetUserManager = class extends BaseManager {
873
- constructor(guild) {
874
- super(guild);
875
- this.guild = guild;
876
- this.rest = guild.rest;
877
- this.base_url = Routes.guilds.betusers.getAll(guild.id);
878
- this.cache = new Collection("betusers");
879
- }
880
- async fetch(options) {
881
- if (options && options.cache) return this.cache;
882
- if (options && options.userId) {
883
- const route2 = Routes.fields(this.base_url, options.userId);
884
- const response2 = await this.rest.request({
885
- method: "GET",
886
- url: route2
887
- });
888
- const user = new GuildBetUser(response2, this);
889
- this.set(user);
890
- return user;
891
- }
892
- const route = this.base_url;
893
- const response = await this.rest.request({
894
- method: "GET",
895
- url: route
896
- });
897
- this.set(response);
898
- return this.cache;
899
- }
900
- async updateMany(...betusers) {
901
- const route = this.base_url;
902
- const response = await this.rest.request({
903
- method: "PATCH",
904
- url: route,
905
- payload: { betusers }
906
- });
907
- return this.set(response);
908
- }
909
- async deleteAll() {
910
- const route = this.base_url;
911
- await this.rest.request({
912
- method: "DELETE",
913
- url: route
914
- });
915
- this.cache.clear();
916
- }
917
- async resetAll() {
918
- const route = this.base_url;
919
- const response = await this.rest.request({
920
- method: "put",
921
- url: route
922
- });
923
- this.cache.clear();
924
- return this.set(response);
925
- }
926
- set(data) {
927
- if (!data) return this.cache;
928
- if (Array.isArray(data)) {
929
- for (let _user of data) {
930
- if (!_user.id) return;
931
- const user = new GuildBetUser(_user, this);
932
- this.cache.set(user.id, user);
933
- this.rest.betusers.set(user.id, user);
934
- }
935
- return this.cache;
936
- } else {
937
- if (!data.id) return;
938
- const user = new GuildBetUser(data, this);
939
- this.cache.set(user.id, user);
940
- this.rest.betusers.set(user.id, user);
941
- return user;
942
- }
943
- }
944
- };
945
-
946
- // src/structures/mediator/GuildMediator.ts
947
- var _GuildMediator_instances, updateInternals_fn2;
948
- var _GuildMediator = class _GuildMediator {
949
- /**
950
- * Bet user
951
- * @param data The user's data
952
- * @param manager The manager
953
- * @param rest The rest client
954
- */
955
- constructor(data, manager) {
956
- __privateAdd(this, _GuildMediator_instances);
957
- /** User's name */
958
- __publicField(this, "id");
959
- __publicField(this, "guild_id");
960
- /** User's games */
961
- __publicField(this, "games");
962
- __publicField(this, "paypal");
963
- __publicField(this, "revolut");
964
- __publicField(this, "mbway");
965
- __publicField(this, "external_links");
966
- /** Creation Date */
967
- __publicField(this, "createdAt");
968
- /** Updated Date */
969
- __publicField(this, "updatedAt");
970
- /** The given manager */
971
- __publicField(this, "manager");
972
- /** The rest client */
973
- __publicField(this, "rest");
974
- __publicField(this, "guild");
975
- this.id = data?.id;
976
- this.guild_id = data?.guild_id;
977
- this.manager = manager;
978
- this.rest = manager.rest;
979
- this.guild = manager.guild;
980
- this.games = data?.games;
981
- this.paypal = data?.paypal;
982
- this.revolut = data?.revolut;
983
- this.mbway = data?.mbway;
984
- this.external_links = data?.external_links;
985
- this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
986
- this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
987
- }
988
- /** String representation of this user */
989
- toString() {
990
- return `<@${this.id}>`;
991
- }
992
- /**
993
- * Fetches the user
994
- * @returns New Instance of the user
995
- */
996
- async fetch() {
997
- const route = Routes.guilds.mediators.get(this.manager.guild.id, this.id);
998
- const response = await this.rest.request({
999
- method: "get",
1000
- url: route
1001
- });
1002
- const user = new _GuildMediator(response, this.manager);
1003
- this.manager.cache.set(user.id, user);
1004
- this.rest.mediators.set(user.id, user);
1005
- return user;
1006
- }
1007
- async reset() {
1008
- const route = Routes.guilds.mediators.get(this.manager.guild.id, this.id);
1009
- const payload = { reset: true };
1010
- const response = await this.rest.request({
1011
- method: "DELETE",
1012
- url: route,
1013
- payload
1014
- });
1015
- return __privateMethod(this, _GuildMediator_instances, updateInternals_fn2).call(this, response);
1016
- }
1017
- /**
1018
- * Update certain property
1019
- * @param data The new data to update with
1020
- * @returns
1021
- */
1022
- async update(data) {
1023
- const route = Routes.guilds.mediators.get(this.manager.guild.id, this.id);
1024
- let payload = data;
1025
- const response = await this.rest.request({
1026
- method: "patch",
1027
- url: route,
1028
- payload
1029
- });
1030
- return __privateMethod(this, _GuildMediator_instances, updateInternals_fn2).call(this, response);
1031
- }
1032
- async setPaymentlink(type, link) {
1033
- const route = Routes.guilds.mediators.get(this.manager.guild.id, this.id);
1034
- let payload = { [type]: link };
1035
- const response = await this.rest.request({
1036
- method: "patch",
1037
- url: route,
1038
- payload
1039
- });
1040
- return __privateMethod(this, _GuildMediator_instances, updateInternals_fn2).call(this, response);
1041
- }
1042
- async delete() {
1043
- const route = Routes.guilds.mediators.delete(this.manager.guild.id, this.id);
1044
- const response = await this.rest.request({
1045
- method: "DELETE",
1046
- url: route
1047
- });
1048
- this.manager.cache.delete(this.id);
1049
- return response;
1050
- }
1051
- toJSON() {
1052
- let json = {};
1053
- for (const [key, value] of Object.entries(this)) {
1054
- const exclude = ["rest", "guilds", "guild", "manager"];
1055
- if (exclude.includes(key)) continue;
1056
- if (typeof value !== "function") {
1057
- json[key] = value;
1058
- }
1059
- }
1060
- return json;
1061
- }
1062
- };
1063
- _GuildMediator_instances = new WeakSet();
1064
- updateInternals_fn2 = function(data) {
1065
- for (let key in data) {
1066
- if (key === "id" || key === "createdAt") continue;
1067
- if (key in this) {
1068
- this[key] = data[key];
1069
- }
1070
- }
1071
- this.updatedAt = /* @__PURE__ */ new Date();
1072
- this.createdAt = new Date(data.createdAt);
1073
- this.manager.set(this);
1074
- return this;
1075
- };
1076
- var GuildMediator = _GuildMediator;
1077
-
1078
- // src/managers/mediator/GuildMediatorManager.ts
1079
- var GuildMediatorManager = class extends BaseManager {
1080
- constructor(guild) {
1081
- super(guild);
1082
- this.guild = guild;
1083
- this.rest = guild.rest;
1084
- this.base_url = Routes.guilds.mediators.getAll(guild.id);
1085
- this.cache = new Collection("mediators");
1086
- }
1087
- async fetch(options) {
1088
- if (options && options.cache) return this.cache;
1089
- if (options && options.mediatorId) {
1090
- const route2 = Routes.fields(this.base_url, options.mediatorId);
1091
- const response2 = await this.rest.request({
1092
- method: "GET",
1093
- url: route2
1094
- });
1095
- return this.set(response2);
1096
- }
1097
- const route = this.base_url;
1098
- const response = await this.rest.request({
1099
- method: "GET",
1100
- url: route
1101
- });
1102
- this.set(response);
1103
- return this.cache;
1104
- }
1105
- async updateMany(...mediators) {
1106
- const route = this.base_url;
1107
- const response = await this.rest.request({
1108
- method: "PATCH",
1109
- url: route,
1110
- payload: { mediators }
1111
- });
1112
- return this.set(response);
1113
- }
1114
- async create(payload) {
1115
- const route = Routes.guilds.mediators.create(this.guild.id);
1116
- const response = await this.rest.request({
1117
- method: "POST",
1118
- url: route,
1119
- payload
1120
- });
1121
- return this.set(response);
1122
- }
1123
- async deleteAll() {
1124
- const route = this.base_url;
1125
- await this.rest.request({
1126
- method: "DELETE",
1127
- url: route
1128
- });
1129
- this.cache.clear();
1130
- }
1131
- async resetAll() {
1132
- const route = this.base_url;
1133
- const response = await this.rest.request({
1134
- method: "put",
1135
- url: route
1136
- });
1137
- this.cache.clear();
1138
- this.set(response);
1139
- return this.cache;
1140
- }
1141
- set(data) {
1142
- if (!data) return this.cache;
1143
- if (Array.isArray(data)) {
1144
- for (let _mediator of data) {
1145
- if (!_mediator.id) return;
1146
- const mediator = new GuildMediator(_mediator, this);
1147
- this.cache.set(mediator.id, mediator);
1148
- this.rest.mediators.set(mediator.id, mediator);
1149
- }
1150
- return this.cache;
1151
- } else {
1152
- if (!data.id) return;
1153
- const mediator = new GuildMediator(data, this);
1154
- this.cache.set(mediator.id, mediator);
1155
- this.rest.mediators.set(mediator.id, mediator);
1156
- return mediator;
1157
- }
1158
- }
1159
- };
1160
-
1161
- // src/structures/tournament/Tournament.ts
1162
- var _Tournament_instances, updateInternals_fn3;
1163
- var Tournament = class {
1164
- constructor(data, manager) {
1165
- __privateAdd(this, _Tournament_instances);
1166
- __publicField(this, "_id");
1167
- __publicField(this, "guild_id");
1168
- __publicField(this, "type");
1169
- __publicField(this, "max_teams");
1170
- __publicField(this, "teams");
1171
- __publicField(this, "message");
1172
- __publicField(this, "message_id");
1173
- __publicField(this, "status");
1174
- __publicField(this, "createdAt");
1175
- __publicField(this, "updatedAt");
1176
- __publicField(this, "guild");
1177
- __publicField(this, "rest");
1178
- __publicField(this, "manager");
1179
- __publicField(this, "data");
1180
- this.manager = manager;
1181
- this.guild = manager.guild;
1182
- this.rest = manager.rest;
1183
- this.guild_id = data?.guild_id;
1184
- this.type = data?.type;
1185
- this.teams = data?.teams;
1186
- this.message = data?.message;
1187
- this.message_id = data?.message_id;
1188
- this.status = data?.status;
1189
- this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
1190
- this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
1191
- this.data = data;
1192
- }
1193
- async fetch() {
1194
- const route = Routes.fields("guilds", this.guild.id, "tournaments", this._id);
1195
- const response = await this.rest.request({
1196
- method: "get",
1197
- url: route
1198
- });
1199
- return __privateMethod(this, _Tournament_instances, updateInternals_fn3).call(this, response);
1200
- }
1201
- async update(data) {
1202
- const route = Routes.fields("guilds", this.guild.id, "tournaments", this._id);
1203
- const response = await this.rest.request({
1204
- method: "patch",
1205
- url: route,
1206
- payload: data
1207
- });
1208
- return __privateMethod(this, _Tournament_instances, updateInternals_fn3).call(this, response);
1209
- }
1210
- toJSON() {
1211
- return {
1212
- guild_id: this.guild_id,
1213
- type: this.type,
1214
- max_teams: this.max_teams,
1215
- teams: this.teams,
1216
- message: this.message,
1217
- message_id: this.message_id,
1218
- status: this.status,
1219
- createdAt: this.createdAt ? new Date(this?.createdAt) : /* @__PURE__ */ new Date(),
1220
- updatedAt: this.updatedAt ? new Date(this?.updatedAt) : /* @__PURE__ */ new Date()
1221
- };
1222
- }
1223
- };
1224
- _Tournament_instances = new WeakSet();
1225
- updateInternals_fn3 = function(data) {
1226
- for (let key in data) {
1227
- if (key === "id" || key === "createdAt") continue;
1228
- if (key in this) {
1229
- this[key] = data[key];
1230
- }
1231
- }
1232
- this.updatedAt = /* @__PURE__ */ new Date();
1233
- this.createdAt = new Date(data.createdAt);
1234
- this.manager._add(this);
1235
- return this;
1236
- };
1237
-
1238
- // src/managers/tournament/TournamentManager.ts
1239
- var TournamentManager = class extends BaseManager {
1240
- constructor(guild) {
1241
- super(guild);
1242
- this.guild = guild;
1243
- this.rest = guild.rest;
1244
- this.base_url = Routes.guilds.resource(guild.id, "tournaments");
1245
- this.cache = new Collection();
1246
- }
1247
- async fetch(options) {
1248
- if (options && options.cache) return this.cache;
1249
- if (options && options.tournamentId) {
1250
- const response2 = await this.rest.request({
1251
- method: "GET",
1252
- url: Routes.fields(this.base_url, options.tournamentId)
1253
- });
1254
- const tournament = new Tournament(response2, this);
1255
- this._add(tournament);
1256
- return tournament;
1257
- }
1258
- const response = await this.rest.request({
1259
- method: "GET",
1260
- url: this.base_url
1261
- });
1262
- return this.set(response);
1263
- }
1264
- set(data) {
1265
- this.cache.clear();
1266
- if (Array.isArray(data)) {
1267
- for (let _m of data) {
1268
- if (!_m._id) continue;
1269
- if (_m instanceof Tournament) this.cache.set(_m._id, _m);
1270
- else this.cache.set(_m._id, new Tournament(_m, this));
1271
- }
1272
- } else {
1273
- if (!data._id) return this.cache;
1274
- if (data instanceof Tournament) this.cache.set(data._id, data);
1275
- else this.cache.set(data._id, new Tournament(data, this));
1276
- }
1277
- return this.cache;
1278
- }
1279
- _add(data) {
1280
- if (Array.isArray(data)) {
1281
- for (let _m of data) {
1282
- if (!_m._id) continue;
1283
- if (_m instanceof Tournament) this.cache.set(_m._id, _m);
1284
- else this.cache.set(_m._id, new Tournament(_m, this));
1285
- }
1286
- } else {
1287
- if (!data._id) return this.cache;
1288
- if (data instanceof Tournament) this.cache.set(data._id, data);
1289
- else this.cache.set(data._id, new Tournament(data, this));
1290
- }
1291
- return this.cache;
1292
- }
1293
- };
1294
-
1295
- // src/structures/guild/Guild.ts
1296
- var _Guild_instances, updateInternals_fn4;
1297
- var Guild2 = class {
1298
- /**
1299
- * The guild structure
1300
- * @param data The guild's data
1301
- * @param rest The rest client
1302
- */
1303
- constructor(data, rest) {
1304
- __privateAdd(this, _Guild_instances);
1305
- /** The data of this guild */
1306
- __publicField(this, "data");
1307
- /** The rest client */
1308
- __publicField(this, "rest");
1309
- /** The guild's id */
1310
- __publicField(this, "id");
1311
- __publicField(this, "modes");
1312
- /** Guild's client key */
1313
- __publicField(this, "client_key");
1314
- /** Guild Permissions */
1315
- __publicField(this, "permissions");
1316
- /** Guild Ticket */
1317
- __publicField(this, "tickets");
1318
- /** Guild Ticket Configuration */
1319
- __publicField(this, "tickets_configuration");
1320
- /** Guild Daily Categories */
1321
- __publicField(this, "daily_categories");
1322
- /** Guild Scores */
1323
- __publicField(this, "scores");
1324
- /** Guild Status */
1325
- __publicField(this, "status");
1326
- __publicField(this, "channels");
1327
- __publicField(this, "roulette_settings");
1328
- /** Guild Prefix */
1329
- __publicField(this, "prefix");
1330
- __publicField(this, "prefixes");
1331
- /** Guild Creation Date */
1332
- __publicField(this, "createdAt");
1333
- /** Guild Updated Date */
1334
- __publicField(this, "updatedAt");
1335
- /** Guild Matches */
1336
- __publicField(this, "matches");
1337
- /** Guild Prices Used */
1338
- __publicField(this, "prices");
1339
- __publicField(this, "permissionsManager");
1340
- __publicField(this, "buffer");
1341
- __publicField(this, "vipMembers");
1342
- __publicField(this, "users");
1343
- __publicField(this, "logEntries");
1344
- __publicField(this, "shop");
1345
- __publicField(this, "betusers");
1346
- __publicField(this, "bets");
1347
- __publicField(this, "mediators");
1348
- __publicField(this, "automatic_messages");
1349
- __publicField(this, "automaticMessagesManager");
1350
- __publicField(this, "tournaments");
1351
- __publicField(this, "adverts");
1352
- __publicField(this, "codes");
1353
- __publicField(this, "coin_symbol");
1354
- this.data = data;
1355
- this.rest = rest;
1356
- this.id = data?.id;
1357
- this.client_key = data?.client_key;
1358
- this.daily_categories = data?.daily_categories;
1359
- this.permissions = data?.permissions;
1360
- this.modes = data?.modes;
1361
- this.prices = data?.prices;
1362
- this.scores = data?.scores;
1363
- this.codes = data?.codes;
1364
- this.prefix = data?.prefix;
1365
- this.prefixes = data?.prefixes;
1366
- this.status = data?.status;
1367
- this.tickets_configuration = data?.tickets_configuration;
1368
- this.automatic_messages = data?.automatic_messages;
1369
- this.channels = data?.channels;
1370
- this.shop = data?.shop;
1371
- this.coin_symbol = data?.coin_symbol;
1372
- this.roulette_settings = data?.roulette_settings;
1373
- this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
1374
- this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
1375
- this.permissionsManager = new GuildPermissionManager(this);
1376
- this.buffer = new BufferManager(this);
1377
- this.users = new GuildUserManager(this);
1378
- this.matches = new GuildMatchManager(this);
1379
- this.tickets = new GuildTicketManager(this);
1380
- this.vipMembers = new VipMemberManager(this);
1381
- this.logEntries = new LogManager(this);
1382
- this.betusers = new GuildBetUserManager(this);
1383
- this.bets = new GuildBetManager(this);
1384
- this.mediators = new GuildMediatorManager(this);
1385
- this.automaticMessagesManager = new AutomaticMessageManager(this);
1386
- this.tournaments = new TournamentManager(this);
1387
- this.adverts = [];
1388
- for (let _adv of data?.adverts || []) {
1389
- this.adverts.push({
1390
- _id: _adv._id,
1391
- admin_id: _adv.admin_id,
1392
- points_to_remove: _adv.points_to_remove,
1393
- role_id: _adv.role_id,
1394
- createdAt: _adv.createdAt ? new Date(_adv.createdAt) : /* @__PURE__ */ new Date(),
1395
- updatedAt: _adv.updatedAt ? new Date(_adv.updatedAt) : /* @__PURE__ */ new Date()
1396
- });
1397
- }
1398
- this.codes = [];
1399
- for (let _adv of data?.codes || []) {
1400
- this.codes.push({
1401
- _id: _adv._id,
1402
- admin_id: _adv.admin_id,
1403
- type: _adv.type,
1404
- add: _adv.add,
1405
- code: _adv.code,
1406
- expire: _adv.expire ? new Date(_adv.expire) : /* @__PURE__ */ new Date(),
1407
- createdAt: _adv.createdAt ? new Date(_adv.createdAt) : /* @__PURE__ */ new Date(),
1408
- updatedAt: _adv.updatedAt ? new Date(_adv.updatedAt) : /* @__PURE__ */ new Date()
1409
- });
1410
- }
1411
- }
1412
- async getChannel(type) {
1413
- const channel = this.channels.find((c) => c.type === type);
1414
- if (channel) return channel;
1415
- else {
1416
- const channels = [...this.channels, { type, ids: [] }];
1417
- const route = Routes.guilds.get(this.id);
1418
- const response = await this.rest.request({
1419
- method: "PATCH",
1420
- url: route,
1421
- payload: { channels }
1422
- });
1423
- __privateMethod(this, _Guild_instances, updateInternals_fn4).call(this, response);
1424
- return response.channels.find((t) => t.type === type);
1425
- }
1426
- }
1427
- async getPermission(type) {
1428
- const permission = this.permissions.find((c) => c.type === type);
1429
- if (permission) return permission;
1430
- else {
1431
- const permissions = [...this.permissions, { type, ids: [] }];
1432
- const route = Routes.guilds.get(this.id);
1433
- const response = await this.rest.request({
1434
- method: "PATCH",
1435
- url: route,
1436
- payload: { permissions }
1437
- });
1438
- __privateMethod(this, _Guild_instances, updateInternals_fn4).call(this, response);
1439
- return response.permissions.find((t) => t.type === type);
1440
- }
1441
- }
1442
- async createAdvert(data) {
1443
- this.adverts.push(data);
1444
- const route = Routes.guilds.get(this.id);
1445
- const payload = { adverts: this.adverts };
1446
- const response = await this.rest.request({ method: "PATCH", url: route, payload });
1447
- return __privateMethod(this, _Guild_instances, updateInternals_fn4).call(this, response);
1448
- }
1449
- async removeAdvert(advertId) {
1450
- const route = Routes.guilds.get(this.id);
1451
- const payload = { adverts: this.adverts.filter((a) => a._id !== advertId) };
1452
- const response = await this.rest.request({ method: "PATCH", url: route, payload });
1453
- return __privateMethod(this, _Guild_instances, updateInternals_fn4).call(this, response);
1454
- }
1455
- async createCode(data) {
1456
- this.codes.push(data);
1457
- const route = Routes.guilds.get(this.id);
1458
- const payload = { codes: this.codes };
1459
- const response = await this.rest.request({ method: "PATCH", url: route, payload });
1460
- return __privateMethod(this, _Guild_instances, updateInternals_fn4).call(this, response);
1461
- }
1462
- async removeCode(codeId) {
1463
- const route = Routes.guilds.get(this.id);
1464
- const payload = { codes: this.codes.filter((a) => a._id !== codeId) };
1465
- const response = await this.rest.request({ method: "PATCH", url: route, payload });
1466
- return __privateMethod(this, _Guild_instances, updateInternals_fn4).call(this, response);
1467
- }
1468
- async addIdToChannel(type, id) {
1469
- const channel = this.channels.find((c) => c.type === type);
1470
- const idsToAdd = Array.isArray(id) ? id : [id];
1471
- if (!channel) {
1472
- this.channels.push({ type, ids: [...idsToAdd] });
1473
- } else {
1474
- const chIndex = this.channels.findIndex((ch) => ch.type === type);
1475
- const mergedIds = [.../* @__PURE__ */ new Set([...channel.ids || [], ...idsToAdd])];
1476
- this.channels[chIndex] = { ...channel, ids: mergedIds };
1477
- }
1478
- const route = Routes.guilds.get(this.id);
1479
- const payload = { channels: this.channels };
1480
- const response = await this.rest.request({
1481
- method: "PATCH",
1482
- url: route,
1483
- payload
1484
- });
1485
- return __privateMethod(this, _Guild_instances, updateInternals_fn4).call(this, response);
1486
- }
1487
- async setChannelIds(type, ...ids) {
1488
- const channel = this.channels.find((c) => c.type === type);
1489
- if (!ids || ids.length === 0) return;
1490
- if (!channel) {
1491
- this.channels.push({ type, ids });
1492
- } else {
1493
- const chIndex = this.channels.findIndex((ch) => ch.type === type);
1494
- const mergedIds = [.../* @__PURE__ */ new Set([...ids])];
1495
- this.channels[chIndex] = { ...channel, ids: mergedIds };
1496
- }
1497
- const route = Routes.guilds.get(this.id);
1498
- const payload = { channels: this.channels };
1499
- const response = await this.rest.request({
1500
- method: "PATCH",
1501
- url: route,
1502
- payload
1503
- });
1504
- return __privateMethod(this, _Guild_instances, updateInternals_fn4).call(this, response);
1505
- }
1506
- async removeIdInChannel(type, id) {
1507
- const chIndex = this.channels.findIndex((c) => c.type === type);
1508
- if (chIndex !== -1) {
1509
- const existing = this.channels[chIndex];
1510
- const idsToRemove = Array.isArray(id) ? id : [id];
1511
- existing.ids = existing.ids.filter((i) => !idsToRemove.includes(i));
1512
- this.channels[chIndex] = existing;
1513
- } else {
1514
- this.channels.push({
1515
- type,
1516
- ids: []
1517
- });
1518
- }
1519
- const route = Routes.guilds.get(this.id);
1520
- const payload = { channels: this.channels };
1521
- const response = await this.rest.request({
1522
- method: "PATCH",
1523
- url: route,
1524
- payload
1525
- });
1526
- return __privateMethod(this, _Guild_instances, updateInternals_fn4).call(this, response);
1527
- }
1528
- async updateRouletteSettings(data) {
1529
- const _data = {
1530
- roulette_settings: {
1531
- primary_color: !data.default ? data.primary_color || this.roulette_settings.primary_color || "#161616" : "#161616",
1532
- secondary_color: !data.default ? data.secondary_color || this.roulette_settings.secondary_color || "#1A1A1A" : "#1A1A1A",
1533
- tertiary_color: !data.default ? data.tertiary_color || this.roulette_settings.tertiary_color || "#2D2D2D" : "#2D2D2D",
1534
- text_color: !data.default ? data.text_color || this.roulette_settings.text_color || "#ffffff" : "#ffffff",
1535
- prizes: data.prizes || this.roulette_settings.prizes || []
1536
- }
1537
- };
1538
- return this.update(_data);
1539
- }
1540
- getActive(key) {
1541
- return this[key].cache.filter((o) => o.status === "created" || o.status === "on");
1542
- }
1543
- async addRoulettePrize(prize) {
1544
- if (!prize.label) {
1545
- throw new Error("Prize label is required");
1546
- }
1547
- const prizes = this.roulette_settings.prizes;
1548
- const prizeIndex = prize._id ? prizes.findIndex((p) => p._id === prize._id) : prizes.findIndex((p) => p.label === prize.label);
1549
- const defaultProbability = prizes.length > 0 ? 1 / prizes.length : 0.1;
1550
- if (prizeIndex !== -1) {
1551
- const existing = prizes[prizeIndex];
1552
- prizes[prizeIndex] = {
1553
- label: prize.label,
1554
- custom_color: prize.custom_color ?? existing.custom_color,
1555
- custom_probability: prize.custom_probability ?? existing.custom_probability ?? defaultProbability,
1556
- _id: existing._id
1557
- };
1558
- } else {
1559
- prizes.push({
1560
- label: prize.label,
1561
- custom_color: prize.custom_color ?? "",
1562
- custom_probability: prize.custom_probability ?? defaultProbability
1563
- });
1564
- }
1565
- await this.updateRouletteSettings({ prizes });
1566
- return this.roulette_settings.prizes.find((p) => p.label === prize.label);
1567
- }
1568
- async removeRoulettePrize(id) {
1569
- let prizes = this.roulette_settings.prizes;
1570
- if (!prizes.find((p) => p._id === id)) return this;
1571
- prizes = prizes.filter((p) => p._id !== id);
1572
- return this.updateRouletteSettings({ prizes });
1573
- }
1574
- async _start() {
1575
- await Promise.all([
1576
- this.users.fetch(),
1577
- this.matches.fetch(),
1578
- this.tickets.fetch(),
1579
- this.vipMembers.fetch(),
1580
- this.logEntries.fetch(),
1581
- this.betusers.fetch(),
1582
- this.bets.fetch(),
1583
- this.mediators.fetch(),
1584
- this.tournaments.fetch()
1585
- ]);
1586
- return this;
1587
- }
1588
- async fetch() {
1589
- const route = Routes.guilds.get(this.id);
1590
- const response = await this.rest.request({
1591
- method: "get",
1592
- url: route
1593
- });
1594
- return __privateMethod(this, _Guild_instances, updateInternals_fn4).call(this, response);
1595
- }
1596
- async reset() {
1597
- return this.update({ reset: true });
1598
- }
1599
- async update(data) {
1600
- const route = Routes.guilds.get(this.id);
1601
- const response = await this.rest.request({
1602
- method: "patch",
1603
- url: route,
1604
- payload: data
1605
- });
1606
- return __privateMethod(this, _Guild_instances, updateInternals_fn4).call(this, response);
1607
- }
1608
- async setStatus(key, status) {
1609
- Assertion.assertString(key);
1610
- this.status[key] = status;
1611
- const route = Routes.guilds.resource(this.id, "status");
1612
- const payload = { set: this.status };
1613
- const response = await this.rest.request({
1614
- method: "PATCH",
1615
- url: route,
1616
- payload
1617
- });
1618
- this.status = response.status;
1619
- this.rest.guilds.cache.set(this.id, this);
1620
- this.rest.emit("guildUpdate", this);
1621
- return this;
1622
- }
1623
- async togglePrice(price) {
1624
- Assertion.assertNumber(price);
1625
- const includesPrice = this.prices.includes(price);
1626
- if (includesPrice) this.prices = this.prices.filter((p) => p !== price);
1627
- else this.prices.push(price);
1628
- await this.update({ prices: this.prices });
1629
- return this;
1630
- }
1631
- async addPrefix(prefixes) {
1632
- const route = Routes.fields(Routes.guilds.resource(this.id, "prefixes"));
1633
- const _p = Array.isArray(prefixes) ? prefixes : [prefixes];
1634
- const payload = { set: [.../* @__PURE__ */ new Set([...this.prefixes, ..._p])] };
1635
- const response = await this.rest.request({
1636
- method: "PATCH",
1637
- url: route,
1638
- payload
1639
- });
1640
- __privateMethod(this, _Guild_instances, updateInternals_fn4).call(this, response);
1641
- return this;
1642
- }
1643
- async setPrefix(prefixes) {
1644
- const route = Routes.fields(Routes.guilds.resource(this.id, "prefixes"));
1645
- const payload = { set: Array.isArray(prefixes) ? prefixes : [prefixes] };
1646
- const response = await this.rest.request({
1647
- method: "PATCH",
1648
- url: route,
1649
- payload
1650
- });
1651
- __privateMethod(this, _Guild_instances, updateInternals_fn4).call(this, response);
1652
- return this;
1653
- }
1654
- async toggleDailyCategory(category) {
1655
- Assertion.assertString(category);
1656
- let categories = this.daily_categories;
1657
- const returnCategories = () => {
1658
- const isCategoryOn = categories.includes(category);
1659
- if (isCategoryOn) categories = categories.filter((m) => m !== category);
1660
- else categories = [...categories, category];
1661
- return categories;
1662
- };
1663
- const _categories = returnCategories();
1664
- const payload = { daily_categories: _categories };
1665
- const route = Routes.guilds.get(this.id);
1666
- const response = await this.rest.request({
1667
- method: "patch",
1668
- url: route,
1669
- payload
1670
- });
1671
- __privateMethod(this, _Guild_instances, updateInternals_fn4).call(this, response);
1672
- return this;
1673
- }
1674
- async setScores(name, amount) {
1675
- const route = Routes.guilds.get(this.id);
1676
- let scores = this.scores;
1677
- scores[name] = amount;
1678
- const payload = { scores };
1679
- const response = await this.rest.request({
1680
- method: "patch",
1681
- url: route,
1682
- payload
1683
- });
1684
- __privateMethod(this, _Guild_instances, updateInternals_fn4).call(this, response);
1685
- return this;
1686
- }
1687
- async toggleMode(mode) {
1688
- const route = Routes.guilds.get(this.id);
1689
- let modes = this.modes;
1690
- const returnModes = () => {
1691
- const isModeOn = modes.on.includes(mode);
1692
- if (isModeOn) {
1693
- modes.on = modes.on.filter((m) => m !== mode);
1694
- modes.off.push(mode);
1695
- return modes;
1696
- } else {
1697
- modes.off = modes.off.filter((m) => m !== mode);
1698
- modes.on.push(mode);
1699
- return modes;
1700
- }
1701
- };
1702
- const md = returnModes();
1703
- const payload = { modes: md };
1704
- const response = await this.rest.request({
1705
- method: "patch",
1706
- url: route,
1707
- payload
1708
- });
1709
- __privateMethod(this, _Guild_instances, updateInternals_fn4).call(this, response);
1710
- return this;
1711
- }
1712
- };
1713
- _Guild_instances = new WeakSet();
1714
- updateInternals_fn4 = function(data) {
1715
- for (let key in data) {
1716
- if (key === "id" || key === "createdAt") continue;
1717
- if (key in this) {
1718
- this[key] = data[key];
1719
- }
1720
- if (key === "adverts") {
1721
- this.adverts = [];
1722
- for (let _adv of data.adverts) {
1723
- this.adverts.push({
1724
- _id: _adv._id,
1725
- admin_id: _adv.admin_id,
1726
- points_to_remove: _adv.points_to_remove,
1727
- role_id: _adv.role_id,
1728
- createdAt: _adv.createdAt ? new Date(_adv.createdAt) : /* @__PURE__ */ new Date(),
1729
- updatedAt: _adv.updatedAt ? new Date(_adv.updatedAt) : /* @__PURE__ */ new Date()
1730
- });
1731
- }
1732
- }
1733
- if (key === "code") {
1734
- this.codes = [];
1735
- for (let _adv of data.codes) {
1736
- this.codes.push({
1737
- _id: _adv._id,
1738
- admin_id: _adv.admin_id,
1739
- type: _adv.type,
1740
- add: _adv.add,
1741
- code: _adv.code,
1742
- expire: _adv.expire ? new Date(_adv.expire) : /* @__PURE__ */ new Date(),
1743
- createdAt: _adv.createdAt ? new Date(_adv.createdAt) : /* @__PURE__ */ new Date(),
1744
- updatedAt: _adv.updatedAt ? new Date(_adv.updatedAt) : /* @__PURE__ */ new Date()
1745
- });
1746
- }
1747
- }
1748
- }
1749
- this.automaticMessagesManager.set(this.automatic_messages);
1750
- this.updatedAt = /* @__PURE__ */ new Date();
1751
- this.rest.guilds.cache.set(this.id, this);
1752
- this.rest.emit("guildUpdate", this);
1753
- return this;
1754
- };
1755
-
1756
- // src/rest/REST.ts
1757
- import_dotenv.default.config();
1758
-
1759
- // src/structures/automaticmessage/AutomaticMessage.ts
1760
- var _AutomaticMessage_instances, updateInternals_fn5;
1761
- var AutomaticMessage = class {
1762
- constructor(data, manager) {
1763
- __privateAdd(this, _AutomaticMessage_instances);
1764
- __publicField(this, "id");
1765
- __publicField(this, "type");
1766
- __publicField(this, "admin_id");
1767
- __publicField(this, "channel_ids");
1768
- __publicField(this, "content");
1769
- __publicField(this, "embeds");
1770
- __publicField(this, "components");
1771
- __publicField(this, "attachments");
1772
- __publicField(this, "flags");
1773
- __publicField(this, "interval_ms");
1774
- __publicField(this, "createdAt");
1775
- __publicField(this, "updatedAt");
1776
- __publicField(this, "guild");
1777
- __publicField(this, "manager");
1778
- __publicField(this, "rest");
1779
- this.manager = manager;
1780
- this.guild = manager.guild;
1781
- this.rest = manager.rest;
1782
- this.id = data?.id;
1783
- this.type = data?.type;
1784
- this.admin_id = data?.admin_id;
1785
- this.channel_ids = data?.channel_ids;
1786
- this.content = data?.content;
1787
- this.embeds = data?.embeds;
1788
- this.components = data?.components;
1789
- this.attachments = data?.attachments;
1790
- this.flags = data?.flags;
1791
- this.interval_ms = data?.interval_ms;
1792
- this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
1793
- this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
1794
- }
1795
- async fetch() {
1796
- return this.manager.fetch(this.id);
1797
- }
1798
- async addChannelId(...id) {
1799
- const ids = [.../* @__PURE__ */ new Set([...this.channel_ids, ...id])];
1800
- return this.update({ channel_ids: ids });
1801
- }
1802
- async removeChannelId(...id) {
1803
- const remove = new Set(id);
1804
- const ids = this.channel_ids.filter((i) => !remove.has(i));
1805
- return this.update({ channel_ids: ids });
1806
- }
1807
- async update(data) {
1808
- this.manager.cache.set(this.id, { ...this, ...data, id: this.id });
1809
- const route = Routes.guilds.get(this.guild.id);
1810
- const response = await this.rest.request({
1811
- method: "patch",
1812
- url: route,
1813
- payload: { automatic_messages: this.manager.toJSON() }
1814
- });
1815
- return __privateMethod(this, _AutomaticMessage_instances, updateInternals_fn5).call(this, response);
1816
- }
1817
- async delete() {
1818
- this.manager.cache.delete(this.id);
1819
- this.guild.automatic_messages = this.manager.cache.toArray();
1820
- const route = Routes.guilds.get(this.guild.id);
1821
- const response = await this.rest.request({
1822
- method: "patch",
1823
- url: route,
1824
- payload: { automatic_messages: this.manager.toJSON() }
1825
- });
1826
- return this.manager.set(response.automatic_messages);
1827
- }
1828
- toJSON() {
1829
- return {
1830
- id: this.id,
1831
- type: this.type,
1832
- admin_id: this.admin_id,
1833
- attachments: this.attachments,
1834
- channel_ids: this.channel_ids,
1835
- content: this.content,
1836
- embeds: this.embeds,
1837
- flags: this.flags,
1838
- interval_ms: this.interval_ms,
1839
- components: this.components,
1840
- createdAt: this.createdAt,
1841
- updatedAt: this.updatedAt
1842
- };
1843
- }
1844
- };
1845
- _AutomaticMessage_instances = new WeakSet();
1846
- updateInternals_fn5 = function(data) {
1847
- const _this = data?.automatic_messages?.find((m) => m.id === this.id);
1848
- for (let key in _this) {
1849
- if (key === "id" || key === "createdAt") continue;
1850
- if (key in this) {
1851
- this[key] = _this[key];
1852
- }
1853
- }
1854
- this.updatedAt = /* @__PURE__ */ new Date();
1855
- this.createdAt = new Date(data.createdAt);
1856
- this.manager._add(data.automatic_messages);
1857
- return this;
1858
- };
1859
-
1860
- // src/utils/randomKeyGenerator.ts
1861
- import { randomBytes } from "crypto";
1862
- function randomKeyGenerator(max, enconding) {
1863
- return randomBytes(24).toString(enconding ?? "base64").slice(0, max || 24).toUpperCase();
1864
- }
1865
-
1866
- // src/managers/automaticmessage/AutomaticMessageManager.ts
1867
- var AutomaticMessageManager = class extends BaseManager {
1868
- constructor(guild) {
1869
- super(guild);
1870
- this.guild = guild;
1871
- this.rest = guild.rest;
1872
- this.base_url = Routes.guilds.resource(guild.id);
1873
- this.cache = new Collection();
1874
- if (guild.automatic_messages && guild.automatic_messages.length !== 0) this.set(guild.automatic_messages);
1875
- else this.guild.automatic_messages = [];
1876
- }
1877
- async fetch(messageId) {
1878
- const route = this.base_url;
1879
- const response = await this.rest.request({
1880
- method: "get",
1881
- url: route
1882
- });
1883
- this._add(response.automatic_messages);
1884
- return this.cache;
1885
- }
1886
- async create(data) {
1887
- if (!data.type) throw new Error(`Missing message's type.`);
1888
- const id = randomKeyGenerator(9).replace(/-/g, "0").replace(/_/g, "Y");
1889
- const m = { ...data, id };
1890
- this.guild.automatic_messages.push(m);
1891
- const route = Routes.guilds.get(this.guild.id);
1892
- const response = await this.rest.request({
1893
- method: "patch",
1894
- url: route,
1895
- payload: { automatic_messages: this.guild.automatic_messages }
1896
- });
1897
- return this._add(response.automatic_messages).find((m2) => m2.id === id);
1898
- }
1899
- _add(data) {
1900
- if (Array.isArray(data)) {
1901
- for (let _m of data) {
1902
- if (!_m.id) continue;
1903
- if (_m instanceof AutomaticMessage) this.cache.set(_m.id, _m);
1904
- else this.cache.set(_m.id, new AutomaticMessage(_m, this));
1905
- }
1906
- } else {
1907
- if (!data.id) return this.cache;
1908
- if (data instanceof AutomaticMessage) this.cache.set(data.id, data);
1909
- else this.cache.set(data.id, new AutomaticMessage(data, this));
1910
- }
1911
- this.guild.automatic_messages = this.cache.toArray();
1912
- return this.cache;
1913
- }
1914
- set(data) {
1915
- this.cache.clear();
1916
- if (Array.isArray(data)) {
1917
- for (let _m of data) {
1918
- if (!_m.id) continue;
1919
- if (_m instanceof AutomaticMessage) this.cache.set(_m.id, _m);
1920
- else this.cache.set(_m.id, new AutomaticMessage(_m, this));
1921
- }
1922
- } else {
1923
- if (!data.id) return this.cache;
1924
- if (data instanceof AutomaticMessage) this.cache.set(data.id, data);
1925
- else this.cache.set(data.id, new AutomaticMessage(data, this));
1926
- }
1927
- return this.cache;
1928
- }
1929
- async delete(messageId) {
1930
- if (messageId) return await this.cache.get(messageId).delete();
1931
- this.cache.clear();
1932
- const route = Routes.guilds.get(this.guild.id);
1933
- const response = await this.rest.request({
1934
- method: "patch",
1935
- url: route,
1936
- payload: { automatic_messages: [] }
1937
- });
1938
- return response;
1939
- }
1940
- toJSON() {
1941
- [...this.cache.values()].map((m) => console.log(m instanceof AutomaticMessage));
1942
- return this.cache.toArray();
1943
- }
1944
- };
1945
-
1946
- // src/managers/bet/GuildBetManager.ts
1947
- var GuildBetManager = class extends BaseManager {
1948
- constructor(guild) {
1949
- super(guild);
1950
- this.guild = guild;
1951
- this.rest = guild.rest;
1952
- this.base_url = Routes.guilds.bets.getAll(guild.id);
1953
- this.cache = new Collection("bets");
1954
- }
1955
- toString() {
1956
- return this.cache.size;
1957
- }
1958
- async fetch(options) {
1959
- const route = this.base_url;
1960
- if (options && options.cache) return this.cache;
1961
- if (options && options.betId) {
1962
- const response2 = await this.rest.request({ url: `${route}/${options.betId}`, method: "GET" });
1963
- return this.set(response2);
1964
- }
1965
- const response = await this.rest.request({ url: route, method: "GET" });
1966
- return this.set(response);
1967
- }
1968
- async create(data) {
1969
- const route = Routes.guilds.bets.create(this.guild.id);
1970
- const response = await this.rest.request({ url: route, method: "POST", payload: data });
1971
- return this.set(response);
1972
- }
1973
- async delete(betId) {
1974
- const route = Routes.fields(this.base_url, betId);
1975
- const response = await this.rest.request({ url: route, method: "DELETE" });
1976
- return this.set(response);
1977
- }
1978
- set(data) {
1979
- if (!data) return;
1980
- if (Array.isArray(data)) {
1981
- for (let _bet of data) {
1982
- if (!_bet._id) continue;
1983
- const bet = new GuildBet(_bet, this);
1984
- this.cache.set(bet._id, bet);
1985
- this.rest.bets.set(bet._id, bet);
1986
- }
1987
- } else {
1988
- if (!data._id) return;
1989
- if (data instanceof GuildBet) {
1990
- this.cache.set(data._id, data);
1991
- return data;
1992
- }
1993
- const bet = new GuildBet(data, this);
1994
- this.cache.set(bet._id, bet);
1995
- this.rest.bets.set(bet._id, bet);
1996
- return bet;
1997
- }
1998
- }
1999
- };
2000
-
2001
- // src/managers/buffer/BufferManager.ts
2002
- var BufferManager = class {
2003
- constructor(guild) {
2004
- __publicField(this, "matches");
2005
- __publicField(this, "tickets");
2006
- __publicField(this, "guild");
2007
- this.matches = new Collection("buffer:matches");
2008
- this.tickets = new Collection("buffer:tickets");
2009
- this.guild = guild;
2010
- }
2011
- async flush(key) {
2012
- const { rest } = this.guild;
2013
- const cache = this[key];
2014
- const { size, clear } = cache;
2015
- if (size >= 2) {
2016
- const response = await rest.request({
2017
- method: "POST",
2018
- url: Routes.guilds.resources(this.guild.id, key, "bulk"),
2019
- payload: { [key]: this[key].toArray() }
2020
- });
2021
- this.guild[key].set(response);
2022
- clear();
2023
- return response;
2024
- }
2025
- return;
2026
- }
2027
- createMatch(id, data) {
2028
- this.matches.set(id, data);
2029
- }
2030
- createTicket(id, data) {
2031
- this.tickets.set(id, data);
2032
- }
2033
- };
2034
-
2035
- // src/managers/logs/LogManager.ts
2036
- var LogManager = class extends BaseManager {
2037
- constructor(guild) {
2038
- super(guild);
2039
- this.guild = guild;
2040
- this.rest = guild.rest;
2041
- this.base_url = Routes.fields(Routes.guilds.get(guild.id), "logs");
2042
- this.cache = new Collection();
2043
- }
2044
- async fetch() {
2045
- const route = this.base_url;
2046
- const response = await this.rest.request({
2047
- method: "GET",
2048
- url: route
2049
- });
2050
- return this.set(response);
2051
- }
2052
- async create(data) {
2053
- const route = this.base_url;
2054
- const payload = { ...data };
2055
- const response = await this.rest.request({
2056
- method: "POST",
2057
- url: route,
2058
- payload
2059
- });
2060
- const logEntry = this.set(response);
2061
- this.cache.set(data._id, logEntry);
2062
- this.rest.emit("logEntryCreate", logEntry, this.guild);
2063
- return logEntry;
2064
- }
2065
- /* async createMany(data: Optional<APILogEntry>[]): Promise<APILogEntry[]> {
2066
- const route = Routes.fields(this.base_url, "bulk");
2067
- const payload = { ...data };
2068
- const response = await this.rest.request<APILogEntry[], typeof payload>({
2069
- method: "POST",
2070
- url: route,
2071
- payload,
2072
- });
2073
-
2074
- this.set(response);
2075
- return response;
2076
- } */
2077
- set(data) {
2078
- if (!data) return this.cache;
2079
- if (Array.isArray(data)) {
2080
- this.cache.clear();
2081
- for (let entry of data) {
2082
- if (!entry._id) continue;
2083
- const logEntry = new LogEntry(entry, this);
2084
- this.cache.set(entry._id, logEntry);
2085
- }
2086
- return this.cache;
2087
- } else {
2088
- const logEntry = new LogEntry(data, this);
2089
- this.cache.set(data._id, logEntry);
2090
- return logEntry;
2091
- }
2092
- }
2093
- };
2094
-
2095
- // src/structures/match/GuildMatch.ts
2096
- var _GuildMatch_instances, updateInternals_fn6;
2097
- var _GuildMatch = class _GuildMatch {
2098
- /**
2099
- * GuildMatch match
2100
- * @param data The match's data
2101
- * @param guild The guild
2102
- * @param rest The rest client
2103
- */
2104
- constructor(data, manager) {
2105
- __privateAdd(this, _GuildMatch_instances);
2106
- __publicField(this, "_id");
2107
- __publicField(this, "selections");
2108
- /** Match's type */
2109
- __publicField(this, "type");
2110
- __publicField(this, "channels");
2111
- __publicField(this, "guild_id");
2112
- /** Match's status */
2113
- __publicField(this, "status");
2114
- /** Match's challenge */
2115
- __publicField(this, "challenge");
2116
- /** Match's players */
2117
- __publicField(this, "players");
2118
- __publicField(this, "teams");
2119
- /** Match's winners */
2120
- __publicField(this, "winners");
2121
- /** Match's losers */
2122
- __publicField(this, "losers");
2123
- /** Match's maximum size */
2124
- __publicField(this, "maximumSize");
2125
- /** Match's kicked out */
2126
- __publicField(this, "kickedOut");
2127
- /** Match's confirmed */
2128
- __publicField(this, "confirmed");
2129
- /** Match's leaders */
2130
- __publicField(this, "leaders");
2131
- /** Match's creator id */
2132
- __publicField(this, "creatorId");
2133
- /** Match's room creator id */
2134
- __publicField(this, "roomCreatorId");
2135
- /** Creation Date */
2136
- __publicField(this, "createdAt");
2137
- /** Updated Date */
2138
- __publicField(this, "updatedAt");
2139
- __publicField(this, "messages");
2140
- /** Match's id */
2141
- __publicField(this, "mvps");
2142
- __publicField(this, "manager");
2143
- __publicField(this, "bet");
2144
- __publicField(this, "admin_id");
2145
- /** The given guild */
2146
- __publicField(this, "guild");
2147
- /** The rest client */
2148
- __publicField(this, "rest");
2149
- __publicField(this, "key");
2150
- this._id = data?._id;
2151
- this.guild_id = data?.guild_id;
2152
- this.manager = manager;
2153
- this.guild = manager.guild;
2154
- this.rest = manager.rest;
2155
- this.admin_id = data?.admin_id;
2156
- this.challenge = data?.challenge;
2157
- this.players = data?.players;
2158
- this.messages = new MessagesManager(this, Routes.guilds.matches.resource(this.guild_id, this._id, "messages"));
2159
- this.channels = data?.channels;
2160
- this.type = data?.type;
2161
- this.status = data?.status;
2162
- this.bet = this.guild.bets.cache.get(data?.bet?._id);
2163
- this.mvps = data?.mvps;
2164
- this.winners = data?.winners;
2165
- this.losers = data?.losers;
2166
- this.maximumSize = data?.maximumSize;
2167
- this.kickedOut = data?.kickedOut;
2168
- this.confirmed = data?.confirmed;
2169
- this.teams = data?.teams;
2170
- this.leaders = data?.leaders;
2171
- this.creatorId = data?.creatorId;
2172
- this.roomCreatorId = data?.roomCreatorId;
2173
- this.selections = data?.selections;
2174
- this.key = "matches";
2175
- this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
2176
- this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
2177
- if (data?.messages?.length !== 0) this.messages.set(data.messages);
2178
- }
2179
- /**
2180
- * Fetches the match
2181
- * @returns New Instance of the match
2182
- */
2183
- async fetch() {
2184
- const route = Routes.guilds.matches.get(this.guild.id, this._id);
2185
- const response = await this.rest.request({
2186
- method: "get",
2187
- url: route
2188
- });
2189
- return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn6).call(this, response);
2190
- }
2191
- async addConfirmed(type, id) {
2192
- const confirmed = this.confirmed.find((c) => c.type === type);
2193
- const idsToAdd = Array.isArray(id) ? id : [id];
2194
- if (!confirmed) {
2195
- this.confirmed.push({ type, ids: [...idsToAdd], count: idsToAdd.length });
2196
- } else {
2197
- const chIndex = this.confirmed.findIndex((ch) => ch.type === type);
2198
- const mergedIds = [.../* @__PURE__ */ new Set([...confirmed.ids || [], ...idsToAdd])];
2199
- this.confirmed[chIndex] = { ...confirmed, ids: mergedIds, count: mergedIds.length };
2200
- }
2201
- return this.update({ confirmed: this.confirmed });
2202
- }
2203
- async setConfirmed(set) {
2204
- Assertion.assertObject(set);
2205
- const route = Routes.guilds.matches.resource(this.guild.id, this._id, "confirmed");
2206
- const response = await this.rest.request({
2207
- method: "PATCH",
2208
- url: route,
2209
- payload: set
2210
- });
2211
- return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn6).call(this, response);
2212
- }
2213
- async setStatus(status) {
2214
- Assertion.assertString(status);
2215
- const payload = { set: status.toLowerCase() };
2216
- const route = Routes.guilds.matches.resource(this.guild.id, this._id, "status");
2217
- const response = await this.rest.request({
2218
- method: "PATCH",
2219
- url: route,
2220
- payload
2221
- });
2222
- return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn6).call(this, response);
2223
- }
2224
- async setWinners(players) {
2225
- if (!Array.isArray(players)) players = [players];
2226
- const payload = { set: players };
2227
- const route = Routes.guilds.matches.resource(this.guild.id, this._id, "winners");
2228
- const response = await this.rest.request({
2229
- method: "PATCH",
2230
- url: route,
2231
- payload
2232
- });
2233
- return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn6).call(this, response);
2234
- }
2235
- async setLoser(players) {
2236
- if (!Array.isArray(players)) players = [players];
2237
- const payload = { set: players };
2238
- const route = Routes.guilds.matches.resource(this.guild.id, this._id, "losers");
2239
- const response = await this.rest.request({
2240
- method: "PATCH",
2241
- url: route,
2242
- payload
2243
- });
2244
- return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn6).call(this, response);
2245
- }
2246
- async setMvps(...usersId) {
2247
- const payload = { set: usersId };
2248
- const route = Routes.guilds.matches.resource(this.guild.id, this._id, "mvps");
2249
- const response = await this.rest.request({
2250
- method: "PATCH",
2251
- url: route,
2252
- payload
2253
- });
2254
- return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn6).call(this, response);
2255
- }
2256
- async setRoomCreatorId(userId) {
2257
- Assertion.assertString(userId);
2258
- const payload = { set: userId };
2259
- const route = Routes.guilds.matches.resource(this.guild.id, this._id, "roomCreatorId");
2260
- const response = await this.rest.request({
2261
- method: "PATCH",
2262
- url: route,
2263
- payload
2264
- });
2265
- return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn6).call(this, response);
2266
- }
2267
- async setRoomAdminId(userId) {
2268
- Assertion.assertString(userId);
2269
- const payload = { set: userId };
2270
- const route = Routes.guilds.matches.resource(this.guild.id, this._id, "admin_id");
2271
- const response = await this.rest.request({
2272
- method: "PATCH",
2273
- url: route,
2274
- payload
2275
- });
2276
- return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn6).call(this, response);
2277
- }
2278
- async kick(player) {
2279
- this.players = this.players.filter((p) => p.id !== player.id);
2280
- this.leaders = this.leaders.filter((p) => p.id !== player.id);
2281
- const teamIndex = this.teams.findIndex((t) => t.some((p) => p.id === player.id));
2282
- if (teamIndex !== -1) {
2283
- let team = this.teams.find((t) => t.some((p) => p.id === player.id));
2284
- team = team.filter((p) => p.id === player.id);
2285
- this.teams[teamIndex] = team;
2286
- }
2287
- return await this.update(this.toJSON());
2288
- }
2289
- async update(data) {
2290
- const route = Routes.guilds.matches.get(this.guild.id, this._id);
2291
- if (data?.bet && data?.bet instanceof GuildBet) {
2292
- data.bet = data.bet.toJSON();
2293
- }
2294
- const response = await this.rest.request({
2295
- method: "patch",
2296
- url: route,
2297
- payload: data
2298
- });
2299
- this.rest.emit("matchUpdate", this, new _GuildMatch(response, this.manager));
2300
- return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn6).call(this, response);
2301
- }
2302
- async delete() {
2303
- const route = Routes.guilds.matches.resource(this.guild.id, this._id);
2304
- const response = await this.rest.request({
2305
- method: "DELETE",
2306
- url: route
2307
- });
2308
- this.manager.cache.delete(this?._id);
2309
- this.rest.matches.delete(this?._id);
2310
- return response;
2311
- }
2312
- toJSON() {
2313
- let json = {};
2314
- for (const [key, value] of Object.entries(this)) {
2315
- const exclude = ["rest", "guilds", "guild", "manager"];
2316
- if (exclude.includes(key)) continue;
2317
- if (typeof value !== "function") {
2318
- json[key] = value;
2319
- }
2320
- }
2321
- return {
2322
- ...json,
2323
- messages: this?.messages instanceof MessagesManager ? this.messages?.cache?.toArray() : []
2324
- };
2325
- }
2326
- };
2327
- _GuildMatch_instances = new WeakSet();
2328
- updateInternals_fn6 = async function(data) {
2329
- if (!data) return;
2330
- for (let key in data) {
2331
- if (key === "id" || key === "createdAt" || key === "messages") continue;
2332
- if (key in this) {
2333
- this[key] = data[key];
2334
- }
2335
- if (key === "bet") {
2336
- this.bet = this.guild.bets.set(data.bet);
2337
- }
2338
- }
2339
- if (data?.messages?.length !== 0) {
2340
- if (this?.messages instanceof MessagesManager) this.messages.set(data.messages);
2341
- else {
2342
- this.messages = new MessagesManager(this, Routes.guilds.matches.resource(this.guild_id, this._id, "messages"));
2343
- this.messages.set(data.messages);
2344
- }
2345
- }
2346
- if (!(this.bet instanceof GuildBet) && data?.bet) {
2347
- this.bet = this.guild.bets.cache.get(data._id) ?? await this.guild.bets.fetch({ betId: data?.bet?._id });
2348
- }
2349
- this.updatedAt = /* @__PURE__ */ new Date();
2350
- this.manager.set(this);
2351
- return this;
2352
- };
2353
- var GuildMatch = _GuildMatch;
2354
-
2355
- // src/managers/match/GuildMatchManager.ts
2356
- var GuildMatchManager = class extends BaseManager {
2357
- /**
2358
- * Manage users with the given client
2359
- * @param users An array of users
2360
- * @param rest The rest client
2361
- */
2362
- constructor(guild) {
2363
- super(guild);
2364
- this.guild = guild;
2365
- this.rest = guild.rest;
2366
- this.base_url = Routes.guilds.matches.getAll(guild.id);
2367
- this.cache = new Collection("matches");
2368
- }
2369
- /**
2370
- * Fetch a match
2371
- * @param id Id of the match to fetch
2372
- * @returns APIBetUser
2373
- */
2374
- async fetch(options) {
2375
- if (options && options.cache) return this.cache;
2376
- if (options && options.matchId) {
2377
- const route2 = Routes.guilds.matches.get(this.guild.id, options.matchId);
2378
- const response2 = await this.rest.request({
2379
- method: "get",
2380
- url: route2
2381
- });
2382
- return this.set(response2);
2383
- }
2384
- const route = Routes.guilds.matches.getAll(this.guild.id);
2385
- const response = await this.rest.request({
2386
- method: "get",
2387
- url: route
2388
- });
2389
- if (!response) return this.cache;
2390
- const coll = new Collection("matches");
2391
- for (let match of response ?? []) {
2392
- const guildMatch = new GuildMatch(match, this);
2393
- coll.set(match._id, guildMatch);
2394
- this.rest.matches.set(match._id, guildMatch);
2395
- }
2396
- this.cache = coll;
2397
- return coll;
2398
- }
2399
- async fetchAll() {
2400
- const route = Routes.guilds.matches.getAll(this.guild.id);
2401
- const response = await this.rest.request({
2402
- method: "get",
2403
- url: route
2404
- });
2405
- if (Array.isArray(response) && response.length === 0) {
2406
- this.cache.clear();
2407
- return this.cache;
2408
- }
2409
- this.set(response);
2410
- return this.cache;
2411
- }
2412
- set(data) {
2413
- if (!data) return this.cache;
2414
- if (Array.isArray(data)) {
2415
- for (let _match of data) {
2416
- if (!_match._id) continue;
2417
- const match = new GuildMatch(_match, this);
2418
- this.cache.set(match._id, match);
2419
- }
2420
- return this.cache;
2421
- } else {
2422
- if (!data._id) return this.cache;
2423
- if (data instanceof GuildMatch) {
2424
- this.cache.set(data._id, data);
2425
- return data;
2426
- }
2427
- const match = new GuildMatch(data, this);
2428
- this.cache.set(match._id, match);
2429
- return match;
2430
- }
2431
- }
2432
- async create(payload) {
2433
- Assertion.assertObject(payload);
2434
- const route = Routes.guilds.matches.create(this.guild.id);
2435
- const response = await this.rest.request({
2436
- method: "POST",
2437
- url: route,
2438
- payload
2439
- });
2440
- return this.set(response);
2441
- }
2442
- async delete(id) {
2443
- const route = Routes.fields(this.base_url, id);
2444
- const response = await this.rest.request({ url: route, method: "DELETE" });
2445
- return this.set(response);
2446
- }
2447
- };
2448
-
2449
- // src/managers/message/MessagesManager.ts
2450
- var MessagesManager = class {
2451
- constructor(structure, base_url) {
2452
- __publicField(this, "cache");
2453
- __publicField(this, "base_url");
2454
- __publicField(this, "rest");
2455
- __publicField(this, "guild");
2456
- this.rest = structure.rest;
2457
- this.guild = structure.guild;
2458
- this.cache = new Collection("messages");
2459
- this.base_url = base_url;
2460
- }
2461
- async fetch() {
2462
- const response = await this.rest.request({
2463
- method: "GET",
2464
- url: this.base_url,
2465
- payload: {}
2466
- });
2467
- this.cache.set(response._id, response);
2468
- return response;
2469
- }
2470
- async create(data) {
2471
- const messages = [...this.cache.toArray()];
2472
- if (Array.isArray(data)) messages.push(...data);
2473
- else messages.push(data);
2474
- const response = await this.rest.request({
2475
- method: "PATCH",
2476
- url: this.base_url,
2477
- payload: { set: messages }
2478
- });
2479
- return this.set(response.messages);
2480
- }
2481
- set(data) {
2482
- if (!data) return this.cache;
2483
- if (Array.isArray(data)) {
2484
- for (let message of data) {
2485
- if (message && !message._id) continue;
2486
- this.cache.set(message._id, message);
2487
- }
2488
- } else {
2489
- if (data && !data._id) return this.cache;
2490
- this.cache.set(data._id, data);
2491
- }
2492
- return this.cache;
2493
- }
2494
- };
2495
-
2496
- // src/managers/permission/GuildPermissionManager.ts
2497
- var GuildPermissionManager = class extends BaseManager {
2498
- constructor(guild) {
2499
- super(guild);
2500
- this.guild = guild;
2501
- this.rest = guild.rest;
2502
- this.base_url = Routes.guilds.resource(guild.id, "permissions");
2503
- }
2504
- async addRole(type, ...ids) {
2505
- const perm = this.guild.permissions.find((p) => p.type === type) || { ids: [], type };
2506
- const _ids = [.../* @__PURE__ */ new Set([...perm.ids, ...ids])];
2507
- const perms = [...this.guild.permissions];
2508
- let permsIndex = this.guild.permissions.findIndex((p) => p.type === type);
2509
- if (permsIndex === -1) perms.push({ type, ids: _ids });
2510
- else perms[permsIndex] = { type, ids: _ids };
2511
- const payload = { set: perms };
2512
- const response = await this.rest.request({
2513
- method: "PATCH",
2514
- url: this.base_url,
2515
- payload
2516
- });
2517
- this.guild.permissions = response.permissions;
2518
- this.rest.guilds.cache.set(this.guild.id, this.guild);
2519
- return response;
2520
- }
2521
- async removeRole(type, ...ids) {
2522
- const perm = this.guild.permissions.find((p) => p.type === type) || { ids: [], type };
2523
- const _ids = [.../* @__PURE__ */ new Set([...perm.ids.filter((i) => !ids.includes(i))])];
2524
- const perms = [...this.guild.permissions];
2525
- let permsIndex = this.guild.permissions.findIndex((p) => p.type === type);
2526
- if (permsIndex === -1) {
2527
- perms.push({ type, ids: _ids });
2528
- } else {
2529
- perms[permsIndex] = { type, ids: _ids };
2530
- }
2531
- const payload = { set: perms };
2532
- const response = await this.rest.request({
2533
- method: "PATCH",
2534
- url: this.base_url,
2535
- payload
2536
- });
2537
- this.guild.permissions = response.permissions;
2538
- this.rest.guilds.cache.set(this.guild.id, this.guild);
2539
- return response;
2540
- }
2541
- };
2542
-
2543
- // src/managers/ticket/TicketManager.ts
2544
- var GuildTicketManager = class {
2545
- constructor(guild) {
2546
- __publicField(this, "cache");
2547
- __publicField(this, "guild");
2548
- __publicField(this, "rest");
2549
- this.guild = guild;
2550
- this.rest = guild.rest;
2551
- this.cache = new Collection("tickets");
2552
- }
2553
- async createTicketCategory(data) {
2554
- const categories = this.guild.tickets_configuration.categories;
2555
- let hasCategory = categories.find((c) => c.type === data?.type);
2556
- if (hasCategory) {
2557
- hasCategory = data;
2558
- const index = categories.findIndex((c) => c.type === data?.type);
2559
- categories[index] = hasCategory;
2560
- } else {
2561
- categories.push(data);
2562
- }
2563
- return this.guild.update({
2564
- tickets_configuration: {
2565
- categories,
2566
- creationCategory: this.guild.tickets_configuration.creationCategory,
2567
- deletionCategory: this.guild.tickets_configuration.deletionCategory,
2568
- rating_channel_id: this.guild.tickets_configuration.rating_channel_id
2569
- }
2570
- });
2571
- }
2572
- async deleteTicketCategory(data) {
2573
- let categories = this.guild.tickets_configuration.categories;
2574
- let categoryIndex = categories.findIndex((c) => c.type === data?.type);
2575
- if (categoryIndex === -1) return this.guild;
2576
- categories = categories.filter((c) => c.type !== data.type);
2577
- const payload = { tickets_configuration: { categories } };
2578
- const route = Routes.guilds.get(this.guild.id);
2579
- const response = await this.rest.request({
2580
- method: "PATCH",
2581
- url: route,
2582
- payload
2583
- });
2584
- return this.guild.update({
2585
- tickets_configuration: {
2586
- categories,
2587
- creationCategory: this.guild.tickets_configuration.creationCategory,
2588
- deletionCategory: this.guild.tickets_configuration.deletionCategory,
2589
- rating_channel_id: this.guild.tickets_configuration.rating_channel_id
2590
- }
2591
- });
2592
- }
2593
- async fetch(options) {
2594
- if (options && options.cache) return this.cache;
2595
- if (options && options.ticketId) {
2596
- const route2 = Routes.guilds.tickets.get(this.guild.id, options.ticketId);
2597
- const response2 = await this.rest.request({
2598
- method: "GET",
2599
- url: route2
2600
- });
2601
- return this.set(response2);
2602
- }
2603
- const route = Routes.guilds.tickets.getAll(this.guild.id);
2604
- const response = await this.rest.request({
2605
- method: "GET",
2606
- url: route
2607
- });
2608
- return this.set(response);
2609
- }
2610
- async create(data) {
2611
- const route = Routes.guilds.tickets.create(this.guild.id);
2612
- const response = await this.rest.request({
2613
- method: "POST",
2614
- url: route,
2615
- payload: data
2616
- });
2617
- const ticket = this.set(response);
2618
- this.rest.emit("ticketCreate", ticket);
2619
- return ticket;
2620
- }
2621
- async delete(options) {
2622
- if (options && options.ticketId) {
2623
- const route2 = Routes.guilds.tickets.delete(this.guild.id, options.ticketId);
2624
- await this.rest.request({
2625
- method: "DELETE",
2626
- url: route2
2627
- });
2628
- this.rest.emit("ticketDelete", this.cache.get(options.ticketId));
2629
- this.cache.delete(options.ticketId);
2630
- return true;
2631
- }
2632
- const route = Routes.guilds.tickets.deleteAll(this.guild.id);
2633
- await this.rest.request({
2634
- method: "DELETE",
2635
- url: route
2636
- });
2637
- this.rest.emit("ticketsDelete", this.cache);
2638
- this.cache.clear();
2639
- return true;
2640
- }
2641
- set(data) {
2642
- if (!data) return this.cache;
2643
- if (Array.isArray(data)) {
2644
- for (let _ticket of data) {
2645
- if (!_ticket._id) return;
2646
- const ticket = new GuildTicket(_ticket, this);
2647
- this.cache.set(ticket._id, ticket);
2648
- this.rest.tickets.set(ticket._id, ticket);
2649
- }
2650
- return this.cache;
2651
- } else {
2652
- if (!data._id) return;
2653
- const ticket = new GuildTicket(data, this);
2654
- this.cache.set(ticket._id, ticket);
2655
- this.rest.tickets.set(ticket._id, ticket);
2656
- return ticket;
2657
- }
2658
- }
2659
- };
2660
-
2661
- // src/structures/user/GuildUser.ts
2662
- var _GuildUser_instances, updateInternals_fn7;
2663
- var _GuildUser = class _GuildUser {
2664
- /**
2665
- * Bet user
2666
- * @param data The user's data
2667
- * @param manager The manager
2668
- * @param rest The rest client
2669
- */
2670
- constructor(data, manager) {
2671
- __privateAdd(this, _GuildUser_instances);
2672
- /** User's id */
2673
- __publicField(this, "id");
2674
- __publicField(this, "guild_id");
2675
- /** User's daily */
2676
- __publicField(this, "daily");
2677
- /** User's points */
2678
- __publicField(this, "points");
2679
- /** User's wins */
2680
- __publicField(this, "wins");
2681
- /** User's mvps */
2682
- __publicField(this, "mvps");
2683
- /** User's losses */
2684
- __publicField(this, "losses");
2685
- /** User's games */
2686
- __publicField(this, "games");
2687
- /** If user is blacklisted */
2688
- __publicField(this, "blacklist");
2689
- /** User's accessories such as double point */
2690
- __publicField(this, "accessories");
2691
- /** User's original channels */
2692
- __publicField(this, "original_channels");
2693
- __publicField(this, "profile");
2694
- __publicField(this, "creations");
2695
- /** User's items */
2696
- __publicField(this, "adverts");
2697
- __publicField(this, "spins");
2698
- /** Creation Date */
2699
- __publicField(this, "createdAt");
2700
- /** Updated Date */
2701
- __publicField(this, "updatedAt");
2702
- /** The given manager */
2703
- __publicField(this, "manager");
2704
- /** The rest client */
2705
- __publicField(this, "rest");
2706
- this.id = data?.id;
2707
- this.guild_id = data?.guild_id;
2708
- this.manager = manager;
2709
- this.rest = manager.rest;
2710
- this.wins = data?.wins;
2711
- this.losses = data?.losses;
2712
- this.mvps = data?.mvps;
2713
- this.points = data?.points;
2714
- this.creations = data?.creations;
2715
- this.spins = data.spins;
2716
- this.daily = data?.daily;
2717
- this.games = data?.games;
2718
- this.blacklist = data?.blacklist;
2719
- this.accessories = data?.accessories;
2720
- this.original_channels = data?.original_channels;
2721
- this.profile = data?.profile;
2722
- this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
2723
- this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
2724
- this.adverts = [];
2725
- for (let _adv of data?.adverts || []) {
2726
- this.adverts.push({
2727
- _id: _adv._id,
2728
- admin_id: _adv.admin_id,
2729
- role_id: _adv.role_id,
2730
- reason: _adv.reason,
2731
- points_removed: _adv.points_removed,
2732
- proof: _adv.proof,
2733
- proof_ext: _adv.proof_ext,
2734
- createdAt: _adv.createdAt ? new Date(_adv.createdAt) : /* @__PURE__ */ new Date(),
2735
- updatedAt: _adv.updatedAt ? new Date(_adv.updatedAt) : /* @__PURE__ */ new Date()
2736
- });
2737
- }
2738
- }
2739
- /** String representation of this user */
2740
- toString() {
2741
- return `<@${this.id}>`;
2742
- }
2743
- /**
2744
- * Fetches the user
2745
- * @returns New Instance of the user
2746
- */
2747
- async fetch() {
2748
- const route = Routes.guilds.users.get(this.manager.guild.id, this.id);
2749
- const response = await this.rest.request({
2750
- method: "get",
2751
- url: route
2752
- });
2753
- const user = new _GuildUser(response, this.manager);
2754
- this.manager.cache.set(user.id, user);
2755
- this.rest.users.set(user.id, user);
2756
- return user;
2757
- }
2758
- /**
2759
- * Set the user blacklist
2760
- * @param value Value to set to
2761
- * @returns GuildUser
2762
- */
2763
- async setBlacklist(value) {
2764
- const route = Routes.guilds.users.resource(this.manager.guild.id, this.id, "blacklist");
2765
- const payload = { set: value };
2766
- await this.rest.request({
2767
- method: "patch",
2768
- url: route,
2769
- payload
2770
- });
2771
- this.blacklist = value;
2772
- this.manager.cache.set(this.id, this);
2773
- this.rest.users.set(this.id, this);
2774
- return this;
2775
- }
2776
- async reset() {
2777
- const route = Routes.guilds.users.get(this.manager.guild.id, this.id);
2778
- const payload = { reset: true };
2779
- const response = await this.rest.request({
2780
- method: "DELETE",
2781
- url: route,
2782
- payload
2783
- });
2784
- __privateMethod(this, _GuildUser_instances, updateInternals_fn7).call(this, response);
2785
- return this;
2786
- }
2787
- async updateProfile(data) {
2788
- const _data = {
2789
- profile: {
2790
- avatarUrl: data.avatarUrl || this.profile.avatarUrl || "",
2791
- bannerUrl: data.bannerUrl || this.profile.bannerUrl || "",
2792
- bio: data.bio || this.profile.bio || "Melhor da minha aldeia (use !bio para alterar)",
2793
- name: data.name || this.profile.name || "",
2794
- textColor: data.textColor || this.profile.textColor || "#ffffff",
2795
- primaryColor: data.primaryColor || this.profile.primaryColor || "#272727",
2796
- secondaryColor: data.secondaryColor || this.profile.secondaryColor || "#151515"
2797
- }
2798
- };
2799
- const route = Routes.guilds.users.update(this.manager.guild.id, this.id);
2800
- const response = await this.rest.request({
2801
- method: "patch",
2802
- url: route,
2803
- payload: _data
2804
- });
2805
- __privateMethod(this, _GuildUser_instances, updateInternals_fn7).call(this, response);
2806
- return this;
2807
- }
2808
- async addAdvert(data) {
2809
- const route = Routes.guilds.users.resource(this.manager.guild.id, this.id, "adverts");
2810
- const payload = data;
2811
- const response = await this.rest.request({ method: "POST", url: route, payload });
2812
- return __privateMethod(this, _GuildUser_instances, updateInternals_fn7).call(this, response);
2813
- }
2814
- async removeAdvert(advertId) {
2815
- let advs = this.adverts;
2816
- if (advertId) advs = advs.filter((a) => a._id !== advertId);
2817
- else advs.pop();
2818
- const payload = { adverts: advs };
2819
- const route = Routes.guilds.users.update(this.manager.guild.id, this.id);
2820
- const response = await this.rest.request({ method: "PATCH", url: route, payload });
2821
- return __privateMethod(this, _GuildUser_instances, updateInternals_fn7).call(this, response);
2822
- }
2823
- /**
2824
- * Update certain property
2825
- * @param data The new data to update with
2826
- * @returns
2827
- */
2828
- async update(data) {
2829
- if (!data?.type) data.type = "add";
2830
- const route = Routes.guilds.users.get(this.manager.guild.id, this.id);
2831
- let payload = {};
2832
- const numericFields = ["wins", "points", "losses", "mvps", "games", "creations", "spins"];
2833
- const arrayFields = ["items", "original_channels", "adverts", "accessories"];
2834
- if (data?.type === "add" || data?.type === "remove") {
2835
- for (const key in data) {
2836
- if (key === "type") continue;
2837
- const value = data[key];
2838
- if (numericFields.includes(key)) {
2839
- const current = this[key] || 0;
2840
- const num = value || 0;
2841
- payload[key] = Math.max(0, data?.type === "add" ? current + num : current - num);
2842
- } else if (key === "blacklist") {
2843
- payload["blacklist"] = value;
2844
- } else if (key === "profile") {
2845
- payload["profile"] = value;
2846
- } else if (arrayFields.includes(key)) {
2847
- if (key === "original_channels") {
2848
- const current2 = this.original_channels;
2849
- const fromData = data["original_channels"];
2850
- let channels = [];
2851
- if (data?.type === "add") {
2852
- const existingIds = new Set(current2.map((ch) => ch.matchId));
2853
- channels = [...current2, ...fromData.filter((ch) => !existingIds.has(ch.matchId))];
2854
- } else if (data?.type === "remove") {
2855
- const idsToRemove = new Set(fromData.map((ch) => ch.matchId));
2856
- channels = current2.filter((ch) => !idsToRemove.has(ch.matchId));
2857
- }
2858
- payload["original_channels"] = channels;
2859
- continue;
2860
- }
2861
- const current = this[key];
2862
- const incoming = value;
2863
- payload[key] = data?.type === "add" ? [.../* @__PURE__ */ new Set([...current, ...incoming])] : current.filter((x) => !incoming.includes(x));
2864
- }
2865
- }
2866
- }
2867
- const response = await this.rest.request({
2868
- method: "patch",
2869
- url: route,
2870
- payload
2871
- });
2872
- __privateMethod(this, _GuildUser_instances, updateInternals_fn7).call(this, response);
2873
- return this;
2874
- }
2875
- async delete() {
2876
- const route = Routes.guilds.users.delete(this.manager.guild.id, this.id);
2877
- const response = await this.rest.request({
2878
- method: "DELETE",
2879
- url: route
2880
- });
2881
- this.rest.emit("userDelete", this);
2882
- this.manager.cache.delete(this.id);
2883
- return response;
2884
- }
2885
- toJSON() {
2886
- let json = {};
2887
- for (const [key, value] of Object.entries(this)) {
2888
- const exclude = ["rest", "guilds", "guild", "manager"];
2889
- if (exclude.includes(key)) continue;
2890
- if (typeof value !== "function") {
2891
- json[key] = value;
2892
- }
2893
- }
2894
- return json;
2895
- }
2896
- };
2897
- _GuildUser_instances = new WeakSet();
2898
- updateInternals_fn7 = function(data) {
2899
- for (let key in data) {
2900
- if (key === "id" || key === "createdAt") continue;
2901
- if (key in this) {
2902
- this[key] = data[key];
2903
- }
2904
- if (key === "adverts") {
2905
- this.adverts = [];
2906
- for (let _adv of data.adverts) {
2907
- this.adverts.push({
2908
- _id: _adv._id,
2909
- admin_id: _adv.admin_id,
2910
- role_id: _adv.role_id,
2911
- reason: _adv.reason,
2912
- points_removed: _adv.points_removed,
2913
- proof: _adv.proof,
2914
- proof_ext: _adv.proof_ext,
2915
- createdAt: _adv.createdAt ? new Date(_adv.createdAt) : /* @__PURE__ */ new Date(),
2916
- updatedAt: _adv.updatedAt ? new Date(_adv.updatedAt) : /* @__PURE__ */ new Date()
2917
- });
2918
- }
2919
- }
2920
- }
2921
- this.updatedAt = /* @__PURE__ */ new Date();
2922
- this.createdAt = new Date(data.createdAt);
2923
- this.manager.set(this);
2924
- this.rest.emit("userUpdate", this);
2925
- return this;
2926
- };
2927
- var GuildUser = _GuildUser;
2928
-
2929
- // src/managers/user/GuildUserManager.ts
2930
- var GuildUserManager = class extends BaseManager {
2931
- constructor(guild) {
2932
- super(guild);
2933
- this.guild = guild;
2934
- this.rest = guild.rest;
2935
- this.base_url = Routes.guilds.users.getAll(guild.id);
2936
- this.cache = new Collection("users");
2937
- }
2938
- async fetch(options) {
2939
- if (options && options.cache) return this.cache;
2940
- if (options && options.userId) {
2941
- const route2 = Routes.fields(this.base_url, options.userId);
2942
- const response2 = await this.rest.request({
2943
- method: "GET",
2944
- url: route2
2945
- });
2946
- const user = new GuildUser(response2, this);
2947
- this.set(user);
2948
- return user;
2949
- }
2950
- const route = this.base_url;
2951
- const response = await this.rest.request({
2952
- method: "GET",
2953
- url: route
2954
- });
2955
- this.cache.clear();
2956
- for (let userData of response) {
2957
- const user = new GuildUser(userData, this);
2958
- this.set(user);
2959
- }
2960
- return this.cache;
2961
- }
2962
- async updateMany(...users) {
2963
- const route = this.base_url;
2964
- const response = await this.rest.request({
2965
- method: "PATCH",
2966
- url: route,
2967
- payload: { users }
2968
- });
2969
- for (const userData of response) {
2970
- const user = new GuildUser(userData, this);
2971
- this.set(user);
2972
- }
2973
- return this.cache;
2974
- }
2975
- async deleteAll() {
2976
- const route = this.base_url;
2977
- await this.rest.request({
2978
- method: "DELETE",
2979
- url: route
2980
- });
2981
- this.cache.clear();
2982
- }
2983
- async resetAll() {
2984
- const route = this.base_url;
2985
- const response = await this.rest.request({
2986
- method: "put",
2987
- url: route
2988
- });
2989
- this.cache.clear();
2990
- this.set(response);
2991
- return this.cache;
2992
- }
2993
- set(data) {
2994
- if (!data) return this.cache;
2995
- if (Array.isArray(data)) {
2996
- for (let _user of data) {
2997
- if (!_user.id) return;
2998
- const user = new GuildUser(_user, this);
2999
- this.cache.set(user.id, user);
3000
- this.rest.users.set(user.id, user);
3001
- }
3002
- return this.cache;
3003
- } else {
3004
- if (!data.id) return;
3005
- const user = new GuildUser(data, this);
3006
- this.cache.set(user.id, user);
3007
- this.rest.users.set(user.id, user);
3008
- return user;
3009
- }
3010
- }
3011
- };
3012
-
3013
- // src/structures/vipmember/VipMember.ts
3014
- var _VipMember_instances, updateData_fn;
3015
- var _VipMember = class _VipMember {
3016
- /**
3017
- * Bet member
3018
- * @param data The member's data
3019
- * @param manager The manager
3020
- * @param rest The rest client
3021
- */
3022
- constructor(data, manager) {
3023
- __privateAdd(this, _VipMember_instances);
3024
- /** member's id */
3025
- __publicField(this, "id");
3026
- /** member name */
3027
- __publicField(this, "name");
3028
- /** Members's roleId */
3029
- __publicField(this, "roleId");
3030
- /** Members's voiceChannelId */
3031
- __publicField(this, "voiceChannelId");
3032
- /** Vip's type */
3033
- __publicField(this, "type");
3034
- /** Member's Guild Id */
3035
- __publicField(this, "guild_id");
3036
- __publicField(this, "duration");
3037
- __publicField(this, "status");
3038
- /** member's daily */
3039
- __publicField(this, "createdAt");
3040
- /** Updated Date */
3041
- __publicField(this, "updatedAt");
3042
- /** The given manager */
3043
- __publicField(this, "manager");
3044
- /** The rest client */
3045
- __publicField(this, "rest");
3046
- __publicField(this, "guild");
3047
- this.name = data?.name;
3048
- this.id = data?.id;
3049
- this.manager = manager;
3050
- this.rest = manager.rest;
3051
- this.guild = manager.guild;
3052
- this.duration = data?.duration ? new Date(data?.duration) : /* @__PURE__ */ new Date();
3053
- this.status = data?.status;
3054
- this.type = data?.type;
3055
- this.roleId = data?.roleId;
3056
- this.voiceChannelId = data?.voiceChannelId;
3057
- this.guild_id = data?.guild_id;
3058
- this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
3059
- this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
3060
- }
3061
- /** String representation of this member */
3062
- toString() {
3063
- return `<@${this.id}>`;
3064
- }
3065
- /**
3066
- * Fetches the member
3067
- * @returns New Instance of the member
3068
- */
3069
- async fetch() {
3070
- const route = Routes.vipmembers.get(this.guild_id, this.id);
3071
- const response = await this.rest.request({
3072
- method: "get",
3073
- url: route
3074
- });
3075
- const member = new _VipMember(response, this.manager);
3076
- this.manager.cache.set(member.id, member);
3077
- return member;
3078
- }
3079
- async reset() {
3080
- const route = Routes.vipmembers.get(this.guild_id, this.id);
3081
- const payload = { reset: true };
3082
- const response = await this.rest.request({
3083
- method: "DELETE",
3084
- url: route,
3085
- payload
3086
- });
3087
- __privateMethod(this, _VipMember_instances, updateData_fn).call(this, response);
3088
- this.type = response.type;
3089
- this.manager.set(response);
3090
- return this;
3091
- }
3092
- /**
3093
- * Update certain property
3094
- * @param data The new data to update with
3095
- * @returns
3096
- */
3097
- async update(data) {
3098
- const route = Routes.vipmembers.get(this.guild.id, this.id);
3099
- const payload = data;
3100
- const response = await this.rest.request({
3101
- method: "patch",
3102
- url: route,
3103
- payload
3104
- });
3105
- for (const k in response) {
3106
- if (k === "id") continue;
3107
- if (Object.hasOwn(this, k)) {
3108
- this[k] = response[k];
3109
- }
3110
- }
3111
- this.updatedAt = response?.updatedAt ? new Date(response?.updatedAt) : /* @__PURE__ */ new Date();
3112
- this.duration = response?.duration ? new Date(response?.duration) : /* @__PURE__ */ new Date();
3113
- this.createdAt = response?.createdAt ? new Date(response?.createdAt) : /* @__PURE__ */ new Date();
3114
- this.type = response.type;
3115
- this.manager.cache.set(this.id, this);
3116
- return this;
3117
- }
3118
- async delete() {
3119
- const route = Routes.vipmembers.delete(this.guild_id, this.id);
3120
- const response = await this.rest.request({
3121
- method: "DELETE",
3122
- url: route
3123
- });
3124
- this.manager.cache.delete(this.id);
3125
- return response;
3126
- }
3127
- toJSON() {
3128
- let json;
3129
- for (const [key, value] of Object.entries(this)) {
3130
- if (typeof value !== "function") {
3131
- json[key] = value;
3132
- }
3133
- }
3134
- return json;
3135
- }
3136
- };
3137
- _VipMember_instances = new WeakSet();
3138
- updateData_fn = function(data) {
3139
- for (const k in data) {
3140
- if (k === "id") continue;
3141
- if (Object.hasOwn(this, k)) {
3142
- this[k] = data[k];
3143
- this.data[k] = data[k];
3144
- }
3145
- }
3146
- };
3147
- var VipMember = _VipMember;
3148
-
3149
- // src/managers/vipmember/VipMemberManager.ts
3150
- var VipMemberManager = class extends BaseManager {
3151
- /**
3152
- * Manage vipmembers with the given client
3153
- * @param vipmembers An array of vipmembers
3154
- * @param rest The rest client
3155
- */
3156
- constructor(guild) {
3157
- super(guild);
3158
- this.guild = guild;
3159
- this.rest = guild.rest;
3160
- this.base_url = Routes.guilds.resource(guild.id, "vipmembers");
3161
- this.cache = new Collection("vipmembers");
3162
- }
3163
- async create(data) {
3164
- const route = Routes.vipmembers.create(this.guild.id);
3165
- const payload = { ...data };
3166
- const response = await this.rest.request({
3167
- method: "post",
3168
- url: route,
3169
- payload
3170
- });
3171
- const member = new VipMember(response, this);
3172
- this.cache.set(member?.id, member);
3173
- return member;
3174
- }
3175
- /**
3176
- * Fetch a member
3177
- * @param id Id of the member to fetch
3178
- * @returns VipMember
3179
- */
3180
- async fetch(options) {
3181
- if (options && options.cache) return this.cache;
3182
- if (options && options.memberId) {
3183
- const route2 = Routes.vipmembers.get(this.guild.id, options.memberId);
3184
- const payload = { guild_id: this.guild.id };
3185
- const response2 = await this.rest.request({
3186
- method: "get",
3187
- url: route2,
3188
- payload
3189
- });
3190
- if (!response2) return this.cache.get(options.memberId);
3191
- const member = new VipMember(response2, this);
3192
- this.cache.set(member?.id, member);
3193
- return member;
3194
- }
3195
- const route = Routes.vipmembers.getAll(this.guild.id);
3196
- const response = await this.rest.request({
3197
- method: "get",
3198
- url: route
3199
- });
3200
- if (Array.isArray(response) && response.length === 0) {
3201
- this.cache.clear();
3202
- return this.cache;
3203
- }
3204
- this.setAll(response);
3205
- return this.cache;
3206
- }
3207
- async updateMember(id, data) {
3208
- const route = Routes.vipmembers.update(this.guild.id, id);
3209
- const payload = { ...data, guild_id: this.guild.id };
3210
- const response = await this.rest.request({
3211
- method: "patch",
3212
- url: route,
3213
- payload
3214
- });
3215
- const member = this.set(response);
3216
- return member;
3217
- }
3218
- set(data) {
3219
- if (!data?.id) return;
3220
- const member = new VipMember(data, this);
3221
- this.cache.set(member.id, member);
3222
- return member;
3223
- }
3224
- setAll(data) {
3225
- if (!data) return this.cache;
3226
- for (let member of data) this.set(member);
3227
- return this.cache;
3228
- }
3229
- async resetAll() {
3230
- const route = Routes.vipmembers.getAll(this.guild.id);
3231
- const response = await this.rest.request({
3232
- method: "PUT",
3233
- url: route
3234
- });
3235
- this.setAll(response);
3236
- return this.cache;
3237
- }
3238
- async delete(id) {
3239
- Assertion.assertString(id);
3240
- Assertion.assertString(this.guild.id);
3241
- const route = Routes.vipmembers.delete(id, this.guild.id);
3242
- await this.rest.request({
3243
- method: "DELETE",
3244
- url: route
3245
- });
3246
- this.cache.delete(id);
3247
- return this.cache;
3248
- }
3249
- async deleteAll() {
3250
- Assertion.assertString(this.guild.id);
3251
- const route = Routes.vipmembers.deleteAll(this.guild.id);
3252
- const value = await this.rest.request({
3253
- method: "DELETE",
3254
- url: route
3255
- });
3256
- this.cache.clear();
3257
- return value;
3258
- }
3259
- };
3260
-
3261
- // src/managers/player/PlayerManager.ts
3262
- var PlayerManager = class extends Collection {
3263
- constructor(structure, base_url) {
3264
- super("players");
3265
- __publicField(this, "base_url");
3266
- __publicField(this, "rest");
3267
- __publicField(this, "guild");
3268
- this.base_url = base_url;
3269
- this.guild = structure.guild;
3270
- this.rest = structure.rest;
3271
- }
3272
- _set(data) {
3273
- this.clear();
3274
- if (Array.isArray(data)) {
3275
- for (let p of data) {
3276
- if (!p.id) continue;
3277
- this.set(p.id, {
3278
- id: p.id,
3279
- createdAt: p.createdAt ? new Date(p.createdAt) : /* @__PURE__ */ new Date(),
3280
- updateAt: p.updateAt ? new Date(p.updateAt) : /* @__PURE__ */ new Date()
3281
- });
3282
- }
3283
- } else {
3284
- if (!data.id) return;
3285
- this.set(data.id, {
3286
- id: data.id,
3287
- createdAt: data.createdAt ? new Date(data.createdAt) : /* @__PURE__ */ new Date(),
3288
- updateAt: data.updateAt ? new Date(data.updateAt) : /* @__PURE__ */ new Date()
3289
- });
3290
- }
3291
- return this;
3292
- }
3293
- /**
3294
- * Adds a player or an array of players to the structure.
3295
- * @param player A player or an array of players to be added
3296
- * @returns returns a collection of players
3297
- */
3298
- async add(player) {
3299
- let players = [];
3300
- if (Array.isArray(player)) {
3301
- for (let p of player) this.has(p.id) ? null : players.push(p);
3302
- } else this.has(player.id) ? null : players.push(player);
3303
- const payload = { set: players };
3304
- const response = await this.rest.request({
3305
- method: "PATCH",
3306
- payload,
3307
- url: this.base_url
3308
- });
3309
- return this._set(response.players);
3310
- }
3311
- /**
3312
- * Remover a player or an array of players.
3313
- * @param player The player or an array of players to be removed
3314
- * @returns Player manager
3315
- */
3316
- async remove(player) {
3317
- const ids = new Set(Array.isArray(player) ? player.map((p) => p.id) : [player.id]);
3318
- const players = this.toArray().filter((p) => !ids.has(p.id));
3319
- const payload = { set: players };
3320
- const response = await this.rest.request({
3321
- method: "PATCH",
3322
- payload,
3323
- url: this.base_url
3324
- });
3325
- return this._set(response.players);
3326
- }
3327
- };
3328
-
3329
- // src/structures/bet/GuildBet.ts
3330
- var _GuildBet_instances, updateInternals_fn8;
3331
- var GuildBet = class {
3332
- constructor(data, manager) {
3333
- __privateAdd(this, _GuildBet_instances);
3334
- /** The bet's type */
3335
- __publicField(this, "type");
3336
- /** The bet's mode */
3337
- __publicField(this, "mode");
3338
- /** The bet's status */
3339
- __publicField(this, "status");
3340
- /** The bet's maximum size */
3341
- __publicField(this, "maximumSize");
3342
- /** The bet's price */
3343
- __publicField(this, "price");
3344
- /** The bet's players */
3345
- __publicField(this, "players");
3346
- __publicField(this, "teams");
3347
- /** The bet's channel */
3348
- __publicField(this, "channels");
3349
- /** The bet's messages */
3350
- __publicField(this, "messages");
3351
- /** The id of the winner */
3352
- __publicField(this, "winners");
3353
- /** The id of the loser */
3354
- __publicField(this, "losers");
3355
- /** The bet's creator id */
3356
- __publicField(this, "creatorId");
3357
- /** The bet's mediator */
3358
- __publicField(this, "mediatorId");
3359
- /** The bet's confirmers */
3360
- __publicField(this, "confirmed");
3361
- /** Creation Date */
3362
- __publicField(this, "createdAt");
3363
- /** Updated Date */
3364
- __publicField(this, "updatedAt");
3365
- /** Bet's id */
3366
- __publicField(this, "_id");
3367
- __publicField(this, "queues");
3368
- __publicField(this, "guild_id");
3369
- __publicField(this, "rest");
3370
- __publicField(this, "guild");
3371
- __publicField(this, "manager");
3372
- this.manager = manager;
3373
- this.guild = manager.guild;
3374
- this.rest = manager.rest;
3375
- this._id = data?._id;
3376
- this.guild_id = data?.guild_id;
3377
- this.type = data?.type;
3378
- this.mode = data?.mode;
3379
- this.status = data?.status;
3380
- this.maximumSize = data?.maximumSize;
3381
- this.price = data?.price;
3382
- this.teams = data?.teams;
3383
- this.channels = data?.channels;
3384
- this.players = new PlayerManager(this, Routes.guilds.bets.resource(this.guild_id, this._id, "players"));
3385
- this.messages = new MessagesManager(this, Routes.guilds.bets.resource(this.guild_id, this._id, "messages"));
3386
- this.winners = data?.winners;
3387
- this.losers = data?.losers;
3388
- this.creatorId = data?.creatorId;
3389
- this.mediatorId = data?.mediatorId;
3390
- this.confirmed = data?.confirmed;
3391
- this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
3392
- this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
3393
- this.queues = [];
3394
- for (let queue of data.queues ?? []) {
3395
- this.queues.push({
3396
- _id: queue?._id,
3397
- type: queue?.type,
3398
- players: queue?.players,
3399
- updatedAt: queue?.updatedAt ? new Date(queue?.updatedAt) : /* @__PURE__ */ new Date(),
3400
- createdAt: queue?.createdAt ? new Date(queue?.createdAt) : /* @__PURE__ */ new Date()
3401
- });
3402
- }
3403
- if (data?.messages?.length !== 0) this.messages.set(data.messages);
3404
- if (data?.players.length !== 0) this.players._set(data.players);
3405
- }
3406
- toString() {
3407
- return this._id;
3408
- }
3409
- async fetch() {
3410
- const route = Routes.guilds.bets.get(this.guild.id, this._id);
3411
- const response = await this.rest.request({ url: route, method: "GET" });
3412
- return __privateMethod(this, _GuildBet_instances, updateInternals_fn8).call(this, response);
3413
- }
3414
- async addPlayer(player, queue_type) {
3415
- if (this.players.length === 2) return this;
3416
- if (this.players.has(player.id)) return this;
3417
- this.players.set(player.id, player);
3418
- if (queue_type) {
3419
- const queue = this.queues.find((q) => q.type === queue_type);
3420
- if (!queue) return this;
3421
- for (const q of this.queues) {
3422
- q.players = q.players.filter((p) => p.id !== player.id);
3423
- }
3424
- if (!queue.players.some((p) => p.id === player.id)) {
3425
- queue.players.push({ id: player.id });
3426
- }
3427
- }
3428
- return await this.update({
3429
- players: this.players.toArray(),
3430
- queues: this.queues
3431
- });
3432
- }
3433
- async removePlayer(player) {
3434
- if (!this.players.some((p) => p.id === player.id)) return this;
3435
- let players = this.players.toArray();
3436
- players = this.players.filter((p) => p.id !== player.id).toArray();
3437
- for (const q of this.queues) {
3438
- q.players = q.players.filter((p) => p.id !== player.id);
3439
- }
3440
- return await this.update({
3441
- players,
3442
- queues: this.queues
3443
- });
3444
- }
3445
- async update(data) {
3446
- const payload = data;
3447
- const route = Routes.guilds.bets.update(this.guild.id, this._id);
3448
- const response = await this.rest.request({ method: "patch", url: route, payload });
3449
- return __privateMethod(this, _GuildBet_instances, updateInternals_fn8).call(this, response);
3450
- }
3451
- async delete() {
3452
- const route = Routes.guilds.bets.delete(this.manager.guild.id, this._id);
3453
- const response = await this.rest.request({
3454
- method: "DELETE",
3455
- url: route
3456
- });
3457
- this.rest.emit("betDelete", this);
3458
- this.manager.cache.delete(this._id);
3459
- return response;
3460
- }
3461
- toJSON() {
3462
- let json = {};
3463
- for (const [key, value] of Object.entries(this)) {
3464
- const exclude = ["rest", "guild", "manager"];
3465
- if (exclude.includes(key)) continue;
3466
- if (typeof value !== "function") {
3467
- json[key] = value;
3468
- }
3469
- }
3470
- return {
3471
- ...json,
3472
- messages: this?.messages instanceof MessagesManager ? this.messages?.cache?.toArray() : [],
3473
- players: this.players.toArray()
3474
- };
3475
- }
3476
- };
3477
- _GuildBet_instances = new WeakSet();
3478
- updateInternals_fn8 = function(data) {
3479
- for (let key in data) {
3480
- if (key === "_id" || key === "createdAt") continue;
3481
- if (key === "messages") {
3482
- this.messages.set(data[key]);
3483
- continue;
3484
- }
3485
- if (key === "players") {
3486
- this.players._set(data[key]);
3487
- continue;
3488
- }
3489
- if (key in this) {
3490
- this[key] = data[key];
3491
- }
3492
- }
3493
- if (data?.messages?.length !== 0) {
3494
- if (this?.messages instanceof MessagesManager) this.messages.set(data.messages);
3495
- else {
3496
- this.messages = new MessagesManager(this, Routes.guilds.matches.resource(this.guild_id, this._id, "messages"));
3497
- this.messages.set(data.messages);
3498
- }
3499
- }
3500
- this.updatedAt = /* @__PURE__ */ new Date();
3501
- this.createdAt = new Date(data.createdAt);
3502
- this.manager.set(this);
3503
- return this;
3504
- };
3505
-
3506
- // src/structures/logentry/LogEntry.ts
3507
- var _LogEntry_instances, updateInternals_fn9;
3508
- var LogEntry = class {
3509
- constructor(data, manager) {
3510
- __privateAdd(this, _LogEntry_instances);
3511
- __publicField(this, "_id");
3512
- __publicField(this, "guild_id");
3513
- __publicField(this, "user_id");
3514
- __publicField(this, "admin_id");
3515
- __publicField(this, "object_id");
3516
- __publicField(this, "type");
3517
- __publicField(this, "description");
3518
- __publicField(this, "change");
3519
- __publicField(this, "before");
3520
- __publicField(this, "after");
3521
- __publicField(this, "logs_channel_id");
3522
- __publicField(this, "createdAt");
3523
- __publicField(this, "updatedAt");
3524
- __publicField(this, "manager");
3525
- /** The given guild */
3526
- __publicField(this, "guild");
3527
- /** The rest client */
3528
- __publicField(this, "rest");
3529
- this.manager = manager;
3530
- this.guild = manager.guild;
3531
- this._id = data?._id;
3532
- this.guild_id = data?.guild_id;
3533
- this.user_id = data?.user_id;
3534
- this.admin_id = data?.admin_id;
3535
- this.object_id = data?.object_id;
3536
- this.type = data?.type;
3537
- this.description = data?.description;
3538
- this.change = data?.change;
3539
- this.before = data?.before;
3540
- this.after = data?.after;
3541
- this.logs_channel_id = data?.logs_channel_id;
3542
- this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
3543
- this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
3544
- }
3545
- async fetch() {
3546
- const route = Routes.fields("guilds", this.guild.id, "logentries", this._id);
3547
- const response = await this.rest.request({ url: route, method: "GET" });
3548
- return __privateMethod(this, _LogEntry_instances, updateInternals_fn9).call(this, response);
3549
- }
3550
- toJSON() {
3551
- const json = {};
3552
- for (const [key, value] of Object.entries(this)) {
3553
- if (typeof value !== "function") {
3554
- json[key] = value;
3555
- }
3556
- }
3557
- return json;
3558
- }
3559
- };
3560
- _LogEntry_instances = new WeakSet();
3561
- updateInternals_fn9 = function(data) {
3562
- for (let key in data) {
3563
- if (key === "id" || key === "createdAt") continue;
3564
- if (key in this) {
3565
- this[key] = data[key];
3566
- }
3567
- }
3568
- this.updatedAt = /* @__PURE__ */ new Date();
3569
- this.manager.set(this);
3570
- return this;
3571
- };
3572
-
3573
- // src/structures/ticket/Ticket.ts
3574
- var _GuildTicket_instances, updateInternals_fn10;
3575
- var GuildTicket = class {
3576
- constructor(data, manager) {
3577
- __privateAdd(this, _GuildTicket_instances);
3578
- __publicField(this, "_id");
3579
- __publicField(this, "guild_id");
3580
- __publicField(this, "type");
3581
- __publicField(this, "status");
3582
- __publicField(this, "admin_id");
3583
- __publicField(this, "channel_id");
3584
- __publicField(this, "closed_by_id");
3585
- __publicField(this, "creator_id");
3586
- __publicField(this, "customer_rating");
3587
- __publicField(this, "messages");
3588
- __publicField(this, "createdAt");
3589
- __publicField(this, "updatedAt");
3590
- __publicField(this, "rest");
3591
- __publicField(this, "guild");
3592
- __publicField(this, "manager");
3593
- this.manager = manager;
3594
- this.guild = manager.guild;
3595
- this.rest = manager.rest;
3596
- this._id = data?._id;
3597
- this.type = data?.type;
3598
- this.admin_id = data?.admin_id;
3599
- this.guild_id = data?.guild_id;
3600
- this.channel_id = data?.channel_id;
3601
- this.creator_id = data?.creator_id;
3602
- this.status = data?.status;
3603
- this.customer_rating = data?.customer_rating;
3604
- this.messages = data?.messages;
3605
- this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
3606
- this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
3607
- }
3608
- async fetch() {
3609
- const route = Routes.guilds.tickets.get(this.guild.id, this._id);
3610
- const response = await this.rest.request({
3611
- method: "GET",
3612
- url: route
3613
- });
3614
- return __privateMethod(this, _GuildTicket_instances, updateInternals_fn10).call(this, response);
3615
- }
3616
- async setCustomerRating(rating) {
3617
- const route = Routes.guilds.tickets.resource(this.guild.id, this._id, "customer_rating");
3618
- const payload = { set: rating };
3619
- const response = await this.rest.request({
3620
- method: "PATCH",
3621
- url: route,
3622
- payload
3623
- });
3624
- return __privateMethod(this, _GuildTicket_instances, updateInternals_fn10).call(this, response);
3625
- }
3626
- async setAdminId(id) {
3627
- const route = Routes.guilds.tickets.resource(this.guild.id, this._id, "admin_id");
3628
- const payload = { set: id };
3629
- const response = await this.rest.request({
3630
- method: "PATCH",
3631
- url: route,
3632
- payload
3633
- });
3634
- return __privateMethod(this, _GuildTicket_instances, updateInternals_fn10).call(this, response);
3635
- }
3636
- async setChannelId(id) {
3637
- const route = Routes.guilds.tickets.resource(this.guild.id, this._id, "channel_id");
3638
- const payload = { set: id };
3639
- const response = await this.rest.request({
3640
- method: "PATCH",
3641
- url: route,
3642
- payload
3643
- });
3644
- return __privateMethod(this, _GuildTicket_instances, updateInternals_fn10).call(this, response);
3645
- }
3646
- async setClosedById(id) {
3647
- const route = Routes.guilds.tickets.resource(this.guild.id, this._id, "closed_by_id");
3648
- const payload = { set: id };
3649
- const response = await this.rest.request({
3650
- method: "PATCH",
3651
- url: route,
3652
- payload
3653
- });
3654
- return __privateMethod(this, _GuildTicket_instances, updateInternals_fn10).call(this, response);
3655
- }
3656
- async setStatus(status) {
3657
- const route = Routes.guilds.tickets.resource(this.guild.id, this._id, "status");
3658
- const payload = { set: status };
3659
- const response = await this.rest.request({
3660
- method: "PATCH",
3661
- url: route,
3662
- payload
3663
- });
3664
- return __privateMethod(this, _GuildTicket_instances, updateInternals_fn10).call(this, response);
3665
- }
3666
- async addMessage(message) {
3667
- const route = Routes.guilds.tickets.resource(this.guild.id, this._id, "messages");
3668
- const payload = { set: [...this.messages, message] };
3669
- const response = await this.rest.request({
3670
- method: "PATCH",
3671
- url: route,
3672
- payload
3673
- });
3674
- return __privateMethod(this, _GuildTicket_instances, updateInternals_fn10).call(this, response);
3675
- }
3676
- };
3677
- _GuildTicket_instances = new WeakSet();
3678
- updateInternals_fn10 = function(data) {
3679
- for (let key in data) {
3680
- if (key === "id" || key === "createdAt") continue;
3681
- if (key in this) {
3682
- this[key] = data[key];
3683
- }
3684
- }
3685
- this.updatedAt = /* @__PURE__ */ new Date();
3686
- this.createdAt = new Date(data.createdAt);
3687
- this.manager.set(this);
3688
- return this;
3689
- };
3690
-
3691
- // src/structures/minesgame/MinesGame.ts
3692
- var _MinesGame_instances, updateInternals_fn11;
3693
- var MinesGame = class {
3694
- constructor(data, manager) {
3695
- __privateAdd(this, _MinesGame_instances);
3696
- __publicField(this, "guild_id");
3697
- __publicField(this, "_id");
3698
- __publicField(this, "creatorId");
3699
- __publicField(this, "maxMines");
3700
- __publicField(this, "bombs");
3701
- __publicField(this, "bombsPosition");
3702
- __publicField(this, "bet");
3703
- __publicField(this, "multiplier");
3704
- __publicField(this, "status");
3705
- __publicField(this, "createdAt");
3706
- __publicField(this, "updatedAt");
3707
- __publicField(this, "rest");
3708
- __publicField(this, "manager");
3709
- this.manager = manager;
3710
- this.rest = manager.rest;
3711
- this.guild_id = data?.guild_id;
3712
- this.bombsPosition = data?.bombsPosition;
3713
- this._id = data?._id;
3714
- this.multiplier = data?.multiplier;
3715
- this.creatorId = data?.creatorId;
3716
- this.maxMines = data?.maxMines;
3717
- this.bombs = data?.bombs;
3718
- this.bet = data?.bet;
3719
- this.status = data?.status;
3720
- this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
3721
- this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
3722
- }
3723
- async fetch() {
3724
- const route = `/${Routes.fields("minesgames", this._id)}`;
3725
- const response = await this.rest.request({
3726
- method: "GET",
3727
- url: route
3728
- });
3729
- return __privateMethod(this, _MinesGame_instances, updateInternals_fn11).call(this, response);
3730
- }
3731
- async delete() {
3732
- const route = `/${Routes.fields("minesgames", this._id)}`;
3733
- const response = await this.rest.request({
3734
- method: "delete",
3735
- url: route
3736
- });
3737
- return __privateMethod(this, _MinesGame_instances, updateInternals_fn11).call(this, response);
3738
- }
3739
- async update(data) {
3740
- const route = `/${Routes.fields("minesgames", this._id)}`;
3741
- const response = await this.rest.request({
3742
- method: "PATCH",
3743
- url: route,
3744
- payload: data
3745
- });
3746
- return __privateMethod(this, _MinesGame_instances, updateInternals_fn11).call(this, response);
3747
- }
3748
- };
3749
- _MinesGame_instances = new WeakSet();
3750
- updateInternals_fn11 = function(data) {
3751
- for (let key in data) {
3752
- if (key === "id" || key === "createdAt") continue;
3753
- if (key in this) {
3754
- this[key] = data[key];
3755
- }
3756
- }
3757
- this.updatedAt = /* @__PURE__ */ new Date();
3758
- this.manager.set(this);
3759
- return this;
3760
- };
3761
- export {
3762
- Collection,
3763
- Guild2 as Guild,
3764
- GuildBet,
3765
- GuildBetUser,
3766
- GuildMatch,
3767
- GuildMediator,
3768
- GuildTicket,
3769
- GuildUser,
3770
- LogEntry,
3771
- MinesGame,
3772
- VipMember
3773
- };