@duque.edits/sdk 1.0.87 → 1.1.0

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