@duque.edits/sdk 1.0.82 → 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 (311) 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 +179 -32
  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 -113
  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 -82
  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 +860 -159
  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 -191
  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 -397
  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 -255
  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 -39
  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/dist/types/api/APIGuildPermissions.d.ts +15 -0
  205. package/dist/types/api/APIGuildPermissions.js +37 -10
  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 -3
  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 +13 -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 -8
  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 -53
  288. package/types/structures/betuser/GuildBetUser.d.ts +0 -70
  289. package/types/structures/guild/Guild.d.ts +0 -79
  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 -74
  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 -116
  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/APIGuildPermissions.d.ts +0 -12
  306. package/types/types/api/APIGuildRole.d.ts +0 -10
  307. package/types/types/api/APIGuildUser.d.ts +0 -40
  308. package/types/types/api/APILogMessage.d.ts +0 -7
  309. package/types/types/api/index.d.ts +0 -161
  310. package/types/types/index.d.ts +0 -2
  311. package/types/utils/getRandomNumber.d.ts +0 -1
@@ -1,271 +1,1186 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GuildMatch = void 0;
4
- const Routes_1 = require("../../rest/Routes");
5
- const Assertion_1 = require("../../utils/Assertion");
6
- const managers_1 = require("../../managers");
7
- const GuildBet_1 = require("../bet/GuildBet");
8
- class GuildMatch {
9
- _id;
10
- selections;
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");
128
+ }
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
+ }
156
+ }
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;
187
+ }
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`;
218
+ }
219
+ }
220
+ } else {
221
+ possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
222
+ }
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}`);
299
+ }
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;
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/structures/match/GuildMatch.ts
395
+ var GuildMatch_exports = {};
396
+ __export(GuildMatch_exports, {
397
+ GuildMatch: () => GuildMatch
398
+ });
399
+ module.exports = __toCommonJS(GuildMatch_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);
562
+ }
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/player/PlayerManager.ts
635
+ var PlayerManager = class extends Collection {
636
+ constructor(structure, base_url) {
637
+ super("players");
638
+ __publicField(this, "base_url");
639
+ __publicField(this, "rest");
640
+ __publicField(this, "guild");
641
+ this.base_url = base_url;
642
+ this.guild = structure.guild;
643
+ this.rest = structure.rest;
644
+ }
645
+ _set(data) {
646
+ this.clear();
647
+ if (Array.isArray(data)) {
648
+ for (let p of data) {
649
+ if (!p.id) continue;
650
+ this.set(p.id, {
651
+ id: p.id,
652
+ createdAt: p.createdAt ? new Date(p.createdAt) : /* @__PURE__ */ new Date(),
653
+ updateAt: p.updateAt ? new Date(p.updateAt) : /* @__PURE__ */ new Date()
654
+ });
655
+ }
656
+ } else {
657
+ if (!data.id) return;
658
+ this.set(data.id, {
659
+ id: data.id,
660
+ createdAt: data.createdAt ? new Date(data.createdAt) : /* @__PURE__ */ new Date(),
661
+ updateAt: data.updateAt ? new Date(data.updateAt) : /* @__PURE__ */ new Date()
662
+ });
663
+ }
664
+ return this;
665
+ }
666
+ /**
667
+ * Adds a player or an array of players to the structure.
668
+ * @param player A player or an array of players to be added
669
+ * @returns returns a collection of players
670
+ */
671
+ async add(player) {
672
+ let players = [];
673
+ if (Array.isArray(player)) {
674
+ for (let p of player) this.has(p.id) ? null : players.push(p);
675
+ } else this.has(player.id) ? null : players.push(player);
676
+ const payload = { set: players };
677
+ const response = await this.rest.request({
678
+ method: "PATCH",
679
+ payload,
680
+ url: this.base_url
681
+ });
682
+ return this._set(response.players);
683
+ }
684
+ /**
685
+ * Remover a player or an array of players.
686
+ * @param player The player or an array of players to be removed
687
+ * @returns Player manager
688
+ */
689
+ async remove(player) {
690
+ const ids = new Set(Array.isArray(player) ? player.map((p) => p.id) : [player.id]);
691
+ const players = this.toArray().filter((p) => !ids.has(p.id));
692
+ const payload = { set: players };
693
+ const response = await this.rest.request({
694
+ method: "PATCH",
695
+ payload,
696
+ url: this.base_url
697
+ });
698
+ return this._set(response.players);
699
+ }
700
+ };
701
+
702
+ // src/rest/REST.ts
703
+ var import_dotenv = __toESM(require_main());
704
+ var import_undici = require("undici");
705
+ import_dotenv.default.config();
706
+
707
+ // src/structures/bet/GuildBet.ts
708
+ var GuildBet = class {
709
+ constructor(data, manager) {
710
+ /** The bet's type */
711
+ __publicField(this, "type");
712
+ /** The bet's mode */
713
+ __publicField(this, "mode");
714
+ /** The bet's status */
715
+ __publicField(this, "status");
716
+ /** The bet's maximum size */
717
+ __publicField(this, "maximumSize");
718
+ /** The bet's price */
719
+ __publicField(this, "price");
720
+ /** The bet's players */
721
+ __publicField(this, "players");
722
+ __publicField(this, "teams");
723
+ /** The bet's channel */
724
+ __publicField(this, "channels");
725
+ /** The bet's messages */
726
+ __publicField(this, "messages");
727
+ /** The id of the winner */
728
+ __publicField(this, "winners");
729
+ /** The id of the loser */
730
+ __publicField(this, "losers");
731
+ /** The bet's creator id */
732
+ __publicField(this, "creatorId");
733
+ /** The bet's mediator */
734
+ __publicField(this, "mediatorId");
735
+ /** The bet's confirmers */
736
+ __publicField(this, "confirmed");
737
+ /** Creation Date */
738
+ __publicField(this, "createdAt");
739
+ /** Updated Date */
740
+ __publicField(this, "updatedAt");
741
+ /** Bet's id */
742
+ __publicField(this, "_id");
743
+ __publicField(this, "queues");
744
+ __publicField(this, "guild_id");
745
+ __publicField(this, "rest");
746
+ __publicField(this, "guild");
747
+ __publicField(this, "manager");
748
+ this.manager = manager;
749
+ this.guild = manager.guild;
750
+ this.rest = manager.rest;
751
+ this._id = data?._id;
752
+ this.guild_id = data?.guild_id;
753
+ this.type = data?.type;
754
+ this.mode = data?.mode;
755
+ this.status = data?.status;
756
+ this.maximumSize = data?.maximumSize;
757
+ this.price = data?.price;
758
+ this.teams = data?.teams;
759
+ this.channels = data?.channels;
760
+ this.players = new PlayerManager(this, Routes.guilds.bets.resource(this.guild_id, this._id, "players"));
761
+ this.messages = new MessagesManager(this, Routes.guilds.bets.resource(this.guild_id, this._id, "messages"));
762
+ this.winners = data?.winners;
763
+ this.losers = data?.losers;
764
+ this.creatorId = data?.creatorId;
765
+ this.mediatorId = data?.mediatorId;
766
+ this.confirmed = data?.confirmed;
767
+ this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
768
+ this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
769
+ this.queues = [];
770
+ for (let queue of data.queues ?? []) {
771
+ this.queues.push({
772
+ _id: queue?._id,
773
+ type: queue?.type,
774
+ players: queue?.players,
775
+ updatedAt: queue?.updatedAt ? new Date(queue?.updatedAt) : /* @__PURE__ */ new Date(),
776
+ createdAt: queue?.createdAt ? new Date(queue?.createdAt) : /* @__PURE__ */ new Date()
777
+ });
778
+ }
779
+ if (data?.messages?.length !== 0) this.messages.set(data.messages);
780
+ if (data?.players.length !== 0) this.players._set(data.players);
781
+ }
782
+ toString() {
783
+ return this._id;
784
+ }
785
+ async fetch() {
786
+ const route = Routes.guilds.bets.get(this.guild.id, this._id);
787
+ const response = await this.rest.request({ url: route, method: "GET" });
788
+ return this._updateInternals(response);
789
+ }
790
+ async addPlayer(player, queue_type) {
791
+ if (this.players.length === 2) return this;
792
+ if (this.players.has(player.id)) return this;
793
+ this.players.set(player.id, player);
794
+ if (queue_type) {
795
+ const queue = this.queues.find((q) => q.type === queue_type);
796
+ if (!queue) return this;
797
+ for (const q of this.queues) {
798
+ q.players = q.players.filter((p) => p.id !== player.id);
799
+ }
800
+ if (!queue.players.some((p) => p.id === player.id)) {
801
+ queue.players.push({ id: player.id });
802
+ }
803
+ }
804
+ return await this.update({
805
+ players: this.players.toArray(),
806
+ queues: this.queues
807
+ });
808
+ }
809
+ async removePlayer(player) {
810
+ if (!this.players.some((p) => p.id === player.id)) return this;
811
+ let players = this.players.toArray();
812
+ players = this.players.filter((p) => p.id !== player.id).toArray();
813
+ for (const q of this.queues) {
814
+ q.players = q.players.filter((p) => p.id !== player.id);
815
+ }
816
+ return await this.update({
817
+ players,
818
+ queues: this.queues
819
+ });
820
+ }
821
+ async update(data) {
822
+ const payload = data;
823
+ const route = Routes.guilds.bets.update(this.guild.id, this._id);
824
+ const response = await this.rest.request({ method: "patch", url: route, payload });
825
+ return this._updateInternals(response);
826
+ }
827
+ async delete() {
828
+ const route = Routes.guilds.bets.delete(this.manager.guild.id, this._id);
829
+ const response = await this.rest.request({
830
+ method: "DELETE",
831
+ url: route
832
+ });
833
+ this.rest.emit("betDelete", this);
834
+ this.manager.cache.delete(this._id);
835
+ return response;
836
+ }
837
+ _updateInternals(data) {
838
+ for (let key in data) {
839
+ if (key === "_id" || key === "createdAt") continue;
840
+ if (key === "messages") {
841
+ this.messages.set(data[key]);
842
+ continue;
843
+ }
844
+ if (key === "players") {
845
+ this.players._set(data[key]);
846
+ continue;
847
+ }
848
+ if (key in this) {
849
+ this[key] = data[key];
850
+ }
851
+ }
852
+ if (data?.messages?.length !== 0) {
853
+ if (this?.messages instanceof MessagesManager) this.messages.set(data.messages);
854
+ else {
855
+ this.messages = new MessagesManager(this, Routes.guilds.matches.resource(this.guild_id, this._id, "messages"));
856
+ this.messages.set(data.messages);
857
+ }
858
+ }
859
+ this.updatedAt = /* @__PURE__ */ new Date();
860
+ this.createdAt = new Date(data.createdAt);
861
+ this.manager.set(this);
862
+ return this;
863
+ }
864
+ toJSON() {
865
+ let json = {};
866
+ for (const [key, value] of Object.entries(this)) {
867
+ const exclude = ["rest", "guild", "manager"];
868
+ if (exclude.includes(key)) continue;
869
+ if (typeof value !== "function") {
870
+ json[key] = value;
871
+ }
872
+ }
873
+ return {
874
+ ...json,
875
+ messages: this?.messages instanceof MessagesManager ? this.messages?.cache?.toArray() : [],
876
+ players: this.players.toArray()
877
+ };
878
+ }
879
+ };
880
+
881
+ // src/managers/message/MessagesManager.ts
882
+ var MessagesManager = class {
883
+ constructor(structure, base_url) {
884
+ __publicField(this, "cache");
885
+ __publicField(this, "base_url");
886
+ __publicField(this, "rest");
887
+ __publicField(this, "guild");
888
+ this.rest = structure.rest;
889
+ this.guild = structure.guild;
890
+ this.cache = new Collection("messages");
891
+ this.base_url = base_url;
892
+ }
893
+ async fetch() {
894
+ const response = await this.rest.request({
895
+ method: "GET",
896
+ url: this.base_url,
897
+ payload: {}
898
+ });
899
+ this.cache.set(response._id, response);
900
+ return response;
901
+ }
902
+ async create(data) {
903
+ const messages = [...this.cache.toArray()];
904
+ if (Array.isArray(data)) messages.push(...data);
905
+ else messages.push(data);
906
+ const response = await this.rest.request({
907
+ method: "PATCH",
908
+ url: this.base_url,
909
+ payload: { set: messages }
910
+ });
911
+ return this.set(response.messages);
912
+ }
913
+ set(data) {
914
+ if (!data) return this.cache;
915
+ if (Array.isArray(data)) {
916
+ for (let message of data) {
917
+ if (message && !message._id) continue;
918
+ this.cache.set(message._id, message);
919
+ }
920
+ } else {
921
+ if (data && !data._id) return this.cache;
922
+ this.cache.set(data._id, data);
923
+ }
924
+ return this.cache;
925
+ }
926
+ };
927
+
928
+ // src/structures/match/GuildMatch.ts
929
+ var GuildMatch = class _GuildMatch {
930
+ /**
931
+ * GuildMatch match
932
+ * @param data The match's data
933
+ * @param guild The guild
934
+ * @param rest The rest client
935
+ */
936
+ constructor(data, manager) {
937
+ __publicField(this, "_id");
938
+ __publicField(this, "selections");
11
939
  /** Match's type */
12
- type;
13
- channels;
14
- guild_id;
940
+ __publicField(this, "type");
941
+ __publicField(this, "channels");
942
+ __publicField(this, "guild_id");
15
943
  /** Match's status */
16
- status;
944
+ __publicField(this, "status");
17
945
  /** Match's challenge */
18
- challenge;
946
+ __publicField(this, "challenge");
19
947
  /** Match's players */
20
- players;
21
- teams;
948
+ __publicField(this, "players");
949
+ __publicField(this, "teams");
22
950
  /** Match's winners */
23
- winners;
951
+ __publicField(this, "winners");
24
952
  /** Match's losers */
25
- losers;
953
+ __publicField(this, "losers");
26
954
  /** Match's maximum size */
27
- maximumSize;
955
+ __publicField(this, "maximumSize");
28
956
  /** Match's kicked out */
29
- kickedOut;
957
+ __publicField(this, "kickedOut");
30
958
  /** Match's confirmed */
31
- confirmed;
959
+ __publicField(this, "confirmed");
32
960
  /** Match's leaders */
33
- leaders;
961
+ __publicField(this, "leaders");
34
962
  /** Match's creator id */
35
- creatorId;
963
+ __publicField(this, "creatorId");
36
964
  /** Match's room creator id */
37
- roomCreatorId;
965
+ __publicField(this, "roomCreatorId");
38
966
  /** Creation Date */
39
- createdAt;
967
+ __publicField(this, "createdAt");
40
968
  /** Updated Date */
41
- updatedAt;
42
- messages;
969
+ __publicField(this, "updatedAt");
970
+ __publicField(this, "messages");
43
971
  /** Match's id */
44
- mvps;
45
- manager;
46
- bet;
47
- admin_id;
972
+ __publicField(this, "mvps");
973
+ __publicField(this, "manager");
974
+ __publicField(this, "bet");
975
+ __publicField(this, "admin_id");
48
976
  /** The given guild */
49
- guild;
977
+ __publicField(this, "guild");
50
978
  /** The rest client */
51
- rest;
52
- key;
53
- /**
54
- * GuildMatch match
55
- * @param data The match's data
56
- * @param guild The guild
57
- * @param rest The rest client
58
- */
59
- constructor(data, manager) {
60
- this._id = data?._id;
61
- this.guild_id = data?.guild_id;
62
- this.manager = manager;
63
- this.guild = manager.guild;
64
- this.rest = manager.rest;
65
- this.admin_id = data?.admin_id;
66
- this.challenge = data?.challenge;
67
- this.players = data?.players;
68
- this.messages = new managers_1.MessagesManager(this, Routes_1.Routes.guilds.matches.resource(this.guild_id, this._id, "messages"));
69
- this.channels = data?.channels;
70
- this.type = data?.type;
71
- this.status = data?.status;
72
- this.bet = this.guild.bets.cache.get(data?.bet?._id);
73
- this.mvps = data?.mvps;
74
- this.winners = data?.winners;
75
- this.losers = data?.losers;
76
- this.maximumSize = data?.maximumSize;
77
- this.kickedOut = data?.kickedOut;
78
- this.confirmed = data?.confirmed;
79
- this.teams = data?.teams;
80
- this.leaders = data?.leaders;
81
- this.creatorId = data?.creatorId;
82
- this.roomCreatorId = data?.roomCreatorId;
83
- this.selections = data?.selections;
84
- this.key = "matches";
85
- this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
86
- this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
87
- if (data?.messages?.length !== 0)
88
- this.messages.set(data.messages);
89
- }
90
- /**
91
- * Fetches the match
92
- * @returns New Instance of the match
93
- */
94
- async fetch() {
95
- const route = Routes_1.Routes.guilds.matches.get(this.guild.id, this._id);
96
- const response = await this.rest.request({
97
- method: "get",
98
- url: route,
99
- });
100
- return await this._updateInternals(response);
979
+ __publicField(this, "rest");
980
+ __publicField(this, "key");
981
+ this._id = data?._id;
982
+ this.guild_id = data?.guild_id;
983
+ this.manager = manager;
984
+ this.guild = manager.guild;
985
+ this.rest = manager.rest;
986
+ this.admin_id = data?.admin_id;
987
+ this.challenge = data?.challenge;
988
+ this.players = data?.players;
989
+ this.messages = new MessagesManager(this, Routes.guilds.matches.resource(this.guild_id, this._id, "messages"));
990
+ this.channels = data?.channels;
991
+ this.type = data?.type;
992
+ this.status = data?.status;
993
+ this.bet = this.guild.bets.cache.get(data?.bet?._id);
994
+ this.mvps = data?.mvps;
995
+ this.winners = data?.winners;
996
+ this.losers = data?.losers;
997
+ this.maximumSize = data?.maximumSize;
998
+ this.kickedOut = data?.kickedOut;
999
+ this.confirmed = data?.confirmed;
1000
+ this.teams = data?.teams;
1001
+ this.leaders = data?.leaders;
1002
+ this.creatorId = data?.creatorId;
1003
+ this.roomCreatorId = data?.roomCreatorId;
1004
+ this.selections = data?.selections;
1005
+ this.key = "matches";
1006
+ this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
1007
+ this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
1008
+ if (data?.messages?.length !== 0) this.messages.set(data.messages);
1009
+ }
1010
+ /**
1011
+ * Fetches the match
1012
+ * @returns New Instance of the match
1013
+ */
1014
+ async fetch() {
1015
+ const route = Routes.guilds.matches.get(this.guild.id, this._id);
1016
+ const response = await this.rest.request({
1017
+ method: "get",
1018
+ url: route
1019
+ });
1020
+ return await this._updateInternals(response);
1021
+ }
1022
+ async addConfirmed(type, id) {
1023
+ const confirmed = this.confirmed.find((c) => c.type === type);
1024
+ const idsToAdd = Array.isArray(id) ? id : [id];
1025
+ if (!confirmed) {
1026
+ this.confirmed.push({ type, ids: [...idsToAdd], count: idsToAdd.length });
1027
+ } else {
1028
+ const chIndex = this.confirmed.findIndex((ch) => ch.type === type);
1029
+ const mergedIds = [.../* @__PURE__ */ new Set([...confirmed.ids || [], ...idsToAdd])];
1030
+ this.confirmed[chIndex] = { ...confirmed, ids: mergedIds, count: mergedIds.length };
101
1031
  }
102
- async addConfirmed(type, id) {
103
- const confirmed = this.confirmed.find((c) => c.type === type);
104
- const idsToAdd = Array.isArray(id) ? id : [id];
105
- if (!confirmed) {
106
- this.confirmed.push({ type, ids: [...idsToAdd], count: idsToAdd.length });
107
- }
108
- else {
109
- const chIndex = this.confirmed.findIndex((ch) => ch.type === type);
110
- const mergedIds = [...new Set([...(confirmed.ids || []), ...idsToAdd])];
111
- this.confirmed[chIndex] = { ...confirmed, ids: mergedIds, count: mergedIds.length };
112
- }
113
- return this.update({ confirmed: this.confirmed });
114
- }
115
- async setConfirmed(set) {
116
- Assertion_1.Assertion.assertObject(set);
117
- const route = Routes_1.Routes.guilds.matches.resource(this.guild.id, this._id, "confirmed");
118
- const response = await this.rest.request({
119
- method: "PATCH",
120
- url: route,
121
- payload: set,
122
- });
123
- return await this._updateInternals(response);
124
- }
125
- async setStatus(status) {
126
- Assertion_1.Assertion.assertString(status);
127
- const payload = { set: status.toLowerCase() };
128
- const route = Routes_1.Routes.guilds.matches.resource(this.guild.id, this._id, "status");
129
- const response = await this.rest.request({
130
- method: "PATCH",
131
- url: route,
132
- payload,
133
- });
134
- return await this._updateInternals(response);
135
- }
136
- async setWinners(players) {
137
- if (!Array.isArray(players))
138
- players = [players];
139
- const payload = { set: players };
140
- const route = Routes_1.Routes.guilds.matches.resource(this.guild.id, this._id, "winners");
141
- const response = await this.rest.request({
142
- method: "PATCH",
143
- url: route,
144
- payload,
145
- });
146
- return await this._updateInternals(response);
147
- }
148
- async setLoser(players) {
149
- if (!Array.isArray(players))
150
- players = [players];
151
- const payload = { set: players };
152
- const route = Routes_1.Routes.guilds.matches.resource(this.guild.id, this._id, "losers");
153
- const response = await this.rest.request({
154
- method: "PATCH",
155
- url: route,
156
- payload,
157
- });
158
- return await this._updateInternals(response);
159
- }
160
- async setMvps(...usersId) {
161
- const payload = { set: usersId };
162
- const route = Routes_1.Routes.guilds.matches.resource(this.guild.id, this._id, "mvps");
163
- const response = await this.rest.request({
164
- method: "PATCH",
165
- url: route,
166
- payload,
167
- });
168
- return await this._updateInternals(response);
169
- }
170
- async setRoomCreatorId(userId) {
171
- Assertion_1.Assertion.assertString(userId);
172
- const payload = { set: userId };
173
- const route = Routes_1.Routes.guilds.matches.resource(this.guild.id, this._id, "roomCreatorId");
174
- const response = await this.rest.request({
175
- method: "PATCH",
176
- url: route,
177
- payload,
178
- });
179
- return await this._updateInternals(response);
180
- }
181
- async setRoomAdminId(userId) {
182
- Assertion_1.Assertion.assertString(userId);
183
- const payload = { set: userId };
184
- const route = Routes_1.Routes.guilds.matches.resource(this.guild.id, this._id, "admin_id");
185
- const response = await this.rest.request({
186
- method: "PATCH",
187
- url: route,
188
- payload,
189
- });
190
- return await this._updateInternals(response);
191
- }
192
- async kick(player) {
193
- this.players = this.players.filter((p) => p.id !== player.id);
194
- this.leaders = this.leaders.filter((p) => p.id !== player.id);
195
- const teamIndex = this.teams.findIndex((t) => t.some((p) => p.id === player.id));
196
- if (teamIndex !== -1) {
197
- let team = this.teams.find((t) => t.some((p) => p.id === player.id));
198
- team = team.filter((p) => p.id === player.id);
199
- this.teams[teamIndex] = team;
200
- }
201
- return await this.update(this.toJSON());
1032
+ return this.update({ confirmed: this.confirmed });
1033
+ }
1034
+ async setConfirmed(set) {
1035
+ Assertion.assertObject(set);
1036
+ const route = Routes.guilds.matches.resource(this.guild.id, this._id, "confirmed");
1037
+ const response = await this.rest.request({
1038
+ method: "PATCH",
1039
+ url: route,
1040
+ payload: set
1041
+ });
1042
+ return await this._updateInternals(response);
1043
+ }
1044
+ async setStatus(status) {
1045
+ Assertion.assertString(status);
1046
+ const payload = { set: status.toLowerCase() };
1047
+ const route = Routes.guilds.matches.resource(this.guild.id, this._id, "status");
1048
+ const response = await this.rest.request({
1049
+ method: "PATCH",
1050
+ url: route,
1051
+ payload
1052
+ });
1053
+ return await this._updateInternals(response);
1054
+ }
1055
+ async setWinners(players) {
1056
+ if (!Array.isArray(players)) players = [players];
1057
+ const payload = { set: players };
1058
+ const route = Routes.guilds.matches.resource(this.guild.id, this._id, "winners");
1059
+ const response = await this.rest.request({
1060
+ method: "PATCH",
1061
+ url: route,
1062
+ payload
1063
+ });
1064
+ return await this._updateInternals(response);
1065
+ }
1066
+ async setLoser(players) {
1067
+ if (!Array.isArray(players)) players = [players];
1068
+ const payload = { set: players };
1069
+ const route = Routes.guilds.matches.resource(this.guild.id, this._id, "losers");
1070
+ const response = await this.rest.request({
1071
+ method: "PATCH",
1072
+ url: route,
1073
+ payload
1074
+ });
1075
+ return await this._updateInternals(response);
1076
+ }
1077
+ async setMvps(...usersId) {
1078
+ const payload = { set: usersId };
1079
+ const route = Routes.guilds.matches.resource(this.guild.id, this._id, "mvps");
1080
+ const response = await this.rest.request({
1081
+ method: "PATCH",
1082
+ url: route,
1083
+ payload
1084
+ });
1085
+ return await this._updateInternals(response);
1086
+ }
1087
+ async setRoomCreatorId(userId) {
1088
+ Assertion.assertString(userId);
1089
+ const payload = { set: userId };
1090
+ const route = Routes.guilds.matches.resource(this.guild.id, this._id, "roomCreatorId");
1091
+ const response = await this.rest.request({
1092
+ method: "PATCH",
1093
+ url: route,
1094
+ payload
1095
+ });
1096
+ return await this._updateInternals(response);
1097
+ }
1098
+ async setRoomAdminId(userId) {
1099
+ Assertion.assertString(userId);
1100
+ const payload = { set: userId };
1101
+ const route = Routes.guilds.matches.resource(this.guild.id, this._id, "admin_id");
1102
+ const response = await this.rest.request({
1103
+ method: "PATCH",
1104
+ url: route,
1105
+ payload
1106
+ });
1107
+ return await this._updateInternals(response);
1108
+ }
1109
+ async kick(player) {
1110
+ this.players = this.players.filter((p) => p.id !== player.id);
1111
+ this.leaders = this.leaders.filter((p) => p.id !== player.id);
1112
+ const teamIndex = this.teams.findIndex((t) => t.some((p) => p.id === player.id));
1113
+ if (teamIndex !== -1) {
1114
+ let team = this.teams.find((t) => t.some((p) => p.id === player.id));
1115
+ team = team.filter((p) => p.id === player.id);
1116
+ this.teams[teamIndex] = team;
202
1117
  }
203
- async update(data) {
204
- const route = Routes_1.Routes.guilds.matches.get(this.guild.id, this._id);
205
- if (data?.bet && data?.bet instanceof GuildBet_1.GuildBet) {
206
- data.bet = data.bet.toJSON();
207
- }
208
- const response = await this.rest.request({
209
- method: "patch",
210
- url: route,
211
- payload: data,
212
- });
213
- this.rest.emit("matchUpdate", this, new GuildMatch(response, this.manager));
214
- return await this._updateInternals(response);
215
- }
216
- async delete() {
217
- const route = Routes_1.Routes.guilds.matches.resource(this.guild.id, this._id);
218
- const response = await this.rest.request({
219
- method: "DELETE",
220
- url: route,
221
- });
222
- this.manager.cache.delete(this?._id);
223
- this.rest.matches.delete(this?._id);
224
- return response;
225
- }
226
- toJSON() {
227
- let json = {};
228
- for (const [key, value] of Object.entries(this)) {
229
- const exclude = ["rest", "guilds", "guild", "manager"];
230
- if (exclude.includes(key))
231
- continue;
232
- if (typeof value !== "function") {
233
- json[key] = value;
234
- }
235
- }
236
- return {
237
- ...json,
238
- messages: this?.messages instanceof managers_1.MessagesManager ? this.messages?.cache?.toArray() : [],
239
- };
240
- }
241
- async _updateInternals(data) {
242
- if (!data)
243
- return;
244
- for (let key in data) {
245
- if (key === "id" || key === "createdAt" || key === "messages")
246
- continue;
247
- if (key in this) {
248
- this[key] = data[key];
249
- }
250
- if (key === "bet") {
251
- this.bet = this.guild.bets.set(data.bet);
252
- }
253
- }
254
- if (data?.messages?.length !== 0) {
255
- if (this?.messages instanceof managers_1.MessagesManager)
256
- this.messages.set(data.messages);
257
- else {
258
- this.messages = new managers_1.MessagesManager(this, Routes_1.Routes.guilds.matches.resource(this.guild_id, this._id, "messages"));
259
- this.messages.set(data.messages);
260
- }
261
- }
262
- if (!(this.bet instanceof GuildBet_1.GuildBet) && data?.bet) {
263
- this.bet =
264
- this.guild.bets.cache.get(data._id) ?? (await this.guild.bets.fetch({ betId: data?.bet?._id }));
265
- }
266
- this.updatedAt = new Date();
267
- this.manager.set(this);
268
- return this;
1118
+ return await this.update(this.toJSON());
1119
+ }
1120
+ async update(data) {
1121
+ const route = Routes.guilds.matches.get(this.guild.id, this._id);
1122
+ if (data?.bet && data?.bet instanceof GuildBet) {
1123
+ data.bet = data.bet.toJSON();
1124
+ }
1125
+ const response = await this.rest.request({
1126
+ method: "patch",
1127
+ url: route,
1128
+ payload: data
1129
+ });
1130
+ this.rest.emit("matchUpdate", this, new _GuildMatch(response, this.manager));
1131
+ return await this._updateInternals(response);
1132
+ }
1133
+ async delete() {
1134
+ const route = Routes.guilds.matches.resource(this.guild.id, this._id);
1135
+ const response = await this.rest.request({
1136
+ method: "DELETE",
1137
+ url: route
1138
+ });
1139
+ this.manager.cache.delete(this?._id);
1140
+ this.rest.matches.delete(this?._id);
1141
+ return response;
1142
+ }
1143
+ toJSON() {
1144
+ let json = {};
1145
+ for (const [key, value] of Object.entries(this)) {
1146
+ const exclude = ["rest", "guilds", "guild", "manager"];
1147
+ if (exclude.includes(key)) continue;
1148
+ if (typeof value !== "function") {
1149
+ json[key] = value;
1150
+ }
1151
+ }
1152
+ return {
1153
+ ...json,
1154
+ messages: this?.messages instanceof MessagesManager ? this.messages?.cache?.toArray() : []
1155
+ };
1156
+ }
1157
+ async _updateInternals(data) {
1158
+ if (!data) return;
1159
+ for (let key in data) {
1160
+ if (key === "id" || key === "createdAt" || key === "messages") continue;
1161
+ if (key in this) {
1162
+ this[key] = data[key];
1163
+ }
1164
+ if (key === "bet") {
1165
+ this.bet = this.guild.bets.set(data.bet);
1166
+ }
1167
+ }
1168
+ if (data?.messages?.length !== 0) {
1169
+ if (this?.messages instanceof MessagesManager) this.messages.set(data.messages);
1170
+ else {
1171
+ this.messages = new MessagesManager(this, Routes.guilds.matches.resource(this.guild_id, this._id, "messages"));
1172
+ this.messages.set(data.messages);
1173
+ }
1174
+ }
1175
+ if (!(this.bet instanceof GuildBet) && data?.bet) {
1176
+ this.bet = this.guild.bets.cache.get(data._id) ?? await this.guild.bets.fetch({ betId: data?.bet?._id });
269
1177
  }
270
- }
271
- exports.GuildMatch = GuildMatch;
1178
+ this.updatedAt = /* @__PURE__ */ new Date();
1179
+ this.manager.set(this);
1180
+ return this;
1181
+ }
1182
+ };
1183
+ // Annotate the CommonJS export names for ESM import in node:
1184
+ 0 && (module.exports = {
1185
+ GuildMatch
1186
+ });