@duque.edits/sdk 1.1.2 → 1.3.0

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