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