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