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