@duque.edits/sdk 1.0.87 → 1.1.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 (310) hide show
  1. package/dist/index-BHHXH2xN.d.mts +1379 -0
  2. package/dist/index-C87LbIta.d.ts +1379 -0
  3. package/dist/index.d.mts +22 -0
  4. package/dist/index.d.ts +22 -0
  5. package/dist/index.js +4054 -19
  6. package/dist/index.mjs +4007 -0
  7. package/dist/managers/automaticmessage/AutomaticMessageManager.d.mts +20 -0
  8. package/dist/managers/automaticmessage/AutomaticMessageManager.d.ts +20 -0
  9. package/dist/managers/automaticmessage/AutomaticMessageManager.js +798 -0
  10. package/dist/managers/automaticmessage/AutomaticMessageManager.mjs +790 -0
  11. package/dist/managers/base.d.mts +20 -0
  12. package/dist/managers/base.d.ts +20 -0
  13. package/dist/managers/base.js +124 -15
  14. package/dist/managers/base.mjs +104 -0
  15. package/dist/managers/bet/GuildBetManager.d.mts +20 -0
  16. package/dist/managers/bet/GuildBetManager.d.ts +20 -0
  17. package/dist/managers/bet/GuildBetManager.js +947 -58
  18. package/dist/managers/bet/GuildBetManager.mjs +946 -0
  19. package/dist/managers/betuser/GuildBetUserManager.d.mts +20 -0
  20. package/dist/managers/betuser/GuildBetUserManager.d.ts +20 -0
  21. package/dist/managers/betuser/GuildBetUserManager.js +506 -78
  22. package/dist/managers/betuser/GuildBetUserManager.mjs +489 -0
  23. package/dist/managers/buffer/BufferManager.d.mts +20 -0
  24. package/dist/managers/buffer/BufferManager.d.ts +20 -0
  25. package/dist/managers/buffer/BufferManager.js +247 -37
  26. package/dist/managers/buffer/BufferManager.mjs +223 -0
  27. package/dist/managers/guild/GuildManager.d.mts +20 -0
  28. package/dist/managers/guild/GuildManager.d.ts +20 -0
  29. package/dist/managers/guild/GuildManager.js +3598 -87
  30. package/dist/managers/guild/GuildManager.mjs +3600 -0
  31. package/dist/managers/index.d.mts +20 -0
  32. package/dist/managers/index.d.ts +20 -0
  33. package/dist/managers/index.js +3766 -29
  34. package/dist/managers/index.mjs +3745 -0
  35. package/dist/managers/logs/LogManager.d.mts +20 -0
  36. package/dist/managers/logs/LogManager.d.ts +20 -0
  37. package/dist/managers/logs/LogManager.js +721 -55
  38. package/dist/managers/logs/LogManager.mjs +726 -0
  39. package/dist/managers/match/GuildMatchManager.d.mts +20 -0
  40. package/dist/managers/match/GuildMatchManager.d.ts +20 -0
  41. package/dist/managers/match/GuildMatchManager.js +1285 -95
  42. package/dist/managers/match/GuildMatchManager.mjs +1289 -0
  43. package/dist/managers/mediator/GuildMediatorManager.d.mts +20 -0
  44. package/dist/managers/mediator/GuildMediatorManager.d.ts +20 -0
  45. package/dist/managers/mediator/GuildMediatorManager.js +434 -86
  46. package/dist/managers/mediator/GuildMediatorManager.mjs +417 -0
  47. package/dist/managers/message/MessagesManager.d.mts +20 -0
  48. package/dist/managers/message/MessagesManager.d.ts +20 -0
  49. package/dist/managers/message/MessagesManager.js +158 -55
  50. package/dist/managers/message/MessagesManager.mjs +134 -0
  51. package/dist/managers/minesgame/MinesGameManager.d.mts +20 -0
  52. package/dist/managers/minesgame/MinesGameManager.d.ts +20 -0
  53. package/dist/managers/minesgame/MinesGameManager.js +714 -61
  54. package/dist/managers/minesgame/MinesGameManager.mjs +712 -0
  55. package/dist/managers/permission/GuildPermissionManager.d.mts +20 -0
  56. package/dist/managers/permission/GuildPermissionManager.d.ts +20 -0
  57. package/dist/managers/permission/GuildPermissionManager.js +277 -55
  58. package/dist/managers/permission/GuildPermissionManager.mjs +253 -0
  59. package/dist/managers/player/PlayerManager.d.mts +20 -0
  60. package/dist/managers/player/PlayerManager.d.ts +20 -0
  61. package/dist/managers/player/PlayerManager.js +174 -71
  62. package/dist/managers/player/PlayerManager.mjs +155 -0
  63. package/dist/managers/ticket/TicketManager.d.mts +20 -0
  64. package/dist/managers/ticket/TicketManager.d.ts +20 -0
  65. package/dist/managers/ticket/TicketManager.js +812 -116
  66. package/dist/managers/ticket/TicketManager.mjs +813 -0
  67. package/dist/managers/user/GuildUserManager.d.mts +20 -0
  68. package/dist/managers/user/GuildUserManager.d.ts +20 -0
  69. package/dist/managers/user/GuildUserManager.js +574 -90
  70. package/dist/managers/user/GuildUserManager.mjs +554 -0
  71. package/dist/managers/vipmember/VipMemberManager.d.mts +20 -0
  72. package/dist/managers/vipmember/VipMemberManager.d.ts +20 -0
  73. package/dist/managers/vipmember/VipMemberManager.js +525 -114
  74. package/dist/managers/vipmember/VipMemberManager.mjs +510 -0
  75. package/dist/rest/APIEndpoints.d.mts +12 -0
  76. package/{types → dist}/rest/APIEndpoints.d.ts +4 -3
  77. package/dist/rest/APIEndpoints.js +40 -10
  78. package/dist/rest/APIEndpoints.mjs +19 -0
  79. package/dist/rest/REST.d.mts +20 -0
  80. package/dist/rest/REST.d.ts +20 -0
  81. package/dist/rest/REST.js +3828 -112
  82. package/dist/rest/REST.mjs +3832 -0
  83. package/dist/rest/Routes.d.mts +104 -0
  84. package/{types → dist}/rest/Routes.d.ts +7 -3
  85. package/dist/rest/Routes.js +124 -98
  86. package/dist/rest/Routes.mjs +104 -0
  87. package/dist/rest/index.d.mts +22 -0
  88. package/dist/rest/index.d.ts +22 -0
  89. package/dist/rest/index.js +3856 -18
  90. package/dist/rest/index.mjs +3847 -0
  91. package/dist/structures/Collection.d.mts +19 -0
  92. package/{types → dist}/structures/Collection.d.ts +3 -1
  93. package/dist/structures/Collection.js +102 -81
  94. package/dist/structures/Collection.mjs +87 -0
  95. package/dist/structures/automaticmessage/AutomaticMessage.d.mts +20 -0
  96. package/dist/structures/automaticmessage/AutomaticMessage.d.ts +20 -0
  97. package/dist/structures/automaticmessage/AutomaticMessage.js +613 -0
  98. package/dist/structures/automaticmessage/AutomaticMessage.mjs +605 -0
  99. package/dist/structures/bet/GuildBet.d.mts +20 -0
  100. package/dist/structures/bet/GuildBet.d.ts +20 -0
  101. package/dist/structures/bet/GuildBet.js +861 -169
  102. package/dist/structures/bet/GuildBet.mjs +872 -0
  103. package/dist/structures/betuser/GuildBetUser.d.mts +20 -0
  104. package/dist/structures/betuser/GuildBetUser.d.ts +20 -0
  105. package/dist/structures/betuser/GuildBetUser.js +323 -201
  106. package/dist/structures/betuser/GuildBetUser.mjs +316 -0
  107. package/dist/structures/guild/Guild.d.mts +20 -0
  108. package/dist/structures/guild/Guild.d.ts +20 -0
  109. package/dist/structures/guild/Guild.js +3499 -452
  110. package/dist/structures/guild/Guild.mjs +3513 -0
  111. package/dist/structures/index.d.mts +20 -0
  112. package/dist/structures/index.d.ts +20 -0
  113. package/dist/structures/index.js +3610 -26
  114. package/dist/structures/index.mjs +3593 -0
  115. package/dist/structures/logentry/LogEntry.d.mts +20 -0
  116. package/dist/structures/logentry/LogEntry.d.ts +20 -0
  117. package/dist/structures/logentry/LogEntry.js +568 -62
  118. package/dist/structures/logentry/LogEntry.mjs +566 -0
  119. package/dist/structures/match/GuildMatch.d.mts +20 -0
  120. package/dist/structures/match/GuildMatch.d.ts +20 -0
  121. package/dist/structures/match/GuildMatch.js +1165 -250
  122. package/dist/structures/match/GuildMatch.mjs +1178 -0
  123. package/dist/structures/mediator/GuildMediator.d.mts +20 -0
  124. package/dist/structures/mediator/GuildMediator.d.ts +20 -0
  125. package/dist/structures/mediator/GuildMediator.js +252 -124
  126. package/dist/structures/mediator/GuildMediator.mjs +236 -0
  127. package/dist/structures/minesgame/MinesGame.d.mts +20 -0
  128. package/dist/structures/minesgame/MinesGame.d.ts +20 -0
  129. package/dist/structures/minesgame/MinesGame.js +574 -68
  130. package/dist/structures/minesgame/MinesGame.mjs +570 -0
  131. package/dist/structures/ticket/Ticket.d.mts +20 -0
  132. package/dist/structures/ticket/Ticket.d.ts +20 -0
  133. package/dist/structures/ticket/Ticket.js +621 -115
  134. package/dist/structures/ticket/Ticket.mjs +617 -0
  135. package/dist/structures/user/GuildUser.d.mts +20 -0
  136. package/dist/structures/user/GuildUser.d.ts +20 -0
  137. package/dist/structures/user/GuildUser.js +374 -257
  138. package/dist/structures/user/GuildUser.mjs +372 -0
  139. package/dist/structures/vipmember/VipMember.d.mts +20 -0
  140. package/dist/structures/vipmember/VipMember.d.ts +20 -0
  141. package/dist/structures/vipmember/VipMember.js +261 -123
  142. package/dist/structures/vipmember/VipMember.mjs +250 -0
  143. package/dist/types/RestTypes.d.mts +20 -0
  144. package/dist/types/RestTypes.d.ts +20 -0
  145. package/dist/types/RestTypes.js +17 -1
  146. package/dist/types/RestTypes.mjs +0 -0
  147. package/dist/types/api/APIAdvert.d.mts +13 -0
  148. package/{types → dist}/types/api/APIAdvert.d.ts +3 -1
  149. package/dist/types/api/APIAdvert.js +17 -1
  150. package/dist/types/api/APIAdvert.mjs +0 -0
  151. package/dist/types/api/APIAutomaticMessage.d.mts +20 -0
  152. package/dist/types/api/APIAutomaticMessage.d.ts +20 -0
  153. package/dist/types/api/APIAutomaticMessage.js +18 -0
  154. package/dist/types/api/APIAutomaticMessage.mjs +0 -0
  155. package/dist/types/api/APIBaseChannel.d.mts +12 -0
  156. package/{types → dist}/types/api/APIBaseChannel.d.ts +3 -1
  157. package/dist/types/api/APIBaseChannel.js +17 -1
  158. package/dist/types/api/APIBaseChannel.mjs +0 -0
  159. package/{types/types/api/APIGuildEmoji.d.ts → dist/types/api/APIBetChannel.d.mts} +6 -6
  160. package/{types → dist}/types/api/APIBetChannel.d.ts +3 -1
  161. package/dist/types/api/APIBetChannel.js +17 -1
  162. package/dist/types/api/APIBetChannel.mjs +0 -0
  163. package/dist/types/api/APICode.d.mts +12 -0
  164. package/{types → dist}/types/api/APICode.d.ts +3 -1
  165. package/dist/types/api/APICode.js +17 -1
  166. package/dist/types/api/APICode.mjs +0 -0
  167. package/dist/types/api/APIGiveaway.d.mts +29 -0
  168. package/{types → dist}/types/api/APIGiveaway.d.ts +5 -3
  169. package/dist/types/api/APIGiveaway.js +17 -1
  170. package/dist/types/api/APIGiveaway.mjs +0 -0
  171. package/dist/types/api/APIGuild.d.mts +20 -0
  172. package/dist/types/api/APIGuild.d.ts +20 -0
  173. package/dist/types/api/APIGuild.js +72 -41
  174. package/dist/types/api/APIGuild.mjs +46 -0
  175. package/dist/types/api/APIGuildAdvert.d.mts +10 -0
  176. package/{types → dist}/types/api/APIGuildAdvert.d.ts +3 -1
  177. package/dist/types/api/APIGuildAdvert.js +17 -1
  178. package/dist/types/api/APIGuildAdvert.mjs +0 -0
  179. package/dist/types/api/APIGuildBet.d.mts +20 -0
  180. package/dist/types/api/APIGuildBet.d.ts +20 -0
  181. package/dist/types/api/APIGuildBet.js +32 -6
  182. package/dist/types/api/APIGuildBet.mjs +8 -0
  183. package/dist/types/api/APIGuildBetUser.d.mts +20 -0
  184. package/dist/types/api/APIGuildBetUser.d.ts +20 -0
  185. package/dist/types/api/APIGuildBetUser.js +17 -1
  186. package/dist/types/api/APIGuildBetUser.mjs +0 -0
  187. package/{types/types/api/APIGuildMessage.d.ts → dist/types/api/APIGuildChannel.d.mts} +5 -3
  188. package/{types → dist}/types/api/APIGuildChannel.d.ts +3 -1
  189. package/dist/types/api/APIGuildChannel.js +17 -1
  190. package/dist/types/api/APIGuildChannel.mjs +0 -0
  191. package/dist/types/api/APIGuildGroupedChannel.d.mts +20 -0
  192. package/dist/types/api/APIGuildGroupedChannel.d.ts +20 -0
  193. package/dist/types/api/APIGuildGroupedChannel.js +17 -1
  194. package/dist/types/api/APIGuildGroupedChannel.mjs +0 -0
  195. package/dist/types/api/APIGuildMatch.d.mts +20 -0
  196. package/dist/types/api/APIGuildMatch.d.ts +20 -0
  197. package/dist/types/api/APIGuildMatch.js +39 -11
  198. package/dist/types/api/APIGuildMatch.mjs +14 -0
  199. package/dist/types/api/APIGuildMediator.d.mts +16 -0
  200. package/{types → dist}/types/api/APIGuildMediator.d.ts +3 -1
  201. package/dist/types/api/APIGuildMediator.js +17 -1
  202. package/dist/types/api/APIGuildMediator.mjs +0 -0
  203. package/dist/types/api/APIGuildPermissions.d.mts +15 -0
  204. package/{types → dist}/types/api/APIGuildPermissions.d.ts +5 -3
  205. package/dist/types/api/APIGuildPermissions.js +37 -11
  206. package/dist/types/api/APIGuildPermissions.mjs +13 -0
  207. package/dist/types/api/APIGuildShop.d.mts +15 -0
  208. package/{types → dist}/types/api/APIGuildShop.d.ts +6 -2
  209. package/dist/types/api/APIGuildShop.js +17 -1
  210. package/dist/types/api/APIGuildShop.mjs +0 -0
  211. package/dist/types/api/APIGuildTicket.d.mts +19 -0
  212. package/{types → dist}/types/api/APIGuildTicket.d.ts +5 -2
  213. package/dist/types/api/APIGuildTicket.js +17 -1
  214. package/dist/types/api/APIGuildTicket.mjs +0 -0
  215. package/dist/types/api/APIGuildUser.d.mts +20 -0
  216. package/dist/types/api/APIGuildUser.d.ts +20 -0
  217. package/dist/types/api/APIGuildUser.js +17 -1
  218. package/dist/types/api/APIGuildUser.mjs +0 -0
  219. package/dist/types/api/APILogEntry.d.mts +32 -0
  220. package/{types → dist}/types/api/APILogEntry.d.ts +4 -2
  221. package/dist/types/api/APILogEntry.js +44 -18
  222. package/dist/types/api/APILogEntry.mjs +20 -0
  223. package/dist/types/api/APIMessage.d.mts +13 -0
  224. package/{types → dist}/types/api/APIMessage.d.ts +3 -1
  225. package/dist/types/api/APIMessage.js +17 -1
  226. package/dist/types/api/APIMessage.mjs +0 -0
  227. package/dist/types/api/APIMinesGame.d.mts +15 -0
  228. package/{types → dist}/types/api/APIMinesGame.d.ts +3 -1
  229. package/dist/types/api/APIMinesGame.js +17 -1
  230. package/dist/types/api/APIMinesGame.mjs +0 -0
  231. package/dist/types/api/APIPlayer.d.mts +10 -0
  232. package/{types → dist}/types/api/APIPlayer.d.ts +3 -1
  233. package/dist/types/api/APIPlayer.js +17 -1
  234. package/dist/types/api/APIPlayer.mjs +0 -0
  235. package/dist/types/api/APIProduct.d.mts +22 -0
  236. package/{types → dist}/types/api/APIProduct.d.ts +5 -2
  237. package/dist/types/api/APIProduct.js +17 -2
  238. package/dist/types/api/APIProduct.mjs +0 -0
  239. package/dist/types/api/APIVipMember.d.mts +22 -0
  240. package/{types → dist}/types/api/APIVipMember.d.ts +3 -1
  241. package/dist/types/api/APIVipMember.js +17 -1
  242. package/dist/types/api/APIVipMember.mjs +0 -0
  243. package/dist/types/api/index.d.mts +20 -0
  244. package/dist/types/api/index.d.ts +20 -0
  245. package/dist/types/api/index.js +171 -70
  246. package/dist/types/api/index.mjs +135 -0
  247. package/dist/types/index.d.mts +20 -0
  248. package/dist/types/index.d.ts +20 -0
  249. package/dist/types/index.js +171 -16
  250. package/dist/types/index.mjs +135 -0
  251. package/dist/utils/Assertion.d.mts +34 -0
  252. package/{types → dist}/utils/Assertion.d.ts +3 -1
  253. package/dist/utils/Assertion.js +76 -59
  254. package/dist/utils/Assertion.mjs +52 -0
  255. package/dist/utils/getRandomNumber.d.mts +3 -0
  256. package/dist/utils/getRandomNumber.d.ts +3 -0
  257. package/dist/utils/getRandomNumber.js +29 -3
  258. package/dist/utils/getRandomNumber.mjs +7 -0
  259. package/dist/utils/randomKeyGenerator.d.mts +3 -0
  260. package/dist/utils/randomKeyGenerator.d.ts +3 -0
  261. package/dist/utils/randomKeyGenerator.js +33 -0
  262. package/dist/utils/randomKeyGenerator.mjs +8 -0
  263. package/package.json +12 -6
  264. package/dist/types/api/APIBetMessage.js +0 -2
  265. package/dist/types/api/APIGuildEmoji.js +0 -2
  266. package/dist/types/api/APIGuildRole.js +0 -2
  267. package/dist/types/api/APILogMessage.js +0 -2
  268. package/types/index.d.ts +0 -4
  269. package/types/managers/base.d.ts +0 -14
  270. package/types/managers/bet/GuildBetManager.d.ts +0 -15
  271. package/types/managers/betuser/GuildBetUserManager.d.ts +0 -18
  272. package/types/managers/buffer/BufferManager.d.ts +0 -19
  273. package/types/managers/guild/GuildManager.d.ts +0 -32
  274. package/types/managers/index.d.ts +0 -14
  275. package/types/managers/logs/LogManager.d.ts +0 -10
  276. package/types/managers/match/GuildMatchManager.d.ts +0 -29
  277. package/types/managers/mediator/GuildMediatorManager.d.ts +0 -19
  278. package/types/managers/message/MessagesManager.d.ts +0 -20
  279. package/types/managers/minesgame/MinesGameManager.d.ts +0 -17
  280. package/types/managers/permission/GuildPermissionManager.d.ts +0 -8
  281. package/types/managers/player/PlayerManager.d.ts +0 -28
  282. package/types/managers/ticket/TicketManager.d.ts +0 -24
  283. package/types/managers/user/GuildUserManager.d.ts +0 -18
  284. package/types/managers/vipmember/VipMemberManager.d.ts +0 -32
  285. package/types/rest/REST.d.ts +0 -56
  286. package/types/rest/index.d.ts +0 -3
  287. package/types/structures/bet/GuildBet.d.ts +0 -54
  288. package/types/structures/betuser/GuildBetUser.d.ts +0 -71
  289. package/types/structures/guild/Guild.d.ts +0 -85
  290. package/types/structures/index.d.ts +0 -11
  291. package/types/structures/logentry/LogEntry.d.ts +0 -28
  292. package/types/structures/match/GuildMatch.d.ts +0 -76
  293. package/types/structures/mediator/GuildMediator.d.ts +0 -50
  294. package/types/structures/minesgame/MinesGame.d.ts +0 -23
  295. package/types/structures/ticket/Ticket.d.ts +0 -30
  296. package/types/structures/user/GuildUser.d.ts +0 -75
  297. package/types/structures/vipmember/VipMember.d.ts +0 -54
  298. package/types/types/RestTypes.d.ts +0 -47
  299. package/types/types/api/APIBetMessage.d.ts +0 -10
  300. package/types/types/api/APIGuild.d.ts +0 -132
  301. package/types/types/api/APIGuildBet.d.ts +0 -51
  302. package/types/types/api/APIGuildBetUser.d.ts +0 -27
  303. package/types/types/api/APIGuildGroupedChannel.d.ts +0 -7
  304. package/types/types/api/APIGuildMatch.d.ts +0 -58
  305. package/types/types/api/APIGuildRole.d.ts +0 -10
  306. package/types/types/api/APIGuildUser.d.ts +0 -41
  307. package/types/types/api/APILogMessage.d.ts +0 -7
  308. package/types/types/api/index.d.ts +0 -161
  309. package/types/types/index.d.ts +0 -2
  310. package/types/utils/getRandomNumber.d.ts +0 -1
