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