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