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