@duque.edits/sdk 1.0.87 → 1.1.0

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