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