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