@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
@@ -0,0 +1,1289 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
+ }) : x)(function(x) {
11
+ if (typeof require !== "undefined") return require.apply(this, arguments);
12
+ throw Error('Dynamic require of "' + x + '" is not supported');
13
+ });
14
+ var __commonJS = (cb, mod) => function __require2() {
15
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
16
+ };
17
+ var __copyProps = (to, from, except, desc) => {
18
+ if (from && typeof from === "object" || typeof from === "function") {
19
+ for (let key of __getOwnPropNames(from))
20
+ if (!__hasOwnProp.call(to, key) && key !== except)
21
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
22
+ }
23
+ return to;
24
+ };
25
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
26
+ // If the importer is in node compatibility mode or this is not an ESM
27
+ // file that has been converted to a CommonJS file using a Babel-
28
+ // compatible transform (i.e. "__esModule" has not been set), then set
29
+ // "default" to the CommonJS "module.exports" for node compatibility.
30
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
31
+ mod
32
+ ));
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"(exports, module) {
38
+ module.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"(exports, module) {
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
+ module.exports.configDotenv = DotenvModule.configDotenv;
384
+ module.exports._configVault = DotenvModule._configVault;
385
+ module.exports._parseVault = DotenvModule._parseVault;
386
+ module.exports.config = DotenvModule.config;
387
+ module.exports.decrypt = DotenvModule.decrypt;
388
+ module.exports.parse = DotenvModule.parse;
389
+ module.exports.populate = DotenvModule.populate;
390
+ module.exports = DotenvModule;
391
+ }
392
+ });
393
+
394
+ // src/rest/Routes.ts
395
+ var Routes = {
396
+ //base: "http://localhost:80/api/v1",
397
+ base: "https://duque-api.up.railway.app/api/v1",
398
+ field: (field) => `/${field}`,
399
+ fields: (...fields) => `${fields.join("/")}`,
400
+ guilds: {
401
+ create: () => `/guilds`,
402
+ get: (guildId) => `/guilds/${guildId}`,
403
+ getAll: () => `/guilds`,
404
+ delete: (guildId) => `/guilds/${guildId}`,
405
+ deleteAll: () => `/guilds`,
406
+ resource: (guildId, ...resources) => `/guilds/${guildId}/manage/${resources.join("/")}`,
407
+ resources: (guildId, ...resources) => `/guilds/${guildId}/manage/${resources.join("/")}`,
408
+ users: {
409
+ create: (guildId) => `/guilds/${guildId}/users`,
410
+ update: (guildId, userId) => `/guilds/${guildId}/users/${userId}`,
411
+ getAll: (guildId) => `/guilds/${guildId}/users`,
412
+ get: (guildId, userId) => `/guilds/${guildId}/users/${userId}`,
413
+ delete: (guildId, userId) => `/guilds/${guildId}/users/${userId}`,
414
+ deleteAll: (guildId) => `/guilds/${guildId}/users`,
415
+ resource: (guildId, userId, ...resource) => `/guilds/${guildId}/users/${userId}/${resource.join("/")}`
416
+ },
417
+ betusers: {
418
+ getAll: (guildId) => `/guilds/${guildId}/betusers`,
419
+ get: (guildId, userId) => `/guilds/${guildId}/betusers/${userId}`,
420
+ create: (guildId) => `/guilds/${guildId}/betusers`,
421
+ update: (guildId, userId) => `/guilds/${guildId}/betusers/${userId}`,
422
+ delete: (guildId, userId) => `/guilds/${guildId}/betusers/${userId}`,
423
+ deleteAll: (guildId) => `/guilds/${guildId}/betusers`,
424
+ resource: (guildId, userId, resourceName) => `/guilds/${guildId}/betusers/${userId}/${resourceName}`
425
+ },
426
+ matches: {
427
+ getAll: (guildId) => `/guilds/${guildId}/matches`,
428
+ get: (guildId, matchId) => `/guilds/${guildId}/matches/${matchId}`,
429
+ create: (guildId) => `/guilds/${guildId}/matches`,
430
+ update: (guildId, matchId) => `/guilds/${guildId}/matches/${matchId}`,
431
+ delete: (guildId, matchId) => `/guilds/${guildId}/matches/${matchId}`,
432
+ deleteAll: (guildId) => `/guilds/${guildId}/matches`,
433
+ resource: (guildId, matchId, ...resources) => `/guilds/${guildId}/matches/${matchId}/${resources.join("/")}`
434
+ },
435
+ bets: {
436
+ getAll: (guildId) => `/guilds/${guildId}/bets`,
437
+ get: (guildId, betId) => `/guilds/${guildId}/bets/${betId}`,
438
+ create: (guildId) => `/guilds/${guildId}/bets`,
439
+ update: (guildId, betId) => `/guilds/${guildId}/bets/${betId}`,
440
+ delete: (guildId, betId) => `/guilds/${guildId}/bets/${betId}`,
441
+ deleteAll: (guildId) => `/guilds/${guildId}/bets`,
442
+ resource: (guildId, betId, ...resources) => `/guilds/${guildId}/bets/${betId}/${resources.join("/")}`
443
+ },
444
+ tickets: {
445
+ getAll: (guildId) => `/guilds/${guildId}/tickets`,
446
+ get: (guildId, ticketId) => `/guilds/${guildId}/tickets/${ticketId}`,
447
+ create: (guildId) => `/guilds/${guildId}/tickets`,
448
+ update: (guildId, ticketId) => `/guilds/${guildId}/tickets/${ticketId}`,
449
+ delete: (guildId, ticketId) => `/guilds/${guildId}/tickets/${ticketId}`,
450
+ deleteAll: (guildId) => `/guilds/${guildId}/tickets`,
451
+ resource: (guildId, ticketId, ...resources) => `/guilds/${guildId}/tickets/${ticketId}/${resources.join("/")}`
452
+ },
453
+ mediators: {
454
+ getAll: (guildId) => `/guilds/${guildId}/mediators`,
455
+ get: (guildId, mediatorId) => `/guilds/${guildId}/mediators/${mediatorId}`,
456
+ create: (guildId) => `/guilds/${guildId}/mediators`,
457
+ update: (guildId, mediatorId) => `/guilds/${guildId}/mediators/${mediatorId}`,
458
+ delete: (guildId, mediatorId) => `/guilds/${guildId}/mediators/${mediatorId}`,
459
+ deleteAll: (guildId) => `/guilds/${guildId}/mediators`,
460
+ resource: (guildId, mediatorId, ...resources) => `/guilds/${guildId}/mediators/${mediatorId}/${resources.join("/")}`
461
+ },
462
+ shop: {
463
+ get: (guildId) => `/guilds/${guildId}/manage/shop`,
464
+ update: (guildId) => `/guilds/${guildId}/manage/shop`,
465
+ delete: (guildId) => `/guilds/${guildId}/manage/shop/ `,
466
+ resource: (guildId, ...resources) => `/guilds/${guildId}/manage/shop/${resources.join("/")}`,
467
+ products: {
468
+ getAll: (guildId) => `/guilds/${guildId}/manage/shop/products`,
469
+ get: (guildId, productId) => `/guilds/${guildId}/manage/shop/${productId}/products`,
470
+ create: (guildId) => `/guilds/${guildId}/manage/shop/products`,
471
+ update: (guildId, productId) => `/guilds/${guildId}/manage/shop/products/${productId}`,
472
+ delete: (guildId, productId) => `/guilds/${guildId}/manage/shop/products/${productId}`,
473
+ deleteAll: (guildId) => `/guilds/${guildId}/products/shop`,
474
+ resource: (guildId, productId, ...resources) => `/guilds/${guildId}/manage/shop/products/${productId}/${resources.join("/")}`
475
+ }
476
+ }
477
+ },
478
+ vipmembers: {
479
+ get: (guildId, memberId) => `/guilds/${guildId}/vipmembers/${memberId}`,
480
+ getAll: (guildId) => `/guilds/${guildId}/vipmembers`,
481
+ deleteAll: (guildId) => `/guilds/${guildId}/vipmembers`,
482
+ create: (guildId) => `/guilds/${guildId}/vipmembers`,
483
+ update: (guildId, memberId) => `/guilds/${guildId}/vipmembers/${memberId}`,
484
+ delete: (guildId, memberId) => `/guilds/${guildId}/vipmembers/${memberId}`
485
+ },
486
+ giveaways: {
487
+ get: (giveawayId) => `/giveaways/${giveawayId}`,
488
+ getAll: () => `/giveaways`,
489
+ deleteAll: () => `/giveaways`,
490
+ create: () => `/giveaways`,
491
+ update: (giveawayId) => `/giveaways/${giveawayId}`,
492
+ delete: (giveawayId) => `/giveaways/${giveawayId}`
493
+ }
494
+ };
495
+
496
+ // src/utils/Assertion.ts
497
+ var Assertion = class {
498
+ constructor() {
499
+ }
500
+ /**
501
+ * Tests if given key is a string
502
+ * @param key Key to test
503
+ */
504
+ static assertString(key) {
505
+ if (typeof key !== "string") throw new Error(`${key} must be a string`);
506
+ if (!key || key === "") throw new Error(`${key} must be a string`);
507
+ return true;
508
+ }
509
+ /**
510
+ * Tests if given key is a number
511
+ * @param key Key to test
512
+ */
513
+ static assertNumber(key) {
514
+ if (typeof key !== "number") throw new Error(`${key} must be a number`);
515
+ return true;
516
+ }
517
+ /**
518
+ * Tests if given key is a boolean
519
+ * @param key Key to test
520
+ */
521
+ static assertBoolean(key) {
522
+ if (typeof key !== "boolean") throw new Error(`${key} must be a boolean`);
523
+ return true;
524
+ }
525
+ /**
526
+ * Tests if given key is an array
527
+ * @param key Key to test
528
+ */
529
+ static assertArray(key) {
530
+ if (!Array.isArray(key)) throw new Error(`${key} must be an array`);
531
+ return true;
532
+ }
533
+ /**
534
+ * Tests if given key is an object
535
+ * @param key Key to test
536
+ */
537
+ static assertObject(key) {
538
+ if (typeof key !== "object") throw new Error(`${key} must be an object`);
539
+ return true;
540
+ }
541
+ toString() {
542
+ return "string, number, boolean, array, object";
543
+ }
544
+ };
545
+
546
+ // src/structures/Collection.ts
547
+ var Collection = class _Collection extends Map {
548
+ constructor(key, data) {
549
+ super();
550
+ __publicField(this, "key");
551
+ this.key = key;
552
+ if (data && Array.isArray(data) && key) {
553
+ if (data.length > 0) return;
554
+ for (let v of data) this.set(key, v);
555
+ }
556
+ }
557
+ at(index) {
558
+ if (index < 0 || index >= this.size) {
559
+ return void 0;
560
+ }
561
+ let i = 0;
562
+ for (let [, value] of this) {
563
+ if (i === index) {
564
+ return value;
565
+ }
566
+ i++;
567
+ }
568
+ }
569
+ has(key) {
570
+ return this.get(key) !== void 0 ? true : false;
571
+ }
572
+ get first() {
573
+ return this.values().next().value;
574
+ }
575
+ get last() {
576
+ return [...this.values()].at(-1);
577
+ }
578
+ get length() {
579
+ return this.toArray().length;
580
+ }
581
+ find(predicate) {
582
+ for (const [key, value] of this) {
583
+ if (predicate(value, key, this)) return value;
584
+ }
585
+ return void 0;
586
+ }
587
+ filter(predicate) {
588
+ const results = new _Collection(this.key, []);
589
+ for (const [key, value] of this) {
590
+ if (predicate(value, key, this)) results.set(key, value);
591
+ }
592
+ return results;
593
+ }
594
+ some(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
+ map(callback) {
602
+ return [...this].map(([key, val]) => callback(val, key, this));
603
+ }
604
+ toArray() {
605
+ return [...this.values()];
606
+ }
607
+ toJSON() {
608
+ let obj = {};
609
+ for (let [k, v] of this.entries()) {
610
+ obj[`${k}`] = v;
611
+ }
612
+ return obj;
613
+ }
614
+ sort(compareFunction) {
615
+ const sortedEntries = [...this.entries()].sort((ab, ba) => {
616
+ return compareFunction(ab[1], ba[1], this);
617
+ });
618
+ const coll = new _Collection();
619
+ for (let [k, v] of sortedEntries) coll.set(k, v);
620
+ return coll;
621
+ }
622
+ toString() {
623
+ return `${this.size}`;
624
+ }
625
+ };
626
+
627
+ // src/managers/base.ts
628
+ var BaseManager = class {
629
+ constructor(guild) {
630
+ /** This url of the manager */
631
+ __publicField(this, "base_url");
632
+ /** The rest client */
633
+ __publicField(this, "rest");
634
+ /** The guild of the manager */
635
+ __publicField(this, "guild");
636
+ /** Cache */
637
+ __publicField(this, "cache");
638
+ this.guild = guild;
639
+ this.rest = guild.rest;
640
+ this.cache = new Collection();
641
+ }
642
+ };
643
+
644
+ // src/managers/player/PlayerManager.ts
645
+ var PlayerManager = class extends Collection {
646
+ constructor(structure, base_url) {
647
+ super("players");
648
+ __publicField(this, "base_url");
649
+ __publicField(this, "rest");
650
+ __publicField(this, "guild");
651
+ this.base_url = base_url;
652
+ this.guild = structure.guild;
653
+ this.rest = structure.rest;
654
+ }
655
+ _set(data) {
656
+ this.clear();
657
+ if (Array.isArray(data)) {
658
+ for (let p of data) {
659
+ if (!p.id) continue;
660
+ this.set(p.id, {
661
+ id: p.id,
662
+ createdAt: p.createdAt ? new Date(p.createdAt) : /* @__PURE__ */ new Date(),
663
+ updateAt: p.updateAt ? new Date(p.updateAt) : /* @__PURE__ */ new Date()
664
+ });
665
+ }
666
+ } else {
667
+ if (!data.id) return;
668
+ this.set(data.id, {
669
+ id: data.id,
670
+ createdAt: data.createdAt ? new Date(data.createdAt) : /* @__PURE__ */ new Date(),
671
+ updateAt: data.updateAt ? new Date(data.updateAt) : /* @__PURE__ */ new Date()
672
+ });
673
+ }
674
+ return this;
675
+ }
676
+ /**
677
+ * Adds a player or an array of players to the structure.
678
+ * @param player A player or an array of players to be added
679
+ * @returns returns a collection of players
680
+ */
681
+ async add(player) {
682
+ let players = [];
683
+ if (Array.isArray(player)) {
684
+ for (let p of player) this.has(p.id) ? null : players.push(p);
685
+ } else this.has(player.id) ? null : players.push(player);
686
+ const payload = { set: players };
687
+ const response = await this.rest.request({
688
+ method: "PATCH",
689
+ payload,
690
+ url: this.base_url
691
+ });
692
+ return this._set(response.players);
693
+ }
694
+ /**
695
+ * Remover a player or an array of players.
696
+ * @param player The player or an array of players to be removed
697
+ * @returns Player manager
698
+ */
699
+ async remove(player) {
700
+ const ids = new Set(Array.isArray(player) ? player.map((p) => p.id) : [player.id]);
701
+ const players = this.toArray().filter((p) => !ids.has(p.id));
702
+ const payload = { set: players };
703
+ const response = await this.rest.request({
704
+ method: "PATCH",
705
+ payload,
706
+ url: this.base_url
707
+ });
708
+ return this._set(response.players);
709
+ }
710
+ };
711
+
712
+ // src/rest/REST.ts
713
+ var import_dotenv = __toESM(require_main());
714
+ import { request, Headers } from "undici";
715
+ import_dotenv.default.config();
716
+
717
+ // src/structures/bet/GuildBet.ts
718
+ var GuildBet = class {
719
+ constructor(data, manager) {
720
+ /** The bet's type */
721
+ __publicField(this, "type");
722
+ /** The bet's mode */
723
+ __publicField(this, "mode");
724
+ /** The bet's status */
725
+ __publicField(this, "status");
726
+ /** The bet's maximum size */
727
+ __publicField(this, "maximumSize");
728
+ /** The bet's price */
729
+ __publicField(this, "price");
730
+ /** The bet's players */
731
+ __publicField(this, "players");
732
+ __publicField(this, "teams");
733
+ /** The bet's channel */
734
+ __publicField(this, "channels");
735
+ /** The bet's messages */
736
+ __publicField(this, "messages");
737
+ /** The id of the winner */
738
+ __publicField(this, "winners");
739
+ /** The id of the loser */
740
+ __publicField(this, "losers");
741
+ /** The bet's creator id */
742
+ __publicField(this, "creatorId");
743
+ /** The bet's mediator */
744
+ __publicField(this, "mediatorId");
745
+ /** The bet's confirmers */
746
+ __publicField(this, "confirmed");
747
+ /** Creation Date */
748
+ __publicField(this, "createdAt");
749
+ /** Updated Date */
750
+ __publicField(this, "updatedAt");
751
+ /** Bet's id */
752
+ __publicField(this, "_id");
753
+ __publicField(this, "queues");
754
+ __publicField(this, "guild_id");
755
+ __publicField(this, "rest");
756
+ __publicField(this, "guild");
757
+ __publicField(this, "manager");
758
+ this.manager = manager;
759
+ this.guild = manager.guild;
760
+ this.rest = manager.rest;
761
+ this._id = data?._id;
762
+ this.guild_id = data?.guild_id;
763
+ this.type = data?.type;
764
+ this.mode = data?.mode;
765
+ this.status = data?.status;
766
+ this.maximumSize = data?.maximumSize;
767
+ this.price = data?.price;
768
+ this.teams = data?.teams;
769
+ this.channels = data?.channels;
770
+ this.players = new PlayerManager(this, Routes.guilds.bets.resource(this.guild_id, this._id, "players"));
771
+ this.messages = new MessagesManager(this, Routes.guilds.bets.resource(this.guild_id, this._id, "messages"));
772
+ this.winners = data?.winners;
773
+ this.losers = data?.losers;
774
+ this.creatorId = data?.creatorId;
775
+ this.mediatorId = data?.mediatorId;
776
+ this.confirmed = data?.confirmed;
777
+ this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
778
+ this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
779
+ this.queues = [];
780
+ for (let queue of data.queues ?? []) {
781
+ this.queues.push({
782
+ _id: queue?._id,
783
+ type: queue?.type,
784
+ players: queue?.players,
785
+ updatedAt: queue?.updatedAt ? new Date(queue?.updatedAt) : /* @__PURE__ */ new Date(),
786
+ createdAt: queue?.createdAt ? new Date(queue?.createdAt) : /* @__PURE__ */ new Date()
787
+ });
788
+ }
789
+ if (data?.messages?.length !== 0) this.messages.set(data.messages);
790
+ if (data?.players.length !== 0) this.players._set(data.players);
791
+ }
792
+ toString() {
793
+ return this._id;
794
+ }
795
+ async fetch() {
796
+ const route = Routes.guilds.bets.get(this.guild.id, this._id);
797
+ const response = await this.rest.request({ url: route, method: "GET" });
798
+ return this._updateInternals(response);
799
+ }
800
+ async addPlayer(player, queue_type) {
801
+ if (this.players.length === 2) return this;
802
+ if (this.players.has(player.id)) return this;
803
+ this.players.set(player.id, player);
804
+ if (queue_type) {
805
+ const queue = this.queues.find((q) => q.type === queue_type);
806
+ if (!queue) return this;
807
+ for (const q of this.queues) {
808
+ q.players = q.players.filter((p) => p.id !== player.id);
809
+ }
810
+ if (!queue.players.some((p) => p.id === player.id)) {
811
+ queue.players.push({ id: player.id });
812
+ }
813
+ }
814
+ return await this.update({
815
+ players: this.players.toArray(),
816
+ queues: this.queues
817
+ });
818
+ }
819
+ async removePlayer(player) {
820
+ if (!this.players.some((p) => p.id === player.id)) return this;
821
+ let players = this.players.toArray();
822
+ players = this.players.filter((p) => p.id !== player.id).toArray();
823
+ for (const q of this.queues) {
824
+ q.players = q.players.filter((p) => p.id !== player.id);
825
+ }
826
+ return await this.update({
827
+ players,
828
+ queues: this.queues
829
+ });
830
+ }
831
+ async update(data) {
832
+ const payload = data;
833
+ const route = Routes.guilds.bets.update(this.guild.id, this._id);
834
+ const response = await this.rest.request({ method: "patch", url: route, payload });
835
+ return this._updateInternals(response);
836
+ }
837
+ async delete() {
838
+ const route = Routes.guilds.bets.delete(this.manager.guild.id, this._id);
839
+ const response = await this.rest.request({
840
+ method: "DELETE",
841
+ url: route
842
+ });
843
+ this.rest.emit("betDelete", this);
844
+ this.manager.cache.delete(this._id);
845
+ return response;
846
+ }
847
+ _updateInternals(data) {
848
+ for (let key in data) {
849
+ if (key === "_id" || key === "createdAt") continue;
850
+ if (key === "messages") {
851
+ this.messages.set(data[key]);
852
+ continue;
853
+ }
854
+ if (key === "players") {
855
+ this.players._set(data[key]);
856
+ continue;
857
+ }
858
+ if (key in this) {
859
+ this[key] = data[key];
860
+ }
861
+ }
862
+ if (data?.messages?.length !== 0) {
863
+ if (this?.messages instanceof MessagesManager) this.messages.set(data.messages);
864
+ else {
865
+ this.messages = new MessagesManager(this, Routes.guilds.matches.resource(this.guild_id, this._id, "messages"));
866
+ this.messages.set(data.messages);
867
+ }
868
+ }
869
+ this.updatedAt = /* @__PURE__ */ new Date();
870
+ this.createdAt = new Date(data.createdAt);
871
+ this.manager.set(this);
872
+ return this;
873
+ }
874
+ toJSON() {
875
+ let json = {};
876
+ for (const [key, value] of Object.entries(this)) {
877
+ const exclude = ["rest", "guild", "manager"];
878
+ if (exclude.includes(key)) continue;
879
+ if (typeof value !== "function") {
880
+ json[key] = value;
881
+ }
882
+ }
883
+ return {
884
+ ...json,
885
+ messages: this?.messages instanceof MessagesManager ? this.messages?.cache?.toArray() : [],
886
+ players: this.players.toArray()
887
+ };
888
+ }
889
+ };
890
+
891
+ // src/managers/message/MessagesManager.ts
892
+ var MessagesManager = class {
893
+ constructor(structure, base_url) {
894
+ __publicField(this, "cache");
895
+ __publicField(this, "base_url");
896
+ __publicField(this, "rest");
897
+ __publicField(this, "guild");
898
+ this.rest = structure.rest;
899
+ this.guild = structure.guild;
900
+ this.cache = new Collection("messages");
901
+ this.base_url = base_url;
902
+ }
903
+ async fetch() {
904
+ const response = await this.rest.request({
905
+ method: "GET",
906
+ url: this.base_url,
907
+ payload: {}
908
+ });
909
+ this.cache.set(response._id, response);
910
+ return response;
911
+ }
912
+ async create(data) {
913
+ const messages = [...this.cache.toArray()];
914
+ if (Array.isArray(data)) messages.push(...data);
915
+ else messages.push(data);
916
+ const response = await this.rest.request({
917
+ method: "PATCH",
918
+ url: this.base_url,
919
+ payload: { set: messages }
920
+ });
921
+ return this.set(response.messages);
922
+ }
923
+ set(data) {
924
+ if (!data) return this.cache;
925
+ if (Array.isArray(data)) {
926
+ for (let message of data) {
927
+ if (message && !message._id) continue;
928
+ this.cache.set(message._id, message);
929
+ }
930
+ } else {
931
+ if (data && !data._id) return this.cache;
932
+ this.cache.set(data._id, data);
933
+ }
934
+ return this.cache;
935
+ }
936
+ };
937
+
938
+ // src/structures/match/GuildMatch.ts
939
+ var GuildMatch = class _GuildMatch {
940
+ /**
941
+ * GuildMatch match
942
+ * @param data The match's data
943
+ * @param guild The guild
944
+ * @param rest The rest client
945
+ */
946
+ constructor(data, manager) {
947
+ __publicField(this, "_id");
948
+ __publicField(this, "selections");
949
+ /** Match's type */
950
+ __publicField(this, "type");
951
+ __publicField(this, "channels");
952
+ __publicField(this, "guild_id");
953
+ /** Match's status */
954
+ __publicField(this, "status");
955
+ /** Match's challenge */
956
+ __publicField(this, "challenge");
957
+ /** Match's players */
958
+ __publicField(this, "players");
959
+ __publicField(this, "teams");
960
+ /** Match's winners */
961
+ __publicField(this, "winners");
962
+ /** Match's losers */
963
+ __publicField(this, "losers");
964
+ /** Match's maximum size */
965
+ __publicField(this, "maximumSize");
966
+ /** Match's kicked out */
967
+ __publicField(this, "kickedOut");
968
+ /** Match's confirmed */
969
+ __publicField(this, "confirmed");
970
+ /** Match's leaders */
971
+ __publicField(this, "leaders");
972
+ /** Match's creator id */
973
+ __publicField(this, "creatorId");
974
+ /** Match's room creator id */
975
+ __publicField(this, "roomCreatorId");
976
+ /** Creation Date */
977
+ __publicField(this, "createdAt");
978
+ /** Updated Date */
979
+ __publicField(this, "updatedAt");
980
+ __publicField(this, "messages");
981
+ /** Match's id */
982
+ __publicField(this, "mvps");
983
+ __publicField(this, "manager");
984
+ __publicField(this, "bet");
985
+ __publicField(this, "admin_id");
986
+ /** The given guild */
987
+ __publicField(this, "guild");
988
+ /** The rest client */
989
+ __publicField(this, "rest");
990
+ __publicField(this, "key");
991
+ this._id = data?._id;
992
+ this.guild_id = data?.guild_id;
993
+ this.manager = manager;
994
+ this.guild = manager.guild;
995
+ this.rest = manager.rest;
996
+ this.admin_id = data?.admin_id;
997
+ this.challenge = data?.challenge;
998
+ this.players = data?.players;
999
+ this.messages = new MessagesManager(this, Routes.guilds.matches.resource(this.guild_id, this._id, "messages"));
1000
+ this.channels = data?.channels;
1001
+ this.type = data?.type;
1002
+ this.status = data?.status;
1003
+ this.bet = this.guild.bets.cache.get(data?.bet?._id);
1004
+ this.mvps = data?.mvps;
1005
+ this.winners = data?.winners;
1006
+ this.losers = data?.losers;
1007
+ this.maximumSize = data?.maximumSize;
1008
+ this.kickedOut = data?.kickedOut;
1009
+ this.confirmed = data?.confirmed;
1010
+ this.teams = data?.teams;
1011
+ this.leaders = data?.leaders;
1012
+ this.creatorId = data?.creatorId;
1013
+ this.roomCreatorId = data?.roomCreatorId;
1014
+ this.selections = data?.selections;
1015
+ this.key = "matches";
1016
+ this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
1017
+ this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
1018
+ if (data?.messages?.length !== 0) this.messages.set(data.messages);
1019
+ }
1020
+ /**
1021
+ * Fetches the match
1022
+ * @returns New Instance of the match
1023
+ */
1024
+ async fetch() {
1025
+ const route = Routes.guilds.matches.get(this.guild.id, this._id);
1026
+ const response = await this.rest.request({
1027
+ method: "get",
1028
+ url: route
1029
+ });
1030
+ return await this._updateInternals(response);
1031
+ }
1032
+ async addConfirmed(type, id) {
1033
+ const confirmed = this.confirmed.find((c) => c.type === type);
1034
+ const idsToAdd = Array.isArray(id) ? id : [id];
1035
+ if (!confirmed) {
1036
+ this.confirmed.push({ type, ids: [...idsToAdd], count: idsToAdd.length });
1037
+ } else {
1038
+ const chIndex = this.confirmed.findIndex((ch) => ch.type === type);
1039
+ const mergedIds = [.../* @__PURE__ */ new Set([...confirmed.ids || [], ...idsToAdd])];
1040
+ this.confirmed[chIndex] = { ...confirmed, ids: mergedIds, count: mergedIds.length };
1041
+ }
1042
+ return this.update({ confirmed: this.confirmed });
1043
+ }
1044
+ async setConfirmed(set) {
1045
+ Assertion.assertObject(set);
1046
+ const route = Routes.guilds.matches.resource(this.guild.id, this._id, "confirmed");
1047
+ const response = await this.rest.request({
1048
+ method: "PATCH",
1049
+ url: route,
1050
+ payload: set
1051
+ });
1052
+ return await this._updateInternals(response);
1053
+ }
1054
+ async setStatus(status) {
1055
+ Assertion.assertString(status);
1056
+ const payload = { set: status.toLowerCase() };
1057
+ const route = Routes.guilds.matches.resource(this.guild.id, this._id, "status");
1058
+ const response = await this.rest.request({
1059
+ method: "PATCH",
1060
+ url: route,
1061
+ payload
1062
+ });
1063
+ return await this._updateInternals(response);
1064
+ }
1065
+ async setWinners(players) {
1066
+ if (!Array.isArray(players)) players = [players];
1067
+ const payload = { set: players };
1068
+ const route = Routes.guilds.matches.resource(this.guild.id, this._id, "winners");
1069
+ const response = await this.rest.request({
1070
+ method: "PATCH",
1071
+ url: route,
1072
+ payload
1073
+ });
1074
+ return await this._updateInternals(response);
1075
+ }
1076
+ async setLoser(players) {
1077
+ if (!Array.isArray(players)) players = [players];
1078
+ const payload = { set: players };
1079
+ const route = Routes.guilds.matches.resource(this.guild.id, this._id, "losers");
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 setMvps(...usersId) {
1088
+ const payload = { set: usersId };
1089
+ const route = Routes.guilds.matches.resource(this.guild.id, this._id, "mvps");
1090
+ const response = await this.rest.request({
1091
+ method: "PATCH",
1092
+ url: route,
1093
+ payload
1094
+ });
1095
+ return await this._updateInternals(response);
1096
+ }
1097
+ async setRoomCreatorId(userId) {
1098
+ Assertion.assertString(userId);
1099
+ const payload = { set: userId };
1100
+ const route = Routes.guilds.matches.resource(this.guild.id, this._id, "roomCreatorId");
1101
+ const response = await this.rest.request({
1102
+ method: "PATCH",
1103
+ url: route,
1104
+ payload
1105
+ });
1106
+ return await this._updateInternals(response);
1107
+ }
1108
+ async setRoomAdminId(userId) {
1109
+ Assertion.assertString(userId);
1110
+ const payload = { set: userId };
1111
+ const route = Routes.guilds.matches.resource(this.guild.id, this._id, "admin_id");
1112
+ const response = await this.rest.request({
1113
+ method: "PATCH",
1114
+ url: route,
1115
+ payload
1116
+ });
1117
+ return await this._updateInternals(response);
1118
+ }
1119
+ async kick(player) {
1120
+ this.players = this.players.filter((p) => p.id !== player.id);
1121
+ this.leaders = this.leaders.filter((p) => p.id !== player.id);
1122
+ const teamIndex = this.teams.findIndex((t) => t.some((p) => p.id === player.id));
1123
+ if (teamIndex !== -1) {
1124
+ let team = this.teams.find((t) => t.some((p) => p.id === player.id));
1125
+ team = team.filter((p) => p.id === player.id);
1126
+ this.teams[teamIndex] = team;
1127
+ }
1128
+ return await this.update(this.toJSON());
1129
+ }
1130
+ async update(data) {
1131
+ const route = Routes.guilds.matches.get(this.guild.id, this._id);
1132
+ if (data?.bet && data?.bet instanceof GuildBet) {
1133
+ data.bet = data.bet.toJSON();
1134
+ }
1135
+ const response = await this.rest.request({
1136
+ method: "patch",
1137
+ url: route,
1138
+ payload: data
1139
+ });
1140
+ this.rest.emit("matchUpdate", this, new _GuildMatch(response, this.manager));
1141
+ return await this._updateInternals(response);
1142
+ }
1143
+ async delete() {
1144
+ const route = Routes.guilds.matches.resource(this.guild.id, this._id);
1145
+ const response = await this.rest.request({
1146
+ method: "DELETE",
1147
+ url: route
1148
+ });
1149
+ this.manager.cache.delete(this?._id);
1150
+ this.rest.matches.delete(this?._id);
1151
+ return response;
1152
+ }
1153
+ toJSON() {
1154
+ let json = {};
1155
+ for (const [key, value] of Object.entries(this)) {
1156
+ const exclude = ["rest", "guilds", "guild", "manager"];
1157
+ if (exclude.includes(key)) continue;
1158
+ if (typeof value !== "function") {
1159
+ json[key] = value;
1160
+ }
1161
+ }
1162
+ return {
1163
+ ...json,
1164
+ messages: this?.messages instanceof MessagesManager ? this.messages?.cache?.toArray() : []
1165
+ };
1166
+ }
1167
+ async _updateInternals(data) {
1168
+ if (!data) return;
1169
+ for (let key in data) {
1170
+ if (key === "id" || key === "createdAt" || key === "messages") continue;
1171
+ if (key in this) {
1172
+ this[key] = data[key];
1173
+ }
1174
+ if (key === "bet") {
1175
+ this.bet = this.guild.bets.set(data.bet);
1176
+ }
1177
+ }
1178
+ if (data?.messages?.length !== 0) {
1179
+ if (this?.messages instanceof MessagesManager) this.messages.set(data.messages);
1180
+ else {
1181
+ this.messages = new MessagesManager(this, Routes.guilds.matches.resource(this.guild_id, this._id, "messages"));
1182
+ this.messages.set(data.messages);
1183
+ }
1184
+ }
1185
+ if (!(this.bet instanceof GuildBet) && data?.bet) {
1186
+ this.bet = this.guild.bets.cache.get(data._id) ?? await this.guild.bets.fetch({ betId: data?.bet?._id });
1187
+ }
1188
+ this.updatedAt = /* @__PURE__ */ new Date();
1189
+ this.manager.set(this);
1190
+ return this;
1191
+ }
1192
+ };
1193
+
1194
+ // src/managers/match/GuildMatchManager.ts
1195
+ var GuildMatchManager = class extends BaseManager {
1196
+ /**
1197
+ * Manage users with the given client
1198
+ * @param users An array of users
1199
+ * @param rest The rest client
1200
+ */
1201
+ constructor(guild) {
1202
+ super(guild);
1203
+ this.guild = guild;
1204
+ this.rest = guild.rest;
1205
+ this.base_url = Routes.guilds.matches.getAll(guild.id);
1206
+ this.cache = new Collection("matches");
1207
+ }
1208
+ /**
1209
+ * Fetch a match
1210
+ * @param id Id of the match to fetch
1211
+ * @returns APIBetUser
1212
+ */
1213
+ async fetch(options) {
1214
+ if (options && options.cache) return this.cache;
1215
+ if (options && options.matchId) {
1216
+ const route2 = Routes.guilds.matches.get(this.guild.id, options.matchId);
1217
+ const response2 = await this.rest.request({
1218
+ method: "get",
1219
+ url: route2
1220
+ });
1221
+ return this.set(response2);
1222
+ }
1223
+ const route = Routes.guilds.matches.getAll(this.guild.id);
1224
+ const response = await this.rest.request({
1225
+ method: "get",
1226
+ url: route
1227
+ });
1228
+ if (!response) return this.cache;
1229
+ const coll = new Collection("matches");
1230
+ for (let match of response ?? []) {
1231
+ const guildMatch = new GuildMatch(match, this);
1232
+ coll.set(match._id, guildMatch);
1233
+ this.rest.matches.set(match._id, guildMatch);
1234
+ }
1235
+ this.cache = coll;
1236
+ return coll;
1237
+ }
1238
+ async fetchAll() {
1239
+ const route = Routes.guilds.matches.getAll(this.guild.id);
1240
+ const response = await this.rest.request({
1241
+ method: "get",
1242
+ url: route
1243
+ });
1244
+ if (Array.isArray(response) && response.length === 0) {
1245
+ this.cache.clear();
1246
+ return this.cache;
1247
+ }
1248
+ this.set(response);
1249
+ return this.cache;
1250
+ }
1251
+ set(data) {
1252
+ if (!data) return this.cache;
1253
+ if (Array.isArray(data)) {
1254
+ for (let _match of data) {
1255
+ if (!_match._id) continue;
1256
+ const match = new GuildMatch(_match, this);
1257
+ this.cache.set(match._id, match);
1258
+ }
1259
+ return this.cache;
1260
+ } else {
1261
+ if (!data._id) return this.cache;
1262
+ if (data instanceof GuildMatch) {
1263
+ this.cache.set(data._id, data);
1264
+ return data;
1265
+ }
1266
+ const match = new GuildMatch(data, this);
1267
+ this.cache.set(match._id, match);
1268
+ return match;
1269
+ }
1270
+ }
1271
+ async create(payload) {
1272
+ Assertion.assertObject(payload);
1273
+ const route = Routes.guilds.matches.create(this.guild.id);
1274
+ const response = await this.rest.request({
1275
+ method: "POST",
1276
+ url: route,
1277
+ payload
1278
+ });
1279
+ return this.set(response);
1280
+ }
1281
+ async delete(id) {
1282
+ const route = Routes.fields(this.base_url, id);
1283
+ const response = await this.rest.request({ url: route, method: "DELETE" });
1284
+ return this.set(response);
1285
+ }
1286
+ };
1287
+ export {
1288
+ GuildMatchManager
1289
+ };