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