@@ -1,107 +1,1297 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GuildMatchManager = void 0;
4
- const Routes_1 = require("../../rest/Routes");
5
- const GuildMatch_1 = require("../../structures/match/GuildMatch");
6
- const Collection_1 = require("../../structures/Collection");
7
- const Assertion_1 = require("../../utils/Assertion");
8
- const base_1 = require("../base");
9
- class GuildMatchManager extends base_1.BaseManager {
10
- /**
11
- * Manage users with the given client
12
- * @param users An array of users
13
- * @param rest The rest client
14
- */
15
- constructor(guild) {
16
- super(guild, guild.rest);
17
- this.guild = guild;
18
- this.rest = guild.rest;
19
- this.base_url = Routes_1.Routes.guilds.matches.getAll(guild.id);
20
- this.cache = new Collection_1.Collection("matches");
21
- }
22
- /**
23
- * Fetch a match
24
- * @param id Id of the match to fetch
25
- * @returns APIBetUser
26
- */
27
- async fetch(options) {
28
- if (options && options.cache)
29
- return this.cache;
30
- if (options && options.matchId) {
31
- const route = Routes_1.Routes.guilds.matches.get(this.guild.id, options.matchId);
32
- const response = await this.rest.request({
33
- method: "get",
34
- url: route,
35
- });
36
- return this.set(response);
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __commonJS = (cb, mod) => function __require() {
10
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
11
+ };
12
+ var __export = (target, all) => {
13
+ for (var name in all)
14
+ __defProp(target, name, { get: all[name], enumerable: true });
15
+ };
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from))
19
+ if (!__hasOwnProp.call(to, key) && key !== except)
20
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
+ }
22
+ return to;
23
+ };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
+ // If the importer is in node compatibility mode or this is not an ESM
26
+ // file that has been converted to a CommonJS file using a Babel-
27
+ // compatible transform (i.e. "__esModule" has not been set), then set
28
+ // "default" to the CommonJS "module.exports" for node compatibility.
29
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
+ mod
31
+ ));
32
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
33
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
34
+
35
+ // node_modules/dotenv/package.json
36
+ var require_package = __commonJS({
37
+ "node_modules/dotenv/package.json"(exports2, module2) {
38
+ module2.exports = {
39
+ name: "dotenv",
40
+ version: "16.6.1",
41
+ description: "Loads environment variables from .env file",
42
+ main: "lib/main.js",
43
+ types: "lib/main.d.ts",
44
+ exports: {
45
+ ".": {
46
+ types: "./lib/main.d.ts",
47
+ require: "./lib/main.js",
48
+ default: "./lib/main.js"
49
+ },
50
+ "./config": "./config.js",
51
+ "./config.js": "./config.js",
52
+ "./lib/env-options": "./lib/env-options.js",
53
+ "./lib/env-options.js": "./lib/env-options.js",
54
+ "./lib/cli-options": "./lib/cli-options.js",
55
+ "./lib/cli-options.js": "./lib/cli-options.js",
56
+ "./package.json": "./package.json"
57
+ },
58
+ scripts: {
59
+ "dts-check": "tsc --project tests/types/tsconfig.json",
60
+ lint: "standard",
61
+ pretest: "npm run lint && npm run dts-check",
62
+ test: "tap run --allow-empty-coverage --disable-coverage --timeout=60000",
63
+ "test:coverage": "tap run --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",
64
+ prerelease: "npm test",
65
+ release: "standard-version"
66
+ },
67
+ repository: {
68
+ type: "git",
69
+ url: "git://github.com/motdotla/dotenv.git"
70
+ },
71
+ homepage: "https://github.com/motdotla/dotenv#readme",
72
+ funding: "https://dotenvx.com",
73
+ keywords: [
74
+ "dotenv",
75
+ "env",
76
+ ".env",
77
+ "environment",
78
+ "variables",
79
+ "config",
80
+ "settings"
81
+ ],
82
+ readmeFilename: "README.md",
83
+ license: "BSD-2-Clause",
84
+ devDependencies: {
85
+ "@types/node": "^18.11.3",
86
+ decache: "^4.6.2",
87
+ sinon: "^14.0.1",
88
+ standard: "^17.0.0",
89
+ "standard-version": "^9.5.0",
90
+ tap: "^19.2.0",
91
+ typescript: "^4.8.4"
92
+ },
93
+ engines: {
94
+ node: ">=12"
95
+ },
96
+ browser: {
97
+ fs: false
98
+ }
99
+ };
100
+ }
101
+ });
102
+
103
+ // node_modules/dotenv/lib/main.js
104
+ var require_main = __commonJS({
105
+ "node_modules/dotenv/lib/main.js"(exports2, module2) {
106
+ "use strict";
107
+ var fs = require("fs");
108
+ var path = require("path");
109
+ var os = require("os");
110
+ var crypto = require("crypto");
111
+ var packageJson = require_package();
112
+ var version = packageJson.version;
113
+ var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
114
+ function parse(src) {
115
+ const obj = {};
116
+ let lines = src.toString();
117
+ lines = lines.replace(/\r\n?/mg, "\n");
118
+ let match;
119
+ while ((match = LINE.exec(lines)) != null) {
120
+ const key = match[1];
121
+ let value = match[2] || "";
122
+ value = value.trim();
123
+ const maybeQuote = value[0];
124
+ value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
125
+ if (maybeQuote === '"') {
126
+ value = value.replace(/\\n/g, "\n");
127
+ value = value.replace(/\\r/g, "\r");
37
128
  }
38
- const route = Routes_1.Routes.guilds.matches.getAll(this.guild.id);
39
- const response = await this.rest.request({
40
- method: "get",
41
- url: route,
42
- });
43
- if (!response)
44
- return this.cache;
45
- const coll = new Collection_1.Collection("matches");
46
- for (let match of response ?? []) {
47
- const guildMatch = new GuildMatch_1.GuildMatch(match, this);
48
- coll.set(match._id, guildMatch);
49
- this.rest.matches.set(match._id, guildMatch);
129
+ obj[key] = value;
130
+ }
131
+ return obj;
132
+ }
133
+ function _parseVault(options) {
134
+ options = options || {};
135
+ const vaultPath = _vaultPath(options);
136
+ options.path = vaultPath;
137
+ const result = DotenvModule.configDotenv(options);
138
+ if (!result.parsed) {
139
+ const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
140
+ err.code = "MISSING_DATA";
141
+ throw err;
142
+ }
143
+ const keys = _dotenvKey(options).split(",");
144
+ const length = keys.length;
145
+ let decrypted;
146
+ for (let i = 0; i < length; i++) {
147
+ try {
148
+ const key = keys[i].trim();
149
+ const attrs = _instructions(result, key);
150
+ decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
151
+ break;
152
+ } catch (error) {
153
+ if (i + 1 >= length) {
154
+ throw error;
155
+ }
50
156
  }
51
- this.cache = coll;
52
- return coll;
53
- }
54
- async fetchAll() {
55
- const route = Routes_1.Routes.guilds.matches.getAll(this.guild.id);
56
- const response = await this.rest.request({
57
- method: "get",
58
- url: route,
59
- });
60
- if (Array.isArray(response) && response.length === 0) {
61
- this.cache.clear();
62
- return this.cache;
157
+ }
158
+ return DotenvModule.parse(decrypted);
159
+ }
160
+ function _warn(message) {
161
+ console.log(`[dotenv@${version}][WARN] ${message}`);
162
+ }
163
+ function _debug(message) {
164
+ console.log(`[dotenv@${version}][DEBUG] ${message}`);
165
+ }
166
+ function _log(message) {
167
+ console.log(`[dotenv@${version}] ${message}`);
168
+ }
169
+ function _dotenvKey(options) {
170
+ if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
171
+ return options.DOTENV_KEY;
172
+ }
173
+ if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
174
+ return process.env.DOTENV_KEY;
175
+ }
176
+ return "";
177
+ }
178
+ function _instructions(result, dotenvKey) {
179
+ let uri;
180
+ try {
181
+ uri = new URL(dotenvKey);
182
+ } catch (error) {
183
+ if (error.code === "ERR_INVALID_URL") {
184
+ 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");
185
+ err.code = "INVALID_DOTENV_KEY";
186
+ throw err;
63
187
  }
64
- this.set(response);
65
- return this.cache;
66
- }
67
- set(data) {
68
- if (!data)
69
- return this.cache;
70
- if (Array.isArray(data)) {
71
- for (let _match of data) {
72
- if (!_match._id)
73
- continue;
74
- const match = new GuildMatch_1.GuildMatch(_match, this);
75
- this.cache.set(match._id, match);
188
+ throw error;
189
+ }
190
+ const key = uri.password;
191
+ if (!key) {
192
+ const err = new Error("INVALID_DOTENV_KEY: Missing key part");
193
+ err.code = "INVALID_DOTENV_KEY";
194
+ throw err;
195
+ }
196
+ const environment = uri.searchParams.get("environment");
197
+ if (!environment) {
198
+ const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
199
+ err.code = "INVALID_DOTENV_KEY";
200
+ throw err;
201
+ }
202
+ const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
203
+ const ciphertext = result.parsed[environmentKey];
204
+ if (!ciphertext) {
205
+ const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
206
+ err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
207
+ throw err;
208
+ }
209
+ return { ciphertext, key };
210
+ }
211
+ function _vaultPath(options) {
212
+ let possibleVaultPath = null;
213
+ if (options && options.path && options.path.length > 0) {
214
+ if (Array.isArray(options.path)) {
215
+ for (const filepath of options.path) {
216
+ if (fs.existsSync(filepath)) {
217
+ possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
76
218
  }
77
- return this.cache;
219
+ }
220
+ } else {
221
+ possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
78
222
  }
79
- else {
80
- if (!data._id)
81
- return this.cache;
82
- if (data instanceof GuildMatch_1.GuildMatch) {
83
- this.cache.set(data._id, data);
84
- return data;
223
+ } else {
224
+ possibleVaultPath = path.resolve(process.cwd(), ".env.vault");
225
+ }
226
+ if (fs.existsSync(possibleVaultPath)) {
227
+ return possibleVaultPath;
228
+ }
229
+ return null;
230
+ }
231
+ function _resolveHome(envPath) {
232
+ return envPath[0] === "~" ? path.join(os.homedir(), envPath.slice(1)) : envPath;
233
+ }
234
+ function _configVault(options) {
235
+ const debug = Boolean(options && options.debug);
236
+ const quiet = options && "quiet" in options ? options.quiet : true;
237
+ if (debug || !quiet) {
238
+ _log("Loading env from encrypted .env.vault");
239
+ }
240
+ const parsed = DotenvModule._parseVault(options);
241
+ let processEnv = process.env;
242
+ if (options && options.processEnv != null) {
243
+ processEnv = options.processEnv;
244
+ }
245
+ DotenvModule.populate(processEnv, parsed, options);
246
+ return { parsed };
247
+ }
248
+ function configDotenv(options) {
249
+ const dotenvPath = path.resolve(process.cwd(), ".env");
250
+ let encoding = "utf8";
251
+ const debug = Boolean(options && options.debug);
252
+ const quiet = options && "quiet" in options ? options.quiet : true;
253
+ if (options && options.encoding) {
254
+ encoding = options.encoding;
255
+ } else {
256
+ if (debug) {
257
+ _debug("No encoding is specified. UTF-8 is used by default");
258
+ }
259
+ }
260
+ let optionPaths = [dotenvPath];
261
+ if (options && options.path) {
262
+ if (!Array.isArray(options.path)) {
263
+ optionPaths = [_resolveHome(options.path)];
264
+ } else {
265
+ optionPaths = [];
266
+ for (const filepath of options.path) {
267
+ optionPaths.push(_resolveHome(filepath));
268
+ }
269
+ }
270
+ }
271
+ let lastError;
272
+ const parsedAll = {};
273
+ for (const path2 of optionPaths) {
274
+ try {
275
+ const parsed = DotenvModule.parse(fs.readFileSync(path2, { encoding }));
276
+ DotenvModule.populate(parsedAll, parsed, options);
277
+ } catch (e) {
278
+ if (debug) {
279
+ _debug(`Failed to load ${path2} ${e.message}`);
280
+ }
281
+ lastError = e;
282
+ }
283
+ }
284
+ let processEnv = process.env;
285
+ if (options && options.processEnv != null) {
286
+ processEnv = options.processEnv;
287
+ }
288
+ DotenvModule.populate(processEnv, parsedAll, options);
289
+ if (debug || !quiet) {
290
+ const keysCount = Object.keys(parsedAll).length;
291
+ const shortPaths = [];
292
+ for (const filePath of optionPaths) {
293
+ try {
294
+ const relative = path.relative(process.cwd(), filePath);
295
+ shortPaths.push(relative);
296
+ } catch (e) {
297
+ if (debug) {
298
+ _debug(`Failed to load ${filePath} ${e.message}`);
85
299
  }
86
- const match = new GuildMatch_1.GuildMatch(data, this);
87
- this.cache.set(match._id, match);
88
- return match;
300
+ lastError = e;
301
+ }
302
+ }
303
+ _log(`injecting env (${keysCount}) from ${shortPaths.join(",")}`);
304
+ }
305
+ if (lastError) {
306
+ return { parsed: parsedAll, error: lastError };
307
+ } else {
308
+ return { parsed: parsedAll };
309
+ }
310
+ }
311
+ function config(options) {
312
+ if (_dotenvKey(options).length === 0) {
313
+ return DotenvModule.configDotenv(options);
314
+ }
315
+ const vaultPath = _vaultPath(options);
316
+ if (!vaultPath) {
317
+ _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
318
+ return DotenvModule.configDotenv(options);
319
+ }
320
+ return DotenvModule._configVault(options);
321
+ }
322
+ function decrypt(encrypted, keyStr) {
323
+ const key = Buffer.from(keyStr.slice(-64), "hex");
324
+ let ciphertext = Buffer.from(encrypted, "base64");
325
+ const nonce = ciphertext.subarray(0, 12);
326
+ const authTag = ciphertext.subarray(-16);
327
+ ciphertext = ciphertext.subarray(12, -16);
328
+ try {
329
+ const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
330
+ aesgcm.setAuthTag(authTag);
331
+ return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
332
+ } catch (error) {
333
+ const isRange = error instanceof RangeError;
334
+ const invalidKeyLength = error.message === "Invalid key length";
335
+ const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
336
+ if (isRange || invalidKeyLength) {
337
+ const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
338
+ err.code = "INVALID_DOTENV_KEY";
339
+ throw err;
340
+ } else if (decryptionFailed) {
341
+ const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
342
+ err.code = "DECRYPTION_FAILED";
343
+ throw err;
344
+ } else {
345
+ throw error;
89
346
  }
347
+ }
348
+ }
349
+ function populate(processEnv, parsed, options = {}) {
350
+ const debug = Boolean(options && options.debug);
351
+ const override = Boolean(options && options.override);
352
+ if (typeof parsed !== "object") {
353
+ const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
354
+ err.code = "OBJECT_REQUIRED";
355
+ throw err;
356
+ }
357
+ for (const key of Object.keys(parsed)) {
358
+ if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
359
+ if (override === true) {
360
+ processEnv[key] = parsed[key];
361
+ }
362
+ if (debug) {
363
+ if (override === true) {
364
+ _debug(`"${key}" is already defined and WAS overwritten`);
365
+ } else {
366
+ _debug(`"${key}" is already defined and was NOT overwritten`);
367
+ }
368
+ }
369
+ } else {
370
+ processEnv[key] = parsed[key];
371
+ }
372
+ }
373
+ }
374
+ var DotenvModule = {
375
+ configDotenv,
376
+ _configVault,
377
+ _parseVault,
378
+ config,
379
+ decrypt,
380
+ parse,
381
+ populate
382
+ };
383
+ module2.exports.configDotenv = DotenvModule.configDotenv;
384
+ module2.exports._configVault = DotenvModule._configVault;
385
+ module2.exports._parseVault = DotenvModule._parseVault;
386
+ module2.exports.config = DotenvModule.config;
387
+ module2.exports.decrypt = DotenvModule.decrypt;
388
+ module2.exports.parse = DotenvModule.parse;
389
+ module2.exports.populate = DotenvModule.populate;
390
+ module2.exports = DotenvModule;
391
+ }
392
+ });
393
+
394
+ // src/managers/match/GuildMatchManager.ts
395
+ var GuildMatchManager_exports = {};
396
+ __export(GuildMatchManager_exports, {
397
+ GuildMatchManager: () => GuildMatchManager
398
+ });
399
+ module.exports = __toCommonJS(GuildMatchManager_exports);
400
+
401
+ // src/rest/Routes.ts
402
+ var Routes = {
403
+ //base: "http://localhost:80/api/v1",
404
+ base: "https://duque-api.up.railway.app/api/v1",
405
+ field: (field) => `/${field}`,
406
+ fields: (...fields) => `${fields.join("/")}`,
407
+ guilds: {
408
+ create: () => `/guilds`,
409
+ get: (guildId) => `/guilds/${guildId}`,
410
+ getAll: () => `/guilds`,
411
+ delete: (guildId) => `/guilds/${guildId}`,
412
+ deleteAll: () => `/guilds`,
413
+ resource: (guildId, ...resources) => `/guilds/${guildId}/manage/${resources.join("/")}`,
414
+ resources: (guildId, ...resources) => `/guilds/${guildId}/manage/${resources.join("/")}`,
415
+ users: {
416
+ create: (guildId) => `/guilds/${guildId}/users`,
417
+ update: (guildId, userId) => `/guilds/${guildId}/users/${userId}`,
418
+ getAll: (guildId) => `/guilds/${guildId}/users`,
419
+ get: (guildId, userId) => `/guilds/${guildId}/users/${userId}`,
420
+ delete: (guildId, userId) => `/guilds/${guildId}/users/${userId}`,
421
+ deleteAll: (guildId) => `/guilds/${guildId}/users`,
422
+ resource: (guildId, userId, ...resource) => `/guilds/${guildId}/users/${userId}/${resource.join("/")}`
423
+ },
424
+ betusers: {
425
+ getAll: (guildId) => `/guilds/${guildId}/betusers`,
426
+ get: (guildId, userId) => `/guilds/${guildId}/betusers/${userId}`,
427
+ create: (guildId) => `/guilds/${guildId}/betusers`,
428
+ update: (guildId, userId) => `/guilds/${guildId}/betusers/${userId}`,
429
+ delete: (guildId, userId) => `/guilds/${guildId}/betusers/${userId}`,
430
+ deleteAll: (guildId) => `/guilds/${guildId}/betusers`,
431
+ resource: (guildId, userId, resourceName) => `/guilds/${guildId}/betusers/${userId}/${resourceName}`
432
+ },
433
+ matches: {
434
+ getAll: (guildId) => `/guilds/${guildId}/matches`,
435
+ get: (guildId, matchId) => `/guilds/${guildId}/matches/${matchId}`,
436
+ create: (guildId) => `/guilds/${guildId}/matches`,
437
+ update: (guildId, matchId) => `/guilds/${guildId}/matches/${matchId}`,
438
+ delete: (guildId, matchId) => `/guilds/${guildId}/matches/${matchId}`,
439
+ deleteAll: (guildId) => `/guilds/${guildId}/matches`,
440
+ resource: (guildId, matchId, ...resources) => `/guilds/${guildId}/matches/${matchId}/${resources.join("/")}`
441
+ },
442
+ bets: {
443
+ getAll: (guildId) => `/guilds/${guildId}/bets`,
444
+ get: (guildId, betId) => `/guilds/${guildId}/bets/${betId}`,
445
+ create: (guildId) => `/guilds/${guildId}/bets`,
446
+ update: (guildId, betId) => `/guilds/${guildId}/bets/${betId}`,
447
+ delete: (guildId, betId) => `/guilds/${guildId}/bets/${betId}`,
448
+ deleteAll: (guildId) => `/guilds/${guildId}/bets`,
449
+ resource: (guildId, betId, ...resources) => `/guilds/${guildId}/bets/${betId}/${resources.join("/")}`
450
+ },
451
+ tickets: {
452
+ getAll: (guildId) => `/guilds/${guildId}/tickets`,
453
+ get: (guildId, ticketId) => `/guilds/${guildId}/tickets/${ticketId}`,
454
+ create: (guildId) => `/guilds/${guildId}/tickets`,
455
+ update: (guildId, ticketId) => `/guilds/${guildId}/tickets/${ticketId}`,
456
+ delete: (guildId, ticketId) => `/guilds/${guildId}/tickets/${ticketId}`,
457
+ deleteAll: (guildId) => `/guilds/${guildId}/tickets`,
458
+ resource: (guildId, ticketId, ...resources) => `/guilds/${guildId}/tickets/${ticketId}/${resources.join("/")}`
459
+ },
460
+ mediators: {
461
+ getAll: (guildId) => `/guilds/${guildId}/mediators`,
462
+ get: (guildId, mediatorId) => `/guilds/${guildId}/mediators/${mediatorId}`,
463
+ create: (guildId) => `/guilds/${guildId}/mediators`,
464
+ update: (guildId, mediatorId) => `/guilds/${guildId}/mediators/${mediatorId}`,
465
+ delete: (guildId, mediatorId) => `/guilds/${guildId}/mediators/${mediatorId}`,
466
+ deleteAll: (guildId) => `/guilds/${guildId}/mediators`,
467
+ resource: (guildId, mediatorId, ...resources) => `/guilds/${guildId}/mediators/${mediatorId}/${resources.join("/")}`
468
+ },
469
+ shop: {
470
+ get: (guildId) => `/guilds/${guildId}/manage/shop`,
471
+ update: (guildId) => `/guilds/${guildId}/manage/shop`,
472
+ delete: (guildId) => `/guilds/${guildId}/manage/shop/ `,
473
+ resource: (guildId, ...resources) => `/guilds/${guildId}/manage/shop/${resources.join("/")}`,
474
+ products: {
475
+ getAll: (guildId) => `/guilds/${guildId}/manage/shop/products`,
476
+ get: (guildId, productId) => `/guilds/${guildId}/manage/shop/${productId}/products`,
477
+ create: (guildId) => `/guilds/${guildId}/manage/shop/products`,
478
+ update: (guildId, productId) => `/guilds/${guildId}/manage/shop/products/${productId}`,
479
+ delete: (guildId, productId) => `/guilds/${guildId}/manage/shop/products/${productId}`,
480
+ deleteAll: (guildId) => `/guilds/${guildId}/products/shop`,
481
+ resource: (guildId, productId, ...resources) => `/guilds/${guildId}/manage/shop/products/${productId}/${resources.join("/")}`
482
+ }
483
+ }
484
+ },
485
+ vipmembers: {
486
+ get: (guildId, memberId) => `/guilds/${guildId}/vipmembers/${memberId}`,
487
+ getAll: (guildId) => `/guilds/${guildId}/vipmembers`,
488
+ deleteAll: (guildId) => `/guilds/${guildId}/vipmembers`,
489
+ create: (guildId) => `/guilds/${guildId}/vipmembers`,
490
+ update: (guildId, memberId) => `/guilds/${guildId}/vipmembers/${memberId}`,
491
+ delete: (guildId, memberId) => `/guilds/${guildId}/vipmembers/${memberId}`
492
+ },
493
+ giveaways: {
494
+ get: (giveawayId) => `/giveaways/${giveawayId}`,
495
+ getAll: () => `/giveaways`,
496
+ deleteAll: () => `/giveaways`,
497
+ create: () => `/giveaways`,
498
+ update: (giveawayId) => `/giveaways/${giveawayId}`,
499
+ delete: (giveawayId) => `/giveaways/${giveawayId}`
500
+ }
501
+ };
502
+
503
+ // src/utils/Assertion.ts
504
+ var Assertion = class {
505
+ constructor() {
506
+ }
507
+ /**
508
+ * Tests if given key is a string
509
+ * @param key Key to test
510
+ */
511
+ static assertString(key) {
512
+ if (typeof key !== "string") throw new Error(`${key} must be a string`);
513
+ if (!key || key === "") throw new Error(`${key} must be a string`);
514
+ return true;
515
+ }
516
+ /**
517
+ * Tests if given key is a number
518
+ * @param key Key to test
519
+ */
520
+ static assertNumber(key) {
521
+ if (typeof key !== "number") throw new Error(`${key} must be a number`);
522
+ return true;
523
+ }
524
+ /**
525
+ * Tests if given key is a boolean
526
+ * @param key Key to test
527
+ */
528
+ static assertBoolean(key) {
529
+ if (typeof key !== "boolean") throw new Error(`${key} must be a boolean`);
530
+ return true;
531
+ }
532
+ /**
533
+ * Tests if given key is an array
534
+ * @param key Key to test
535
+ */
536
+ static assertArray(key) {
537
+ if (!Array.isArray(key)) throw new Error(`${key} must be an array`);
538
+ return true;
539
+ }
540
+ /**
541
+ * Tests if given key is an object
542
+ * @param key Key to test
543
+ */
544
+ static assertObject(key) {
545
+ if (typeof key !== "object") throw new Error(`${key} must be an object`);
546
+ return true;
547
+ }
548
+ toString() {
549
+ return "string, number, boolean, array, object";
550
+ }
551
+ };
552
+
553
+ // src/structures/Collection.ts
554
+ var Collection = class _Collection extends Map {
555
+ constructor(key, data) {
556
+ super();
557
+ __publicField(this, "key");
558
+ this.key = key;
559
+ if (data && Array.isArray(data) && key) {
560
+ if (data.length > 0) return;
561
+ for (let v of data) this.set(key, v);
90
562
  }
91
- async create(payload) {
92
- Assertion_1.Assertion.assertObject(payload);
93
- const route = Routes_1.Routes.guilds.matches.create(this.guild.id);
94
- const response = await this.rest.request({
95
- method: "POST",
96
- url: route,
97
- payload,
563
+ }
564
+ at(index) {
565
+ if (index < 0 || index >= this.size) {
566
+ return void 0;
567
+ }
568
+ let i = 0;
569
+ for (let [, value] of this) {
570
+ if (i === index) {
571
+ return value;
572
+ }
573
+ i++;
574
+ }
575
+ }
576
+ has(key) {
577
+ return this.get(key) !== void 0 ? true : false;
578
+ }
579
+ get first() {
580
+ return this.values().next().value;
581
+ }
582
+ get last() {
583
+ return [...this.values()].at(-1);
584
+ }
585
+ get length() {
586
+ return this.toArray().length;
587
+ }
588
+ find(predicate) {
589
+ for (const [key, value] of this) {
590
+ if (predicate(value, key, this)) return value;
591
+ }
592
+ return void 0;
593
+ }
594
+ filter(predicate) {
595
+ const results = new _Collection(this.key, []);
596
+ for (const [key, value] of this) {
597
+ if (predicate(value, key, this)) results.set(key, value);
598
+ }
599
+ return results;
600
+ }
601
+ some(predicate) {
602
+ const results = new _Collection(this.key, []);
603
+ for (const [key, value] of this) {
604
+ if (predicate(value, key, this)) results.set(key, value);
605
+ }
606
+ return results;
607
+ }
608
+ map(callback) {
609
+ return [...this].map(([key, val]) => callback(val, key, this));
610
+ }
611
+ toArray() {
612
+ return [...this.values()];
613
+ }
614
+ toJSON() {
615
+ let obj = {};
616
+ for (let [k, v] of this.entries()) {
617
+ obj[`${k}`] = v;
618
+ }
619
+ return obj;
620
+ }
621
+ sort(compareFunction) {
622
+ const sortedEntries = [...this.entries()].sort((ab, ba) => {
623
+ return compareFunction(ab[1], ba[1], this);
624
+ });
625
+ const coll = new _Collection();
626
+ for (let [k, v] of sortedEntries) coll.set(k, v);
627
+ return coll;
628
+ }
629
+ toString() {
630
+ return `${this.size}`;
631
+ }
632
+ };
633
+
634
+ // src/managers/base.ts
635
+ var BaseManager = class {
636
+ constructor(guild) {
637
+ /** This url of the manager */
638
+ __publicField(this, "base_url");
639
+ /** The rest client */
640
+ __publicField(this, "rest");
641
+ /** The guild of the manager */
642
+ __publicField(this, "guild");
643
+ /** Cache */
644
+ __publicField(this, "cache");
645
+ this.guild = guild;
646
+ this.rest = guild.rest;
647
+ this.cache = new Collection();
648
+ }
649
+ };
650
+
651
+ // src/managers/player/PlayerManager.ts
652
+ var PlayerManager = class extends Collection {
653
+ constructor(structure, base_url) {
654
+ super("players");
655
+ __publicField(this, "base_url");
656
+ __publicField(this, "rest");
657
+ __publicField(this, "guild");
658
+ this.base_url = base_url;
659
+ this.guild = structure.guild;
660
+ this.rest = structure.rest;
661
+ }
662
+ _set(data) {
663
+ this.clear();
664
+ if (Array.isArray(data)) {
665
+ for (let p of data) {
666
+ if (!p.id) continue;
667
+ this.set(p.id, {
668
+ id: p.id,
669
+ createdAt: p.createdAt ? new Date(p.createdAt) : /* @__PURE__ */ new Date(),
670
+ updateAt: p.updateAt ? new Date(p.updateAt) : /* @__PURE__ */ new Date()
98
671
  });
99
- return this.set(response);
672
+ }
673
+ } else {
674
+ if (!data.id) return;
675
+ this.set(data.id, {
676
+ id: data.id,
677
+ createdAt: data.createdAt ? new Date(data.createdAt) : /* @__PURE__ */ new Date(),
678
+ updateAt: data.updateAt ? new Date(data.updateAt) : /* @__PURE__ */ new Date()
679
+ });
680
+ }
681
+ return this;
682
+ }
683
+ /**
684
+ * Adds a player or an array of players to the structure.
685
+ * @param player A player or an array of players to be added
686
+ * @returns returns a collection of players
687
+ */
688
+ async add(player) {
689
+ let players = [];
690
+ if (Array.isArray(player)) {
691
+ for (let p of player) this.has(p.id) ? null : players.push(p);
692
+ } else this.has(player.id) ? null : players.push(player);
693
+ const payload = { set: players };
694
+ const response = await this.rest.request({
695
+ method: "PATCH",
696
+ payload,
697
+ url: this.base_url
698
+ });
699
+ return this._set(response.players);
700
+ }
701
+ /**
702
+ * Remover a player or an array of players.
703
+ * @param player The player or an array of players to be removed
704
+ * @returns Player manager
705
+ */
706
+ async remove(player) {
707
+ const ids = new Set(Array.isArray(player) ? player.map((p) => p.id) : [player.id]);
708
+ const players = this.toArray().filter((p) => !ids.has(p.id));
709
+ const payload = { set: players };
710
+ const response = await this.rest.request({
711
+ method: "PATCH",
712
+ payload,
713
+ url: this.base_url
714
+ });
715
+ return this._set(response.players);
716
+ }
717
+ };
718
+
719
+ // src/rest/REST.ts
720
+ var import_dotenv = __toESM(require_main());
721
+ var import_undici = require("undici");
722
+ import_dotenv.default.config();
723
+
724
+ // src/structures/bet/GuildBet.ts
725
+ var GuildBet = class {
726
+ constructor(data, manager) {
727
+ /** The bet's type */
728
+ __publicField(this, "type");
729
+ /** The bet's mode */
730
+ __publicField(this, "mode");
731
+ /** The bet's status */
732
+ __publicField(this, "status");
733
+ /** The bet's maximum size */
734
+ __publicField(this, "maximumSize");
735
+ /** The bet's price */
736
+ __publicField(this, "price");
737
+ /** The bet's players */
738
+ __publicField(this, "players");
739
+ __publicField(this, "teams");
740
+ /** The bet's channel */
741
+ __publicField(this, "channels");
742
+ /** The bet's messages */
743
+ __publicField(this, "messages");
744
+ /** The id of the winner */
745
+ __publicField(this, "winners");
746
+ /** The id of the loser */
747
+ __publicField(this, "losers");
748
+ /** The bet's creator id */
749
+ __publicField(this, "creatorId");
750
+ /** The bet's mediator */
751
+ __publicField(this, "mediatorId");
752
+ /** The bet's confirmers */
753
+ __publicField(this, "confirmed");
754
+ /** Creation Date */
755
+ __publicField(this, "createdAt");
756
+ /** Updated Date */
757
+ __publicField(this, "updatedAt");
758
+ /** Bet's id */
759
+ __publicField(this, "_id");
760
+ __publicField(this, "queues");
761
+ __publicField(this, "guild_id");
762
+ __publicField(this, "rest");
763
+ __publicField(this, "guild");
764
+ __publicField(this, "manager");
765
+ this.manager = manager;
766
+ this.guild = manager.guild;
767
+ this.rest = manager.rest;
768
+ this._id = data?._id;
769
+ this.guild_id = data?.guild_id;
770
+ this.type = data?.type;
771
+ this.mode = data?.mode;
772
+ this.status = data?.status;
773
+ this.maximumSize = data?.maximumSize;
774
+ this.price = data?.price;
775
+ this.teams = data?.teams;
776
+ this.channels = data?.channels;
777
+ this.players = new PlayerManager(this, Routes.guilds.bets.resource(this.guild_id, this._id, "players"));
778
+ this.messages = new MessagesManager(this, Routes.guilds.bets.resource(this.guild_id, this._id, "messages"));
779
+ this.winners = data?.winners;
780
+ this.losers = data?.losers;
781
+ this.creatorId = data?.creatorId;
782
+ this.mediatorId = data?.mediatorId;
783
+ this.confirmed = data?.confirmed;
784
+ this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
785
+ this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
786
+ this.queues = [];
787
+ for (let queue of data.queues ?? []) {
788
+ this.queues.push({
789
+ _id: queue?._id,
790
+ type: queue?.type,
791
+ players: queue?.players,
792
+ updatedAt: queue?.updatedAt ? new Date(queue?.updatedAt) : /* @__PURE__ */ new Date(),
793
+ createdAt: queue?.createdAt ? new Date(queue?.createdAt) : /* @__PURE__ */ new Date()
794
+ });
795
+ }
796
+ if (data?.messages?.length !== 0) this.messages.set(data.messages);
797
+ if (data?.players.length !== 0) this.players._set(data.players);
798
+ }
799
+ toString() {
800
+ return this._id;
801
+ }
802
+ async fetch() {
803
+ const route = Routes.guilds.bets.get(this.guild.id, this._id);
804
+ const response = await this.rest.request({ url: route, method: "GET" });
805
+ return this._updateInternals(response);
806
+ }
807
+ async addPlayer(player, queue_type) {
808
+ if (this.players.length === 2) return this;
809
+ if (this.players.has(player.id)) return this;
810
+ this.players.set(player.id, player);
811
+ if (queue_type) {
812
+ const queue = this.queues.find((q) => q.type === queue_type);
813
+ if (!queue) return this;
814
+ for (const q of this.queues) {
815
+ q.players = q.players.filter((p) => p.id !== player.id);
816
+ }
817
+ if (!queue.players.some((p) => p.id === player.id)) {
818
+ queue.players.push({ id: player.id });
819
+ }
820
+ }
821
+ return await this.update({
822
+ players: this.players.toArray(),
823
+ queues: this.queues
824
+ });
825
+ }
826
+ async removePlayer(player) {
827
+ if (!this.players.some((p) => p.id === player.id)) return this;
828
+ let players = this.players.toArray();
829
+ players = this.players.filter((p) => p.id !== player.id).toArray();
830
+ for (const q of this.queues) {
831
+ q.players = q.players.filter((p) => p.id !== player.id);
832
+ }
833
+ return await this.update({
834
+ players,
835
+ queues: this.queues
836
+ });
837
+ }
838
+ async update(data) {
839
+ const payload = data;
840
+ const route = Routes.guilds.bets.update(this.guild.id, this._id);
841
+ const response = await this.rest.request({ method: "patch", url: route, payload });
842
+ return this._updateInternals(response);
843
+ }
844
+ async delete() {
845
+ const route = Routes.guilds.bets.delete(this.manager.guild.id, this._id);
846
+ const response = await this.rest.request({
847
+ method: "DELETE",
848
+ url: route
849
+ });
850
+ this.rest.emit("betDelete", this);
851
+ this.manager.cache.delete(this._id);
852
+ return response;
853
+ }
854
+ _updateInternals(data) {
855
+ for (let key in data) {
856
+ if (key === "_id" || key === "createdAt") continue;
857
+ if (key === "messages") {
858
+ this.messages.set(data[key]);
859
+ continue;
860
+ }
861
+ if (key === "players") {
862
+ this.players._set(data[key]);
863
+ continue;
864
+ }
865
+ if (key in this) {
866
+ this[key] = data[key];
867
+ }
868
+ }
869
+ if (data?.messages?.length !== 0) {
870
+ if (this?.messages instanceof MessagesManager) this.messages.set(data.messages);
871
+ else {
872
+ this.messages = new MessagesManager(this, Routes.guilds.matches.resource(this.guild_id, this._id, "messages"));
873
+ this.messages.set(data.messages);
874
+ }
875
+ }
876
+ this.updatedAt = /* @__PURE__ */ new Date();
877
+ this.createdAt = new Date(data.createdAt);
878
+ this.manager.set(this);
879
+ return this;
880
+ }
881
+ toJSON() {
882
+ let json = {};
883
+ for (const [key, value] of Object.entries(this)) {
884
+ const exclude = ["rest", "guild", "manager"];
885
+ if (exclude.includes(key)) continue;
886
+ if (typeof value !== "function") {
887
+ json[key] = value;
888
+ }
889
+ }
890
+ return {
891
+ ...json,
892
+ messages: this?.messages instanceof MessagesManager ? this.messages?.cache?.toArray() : [],
893
+ players: this.players.toArray()
894
+ };
895
+ }
896
+ };
897
+
898
+ // src/managers/message/MessagesManager.ts
899
+ var MessagesManager = class {
900
+ constructor(structure, base_url) {
901
+ __publicField(this, "cache");
902
+ __publicField(this, "base_url");
903
+ __publicField(this, "rest");
904
+ __publicField(this, "guild");
905
+ this.rest = structure.rest;
906
+ this.guild = structure.guild;
907
+ this.cache = new Collection("messages");
908
+ this.base_url = base_url;
909
+ }
910
+ async fetch() {
911
+ const response = await this.rest.request({
912
+ method: "GET",
913
+ url: this.base_url,
914
+ payload: {}
915
+ });
916
+ this.cache.set(response._id, response);
917
+ return response;
918
+ }
919
+ async create(data) {
920
+ const messages = [...this.cache.toArray()];
921
+ if (Array.isArray(data)) messages.push(...data);
922
+ else messages.push(data);
923
+ const response = await this.rest.request({
924
+ method: "PATCH",
925
+ url: this.base_url,
926
+ payload: { set: messages }
927
+ });
928
+ return this.set(response.messages);
929
+ }
930
+ set(data) {
931
+ if (!data) return this.cache;
932
+ if (Array.isArray(data)) {
933
+ for (let message of data) {
934
+ if (message && !message._id) continue;
935
+ this.cache.set(message._id, message);
936
+ }
937
+ } else {
938
+ if (data && !data._id) return this.cache;
939
+ this.cache.set(data._id, data);
940
+ }
941
+ return this.cache;
942
+ }
943
+ };
944
+
945
+ // src/structures/match/GuildMatch.ts
946
+ var GuildMatch = class _GuildMatch {
947
+ /**
948
+ * GuildMatch match
949
+ * @param data The match's data
950
+ * @param guild The guild
951
+ * @param rest The rest client
952
+ */
953
+ constructor(data, manager) {
954
+ __publicField(this, "_id");
955
+ __publicField(this, "selections");
956
+ /** Match's type */
957
+ __publicField(this, "type");
958
+ __publicField(this, "channels");
959
+ __publicField(this, "guild_id");
960
+ /** Match's status */
961
+ __publicField(this, "status");
962
+ /** Match's challenge */
963
+ __publicField(this, "challenge");
964
+ /** Match's players */
965
+ __publicField(this, "players");
966
+ __publicField(this, "teams");
967
+ /** Match's winners */
968
+ __publicField(this, "winners");
969
+ /** Match's losers */
970
+ __publicField(this, "losers");
971
+ /** Match's maximum size */
972
+ __publicField(this, "maximumSize");
973
+ /** Match's kicked out */
974
+ __publicField(this, "kickedOut");
975
+ /** Match's confirmed */
976
+ __publicField(this, "confirmed");
977
+ /** Match's leaders */
978
+ __publicField(this, "leaders");
979
+ /** Match's creator id */
980
+ __publicField(this, "creatorId");
981
+ /** Match's room creator id */
982
+ __publicField(this, "roomCreatorId");
983
+ /** Creation Date */
984
+ __publicField(this, "createdAt");
985
+ /** Updated Date */
986
+ __publicField(this, "updatedAt");
987
+ __publicField(this, "messages");
988
+ /** Match's id */
989
+ __publicField(this, "mvps");
990
+ __publicField(this, "manager");
991
+ __publicField(this, "bet");
992
+ __publicField(this, "admin_id");
993
+ /** The given guild */
994
+ __publicField(this, "guild");
995
+ /** The rest client */
996
+ __publicField(this, "rest");
997
+ __publicField(this, "key");
998
+ this._id = data?._id;
999
+ this.guild_id = data?.guild_id;
1000
+ this.manager = manager;
1001
+ this.guild = manager.guild;
1002
+ this.rest = manager.rest;
1003
+ this.admin_id = data?.admin_id;
1004
+ this.challenge = data?.challenge;
1005
+ this.players = data?.players;
1006
+ this.messages = new MessagesManager(this, Routes.guilds.matches.resource(this.guild_id, this._id, "messages"));
1007
+ this.channels = data?.channels;
1008
+ this.type = data?.type;
1009
+ this.status = data?.status;
1010
+ this.bet = this.guild.bets.cache.get(data?.bet?._id);
1011
+ this.mvps = data?.mvps;
1012
+ this.winners = data?.winners;
1013
+ this.losers = data?.losers;
1014
+ this.maximumSize = data?.maximumSize;
1015
+ this.kickedOut = data?.kickedOut;
1016
+ this.confirmed = data?.confirmed;
1017
+ this.teams = data?.teams;
1018
+ this.leaders = data?.leaders;
1019
+ this.creatorId = data?.creatorId;
1020
+ this.roomCreatorId = data?.roomCreatorId;
1021
+ this.selections = data?.selections;
1022
+ this.key = "matches";
1023
+ this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
1024
+ this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
1025
+ if (data?.messages?.length !== 0) this.messages.set(data.messages);
1026
+ }
1027
+ /**
1028
+ * Fetches the match
1029
+ * @returns New Instance of the match
1030
+ */
1031
+ async fetch() {
1032
+ const route = Routes.guilds.matches.get(this.guild.id, this._id);
1033
+ const response = await this.rest.request({
1034
+ method: "get",
1035
+ url: route
1036
+ });
1037
+ return await this._updateInternals(response);
1038
+ }
1039
+ async addConfirmed(type, id) {
1040
+ const confirmed = this.confirmed.find((c) => c.type === type);
1041
+ const idsToAdd = Array.isArray(id) ? id : [id];
1042
+ if (!confirmed) {
1043
+ this.confirmed.push({ type, ids: [...idsToAdd], count: idsToAdd.length });
1044
+ } else {
1045
+ const chIndex = this.confirmed.findIndex((ch) => ch.type === type);
1046
+ const mergedIds = [.../* @__PURE__ */ new Set([...confirmed.ids || [], ...idsToAdd])];
1047
+ this.confirmed[chIndex] = { ...confirmed, ids: mergedIds, count: mergedIds.length };
1048
+ }
1049
+ return this.update({ confirmed: this.confirmed });
1050
+ }
1051
+ async setConfirmed(set) {
1052
+ Assertion.assertObject(set);
1053
+ const route = Routes.guilds.matches.resource(this.guild.id, this._id, "confirmed");
1054
+ const response = await this.rest.request({
1055
+ method: "PATCH",
1056
+ url: route,
1057
+ payload: set
1058
+ });
1059
+ return await this._updateInternals(response);
1060
+ }
1061
+ async setStatus(status) {
1062
+ Assertion.assertString(status);
1063
+ const payload = { set: status.toLowerCase() };
1064
+ const route = Routes.guilds.matches.resource(this.guild.id, this._id, "status");
1065
+ const response = await this.rest.request({
1066
+ method: "PATCH",
1067
+ url: route,
1068
+ payload
1069
+ });
1070
+ return await this._updateInternals(response);
1071
+ }
1072
+ async setWinners(players) {
1073
+ if (!Array.isArray(players)) players = [players];
1074
+ const payload = { set: players };
1075
+ const route = Routes.guilds.matches.resource(this.guild.id, this._id, "winners");
1076
+ const response = await this.rest.request({
1077
+ method: "PATCH",
1078
+ url: route,
1079
+ payload
1080
+ });
1081
+ return await this._updateInternals(response);
1082
+ }
1083
+ async setLoser(players) {
1084
+ if (!Array.isArray(players)) players = [players];
1085
+ const payload = { set: players };
1086
+ const route = Routes.guilds.matches.resource(this.guild.id, this._id, "losers");
1087
+ const response = await this.rest.request({
1088
+ method: "PATCH",
1089
+ url: route,
1090
+ payload
1091
+ });
1092
+ return await this._updateInternals(response);
1093
+ }
1094
+ async setMvps(...usersId) {
1095
+ const payload = { set: usersId };
1096
+ const route = Routes.guilds.matches.resource(this.guild.id, this._id, "mvps");
1097
+ const response = await this.rest.request({
1098
+ method: "PATCH",
1099
+ url: route,
1100
+ payload
1101
+ });
1102
+ return await this._updateInternals(response);
1103
+ }
1104
+ async setRoomCreatorId(userId) {
1105
+ Assertion.assertString(userId);
1106
+ const payload = { set: userId };
1107
+ const route = Routes.guilds.matches.resource(this.guild.id, this._id, "roomCreatorId");
1108
+ const response = await this.rest.request({
1109
+ method: "PATCH",
1110
+ url: route,
1111
+ payload
1112
+ });
1113
+ return await this._updateInternals(response);
1114
+ }
1115
+ async setRoomAdminId(userId) {
1116
+ Assertion.assertString(userId);
1117
+ const payload = { set: userId };
1118
+ const route = Routes.guilds.matches.resource(this.guild.id, this._id, "admin_id");
1119
+ const response = await this.rest.request({
1120
+ method: "PATCH",
1121
+ url: route,
1122
+ payload
1123
+ });
1124
+ return await this._updateInternals(response);
1125
+ }
1126
+ async kick(player) {
1127
+ this.players = this.players.filter((p) => p.id !== player.id);
1128
+ this.leaders = this.leaders.filter((p) => p.id !== player.id);
1129
+ const teamIndex = this.teams.findIndex((t) => t.some((p) => p.id === player.id));
1130
+ if (teamIndex !== -1) {
1131
+ let team = this.teams.find((t) => t.some((p) => p.id === player.id));
1132
+ team = team.filter((p) => p.id === player.id);
1133
+ this.teams[teamIndex] = team;
1134
+ }
1135
+ return await this.update(this.toJSON());
1136
+ }
1137
+ async update(data) {
1138
+ const route = Routes.guilds.matches.get(this.guild.id, this._id);
1139
+ if (data?.bet && data?.bet instanceof GuildBet) {
1140
+ data.bet = data.bet.toJSON();
1141
+ }
1142
+ const response = await this.rest.request({
1143
+ method: "patch",
1144
+ url: route,
1145
+ payload: data
1146
+ });
1147
+ this.rest.emit("matchUpdate", this, new _GuildMatch(response, this.manager));
1148
+ return await this._updateInternals(response);
1149
+ }
1150
+ async delete() {
1151
+ const route = Routes.guilds.matches.resource(this.guild.id, this._id);
1152
+ const response = await this.rest.request({
1153
+ method: "DELETE",
1154
+ url: route
1155
+ });
1156
+ this.manager.cache.delete(this?._id);
1157
+ this.rest.matches.delete(this?._id);
1158
+ return response;
1159
+ }
1160
+ toJSON() {
1161
+ let json = {};
1162
+ for (const [key, value] of Object.entries(this)) {
1163
+ const exclude = ["rest", "guilds", "guild", "manager"];
1164
+ if (exclude.includes(key)) continue;
1165
+ if (typeof value !== "function") {
1166
+ json[key] = value;
1167
+ }
1168
+ }
1169
+ return {
1170
+ ...json,
1171
+ messages: this?.messages instanceof MessagesManager ? this.messages?.cache?.toArray() : []
1172
+ };
1173
+ }
1174
+ async _updateInternals(data) {
1175
+ if (!data) return;
1176
+ for (let key in data) {
1177
+ if (key === "id" || key === "createdAt" || key === "messages") continue;
1178
+ if (key in this) {
1179
+ this[key] = data[key];
1180
+ }
1181
+ if (key === "bet") {
1182
+ this.bet = this.guild.bets.set(data.bet);
1183
+ }
1184
+ }
1185
+ if (data?.messages?.length !== 0) {
1186
+ if (this?.messages instanceof MessagesManager) this.messages.set(data.messages);
1187
+ else {
1188
+ this.messages = new MessagesManager(this, Routes.guilds.matches.resource(this.guild_id, this._id, "messages"));
1189
+ this.messages.set(data.messages);
1190
+ }
1191
+ }
1192
+ if (!(this.bet instanceof GuildBet) && data?.bet) {
1193
+ this.bet = this.guild.bets.cache.get(data._id) ?? await this.guild.bets.fetch({ betId: data?.bet?._id });
1194
+ }
1195
+ this.updatedAt = /* @__PURE__ */ new Date();
1196
+ this.manager.set(this);
1197
+ return this;
1198
+ }
1199
+ };
1200
+
1201
+ // src/managers/match/GuildMatchManager.ts
1202
+ var GuildMatchManager = class extends BaseManager {
1203
+ /**
1204
+ * Manage users with the given client
1205
+ * @param users An array of users
1206
+ * @param rest The rest client
1207
+ */
1208
+ constructor(guild) {
1209
+ super(guild);
1210
+ this.guild = guild;
1211
+ this.rest = guild.rest;
1212
+ this.base_url = Routes.guilds.matches.getAll(guild.id);
1213
+ this.cache = new Collection("matches");
1214
+ }
1215
+ /**
1216
+ * Fetch a match
1217
+ * @param id Id of the match to fetch
1218
+ * @returns APIBetUser
1219
+ */
1220
+ async fetch(options) {
1221
+ if (options && options.cache) return this.cache;
1222
+ if (options && options.matchId) {
1223
+ const route2 = Routes.guilds.matches.get(this.guild.id, options.matchId);
1224
+ const response2 = await this.rest.request({
1225
+ method: "get",
1226
+ url: route2
1227
+ });
1228
+ return this.set(response2);
1229
+ }
1230
+ const route = Routes.guilds.matches.getAll(this.guild.id);
1231
+ const response = await this.rest.request({
1232
+ method: "get",
1233
+ url: route
1234
+ });
1235
+ if (!response) return this.cache;
1236
+ const coll = new Collection("matches");
1237
+ for (let match of response ?? []) {
1238
+ const guildMatch = new GuildMatch(match, this);
1239
+ coll.set(match._id, guildMatch);
1240
+ this.rest.matches.set(match._id, guildMatch);
1241
+ }
1242
+ this.cache = coll;
1243
+ return coll;
1244
+ }
1245
+ async fetchAll() {
1246
+ const route = Routes.guilds.matches.getAll(this.guild.id);
1247
+ const response = await this.rest.request({
1248
+ method: "get",
1249
+ url: route
1250
+ });
1251
+ if (Array.isArray(response) && response.length === 0) {
1252
+ this.cache.clear();
1253
+ return this.cache;
100
1254
  }
101
- async delete(id) {
102
- const route = Routes_1.Routes.fields(this.base_url, id);
103
- const response = await this.rest.request({ url: route, method: "DELETE" });
104
- return this.set(response);
1255
+ this.set(response);
1256
+ return this.cache;
1257
+ }
1258
+ set(data) {
1259
+ if (!data) return this.cache;
1260
+ if (Array.isArray(data)) {
1261
+ for (let _match of data) {
1262
+ if (!_match._id) continue;
1263
+ const match = new GuildMatch(_match, this);
1264
+ this.cache.set(match._id, match);
1265
+ }
1266
+ return this.cache;
1267
+ } else {
1268
+ if (!data._id) return this.cache;
1269
+ if (data instanceof GuildMatch) {
1270
+ this.cache.set(data._id, data);
1271
+ return data;
1272
+ }
1273
+ const match = new GuildMatch(data, this);
1274
+ this.cache.set(match._id, match);
1275
+ return match;
105
1276
  }
106
- }
107
- exports.GuildMatchManager = GuildMatchManager;
1277
+ }
1278
+ async create(payload) {
1279
+ Assertion.assertObject(payload);
1280
+ const route = Routes.guilds.matches.create(this.guild.id);
1281
+ const response = await this.rest.request({
1282
+ method: "POST",
1283
+ url: route,
1284
+ payload
1285
+ });
1286
+ return this.set(response);
1287
+ }
1288
+ async delete(id) {
1289
+ const route = Routes.fields(this.base_url, id);
1290
+ const response = await this.rest.request({ url: route, method: "DELETE" });
1291
+ return this.set(response);
1292
+ }
1293
+ };
1294
+ // Annotate the CommonJS export names for ESM import in node:
1295
+ 0 && (module.exports = {
1296
+ GuildMatchManager
1297
+ });