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