@duque.edits/sdk 1.1.3 → 1.3.1

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 (277) hide show
  1. package/README.md +1 -1
  2. package/dist/{index-BPxglVSk.d.ts → index-xkfp9hFj.d.ts} +442 -193
  3. package/dist/index.d.ts +2 -1
  4. package/dist/index.js +9 -4225
  5. package/dist/managers/automaticmessage/AutomaticMessageManager.d.ts +2 -1
  6. package/dist/managers/automaticmessage/AutomaticMessageManager.js +41 -739
  7. package/dist/managers/base.d.ts +2 -1
  8. package/dist/managers/base.js +7 -89
  9. package/dist/managers/bet/GuildBetManager.d.ts +2 -1
  10. package/dist/managers/bet/GuildBetManager.js +20 -901
  11. package/dist/managers/betuser/GuildBetUserManager.d.ts +2 -1
  12. package/dist/managers/betuser/GuildBetUserManager.js +21 -444
  13. package/dist/managers/buffer/BufferManager.d.ts +2 -1
  14. package/dist/managers/buffer/BufferManager.js +7 -192
  15. package/dist/managers/guild/GuildManager.d.ts +2 -1
  16. package/dist/managers/guild/GuildManager.js +37 -3704
  17. package/dist/managers/index.d.ts +2 -1
  18. package/dist/managers/index.js +39 -3937
  19. package/dist/managers/logs/LogManager.d.ts +2 -1
  20. package/dist/managers/logs/LogManager.js +15 -673
  21. package/dist/managers/match/GuildMatchManager.d.ts +2 -1
  22. package/dist/managers/match/GuildMatchManager.js +25 -1225
  23. package/dist/managers/mediator/GuildMediatorManager.d.ts +2 -1
  24. package/dist/managers/mediator/GuildMediatorManager.js +22 -365
  25. package/dist/managers/message/MessagesManager.d.ts +2 -1
  26. package/dist/managers/message/MessagesManager.js +4 -88
  27. package/dist/managers/minesgame/MinesGameManager.d.ts +2 -1
  28. package/dist/managers/minesgame/MinesGameManager.js +15 -655
  29. package/dist/managers/permission/GuildPermissionManager.d.ts +2 -1
  30. package/dist/managers/permission/GuildPermissionManager.js +21 -212
  31. package/dist/managers/player/PlayerManager.d.ts +2 -1
  32. package/dist/managers/player/PlayerManager.js +3 -87
  33. package/dist/managers/product/ProductManager.d.ts +22 -0
  34. package/dist/managers/product/ProductManager.js +100 -0
  35. package/dist/managers/shop/ShopManager.d.ts +22 -0
  36. package/dist/managers/shop/ShopManager.js +98 -0
  37. package/dist/managers/ticket/TicketManager.d.ts +2 -1
  38. package/dist/managers/ticket/TicketManager.js +24 -707
  39. package/dist/managers/ticketpanel/TicketPanelManager.d.ts +22 -0
  40. package/dist/managers/ticketpanel/TicketPanelManager.js +81 -0
  41. package/dist/managers/tournament/TournamentManager.d.ts +2 -1
  42. package/dist/managers/tournament/TournamentManager.js +32 -686
  43. package/dist/managers/user/GuildUserManager.d.ts +2 -1
  44. package/dist/managers/user/GuildUserManager.js +27 -506
  45. package/dist/managers/vipmember/VipMemberManager.d.ts +2 -1
  46. package/dist/managers/vipmember/VipMemberManager.js +29 -425
  47. package/dist/rest/APIEndpoints.js +3 -5
  48. package/dist/rest/REST.d.ts +2 -1
  49. package/dist/rest/REST.js +56 -3932
  50. package/dist/rest/Routes.d.ts +79 -87
  51. package/dist/rest/Routes.js +8 -18
  52. package/dist/rest/index.d.ts +2 -1
  53. package/dist/rest/index.js +7 -4027
  54. package/dist/structures/Collection.js +5 -7
  55. package/dist/structures/automaticmessage/AutomaticMessage.d.ts +3 -2
  56. package/dist/structures/automaticmessage/AutomaticMessage.js +50 -531
  57. package/dist/structures/bet/GuildBet.d.ts +2 -1
  58. package/dist/structures/bet/GuildBet.js +20 -696
  59. package/dist/structures/betuser/GuildBetUser.d.ts +2 -1
  60. package/dist/structures/betuser/GuildBetUser.js +31 -130
  61. package/dist/structures/guild/Guild.d.ts +5 -4
  62. package/dist/structures/guild/Guild.js +196 -3322
  63. package/dist/structures/index.d.ts +2 -1
  64. package/dist/structures/index.js +33 -3772
  65. package/dist/structures/logentry/LogEntry.d.ts +2 -1
  66. package/dist/structures/logentry/LogEntry.js +23 -497
  67. package/dist/structures/match/GuildMatch.d.ts +2 -1
  68. package/dist/structures/match/GuildMatch.js +55 -950
  69. package/dist/structures/mediator/GuildMediator.d.ts +2 -1
  70. package/dist/structures/mediator/GuildMediator.js +18 -123
  71. package/dist/structures/minesgame/MinesGame.d.ts +2 -1
  72. package/dist/structures/minesgame/MinesGame.js +14 -496
  73. package/dist/structures/product/Product.d.ts +22 -0
  74. package/dist/structures/product/Product.js +123 -0
  75. package/dist/structures/shop/Shop.d.ts +22 -0
  76. package/dist/structures/shop/Shop.js +124 -0
  77. package/dist/structures/ticket/Ticket.d.ts +3 -2
  78. package/dist/structures/ticket/Ticket.js +38 -517
  79. package/dist/structures/ticketpanel/TicketPanel.d.ts +22 -0
  80. package/dist/structures/ticketpanel/TicketPanel.js +175 -0
  81. package/dist/structures/tournament/Tournament.d.ts +2 -1
  82. package/dist/structures/tournament/Tournament.js +13 -493
  83. package/dist/structures/user/GuildUser.d.ts +2 -1
  84. package/dist/structures/user/GuildUser.js +253 -147
  85. package/dist/structures/vipmember/VipMember.d.ts +2 -1
  86. package/dist/structures/vipmember/VipMember.js +11 -116
  87. package/dist/types/RestTypes.d.ts +2 -1
  88. package/dist/types/RestTypes.js +0 -2
  89. package/dist/types/api/APIAdvert.js +0 -2
  90. package/dist/types/api/APIAutomaticMessage.d.ts +2 -1
  91. package/dist/types/api/APIAutomaticMessage.js +0 -2
  92. package/dist/types/api/APIBaseChannel.js +0 -2
  93. package/dist/types/api/APIBetChannel.js +0 -2
  94. package/dist/types/api/APICode.js +0 -2
  95. package/dist/types/api/APIGiveaway.js +0 -2
  96. package/dist/types/api/APIGuild.d.ts +5 -4
  97. package/dist/types/api/APIGuild.js +1 -2
  98. package/dist/types/api/APIGuildAdvert.js +0 -2
  99. package/dist/types/api/APIGuildBet.d.ts +2 -1
  100. package/dist/types/api/APIGuildBet.js +0 -2
  101. package/dist/types/api/APIGuildBetUser.d.ts +2 -1
  102. package/dist/types/api/APIGuildBetUser.js +0 -2
  103. package/dist/types/api/APIGuildChannel.js +0 -2
  104. package/dist/types/api/APIGuildGroupedChannel.d.ts +2 -1
  105. package/dist/types/api/APIGuildGroupedChannel.js +0 -2
  106. package/dist/types/api/APIGuildMatch.d.ts +2 -1
  107. package/dist/types/api/APIGuildMatch.js +0 -2
  108. package/dist/types/api/APIGuildMediator.js +0 -2
  109. package/dist/types/api/APIGuildPermissions.d.ts +18 -2
  110. package/dist/types/api/APIGuildPermissions.js +17 -3
  111. package/dist/types/api/APIGuildShop.d.ts +6 -1
  112. package/dist/types/api/APIGuildShop.js +0 -2
  113. package/dist/types/api/APIGuildTicket.js +0 -2
  114. package/dist/types/api/APIGuildUser.d.ts +2 -1
  115. package/dist/types/api/APIGuildUser.js +0 -2
  116. package/dist/types/api/APILogEntry.d.ts +4 -2
  117. package/dist/types/api/APILogEntry.js +3 -3
  118. package/dist/types/api/APIMessage.d.ts +2 -0
  119. package/dist/types/api/APIMessage.js +0 -2
  120. package/dist/types/api/APIMinesGame.js +0 -2
  121. package/dist/types/api/APIPlayer.js +0 -2
  122. package/dist/types/api/APIProduct.d.ts +2 -1
  123. package/dist/types/api/APIProduct.js +1 -2
  124. package/dist/types/api/APITicketPanel.d.ts +22 -0
  125. package/dist/types/api/APITicketPanel.js +16 -0
  126. package/dist/types/api/APITournament.d.ts +6 -1
  127. package/dist/types/api/APITournament.js +0 -2
  128. package/dist/types/api/APIVipMember.js +0 -2
  129. package/dist/types/api/index.d.ts +2 -1
  130. package/dist/types/api/index.js +61 -110
  131. package/dist/types/index.d.ts +2 -1
  132. package/dist/types/index.js +5 -154
  133. package/dist/utils/Assertion.js +2 -4
  134. package/dist/utils/clamp0.d.ts +3 -0
  135. package/dist/utils/clamp0.js +31 -0
  136. package/dist/utils/getRandomNumber.js +0 -2
  137. package/dist/utils/isSameDayUTC.d.ts +3 -0
  138. package/dist/utils/isSameDayUTC.js +33 -0
  139. package/dist/utils/randomKeyGenerator.js +0 -2
  140. package/package.json +4 -5
  141. package/dist/index-DjHimKUy.d.mts +0 -1431
  142. package/dist/index.d.mts +0 -23
  143. package/dist/index.mjs +0 -4196
  144. package/dist/managers/automaticmessage/AutomaticMessageManager.d.mts +0 -21
  145. package/dist/managers/automaticmessage/AutomaticMessageManager.mjs +0 -796
  146. package/dist/managers/base.d.mts +0 -21
  147. package/dist/managers/base.mjs +0 -107
  148. package/dist/managers/bet/GuildBetManager.d.mts +0 -21
  149. package/dist/managers/bet/GuildBetManager.mjs +0 -958
  150. package/dist/managers/betuser/GuildBetUserManager.d.mts +0 -21
  151. package/dist/managers/betuser/GuildBetUserManager.mjs +0 -502
  152. package/dist/managers/buffer/BufferManager.d.mts +0 -21
  153. package/dist/managers/buffer/BufferManager.mjs +0 -223
  154. package/dist/managers/guild/GuildManager.d.mts +0 -21
  155. package/dist/managers/guild/GuildManager.mjs +0 -3786
  156. package/dist/managers/index.d.mts +0 -21
  157. package/dist/managers/index.mjs +0 -3934
  158. package/dist/managers/logs/LogManager.d.mts +0 -21
  159. package/dist/managers/logs/LogManager.mjs +0 -738
  160. package/dist/managers/match/GuildMatchManager.d.mts +0 -21
  161. package/dist/managers/match/GuildMatchManager.mjs +0 -1305
  162. package/dist/managers/mediator/GuildMediatorManager.d.mts +0 -21
  163. package/dist/managers/mediator/GuildMediatorManager.mjs +0 -430
  164. package/dist/managers/message/MessagesManager.d.mts +0 -21
  165. package/dist/managers/message/MessagesManager.mjs +0 -134
  166. package/dist/managers/minesgame/MinesGameManager.d.mts +0 -21
  167. package/dist/managers/minesgame/MinesGameManager.mjs +0 -721
  168. package/dist/managers/permission/GuildPermissionManager.d.mts +0 -21
  169. package/dist/managers/permission/GuildPermissionManager.mjs +0 -256
  170. package/dist/managers/player/PlayerManager.d.mts +0 -21
  171. package/dist/managers/player/PlayerManager.mjs +0 -155
  172. package/dist/managers/ticket/TicketManager.d.mts +0 -21
  173. package/dist/managers/ticket/TicketManager.mjs +0 -827
  174. package/dist/managers/tournament/TournamentManager.d.mts +0 -21
  175. package/dist/managers/tournament/TournamentManager.mjs +0 -745
  176. package/dist/managers/user/GuildUserManager.d.mts +0 -21
  177. package/dist/managers/user/GuildUserManager.mjs +0 -567
  178. package/dist/managers/vipmember/VipMemberManager.d.mts +0 -21
  179. package/dist/managers/vipmember/VipMemberManager.mjs +0 -513
  180. package/dist/rest/APIEndpoints.d.mts +0 -12
  181. package/dist/rest/APIEndpoints.mjs +0 -19
  182. package/dist/rest/REST.d.mts +0 -21
  183. package/dist/rest/REST.mjs +0 -4021
  184. package/dist/rest/Routes.d.mts +0 -104
  185. package/dist/rest/Routes.mjs +0 -104
  186. package/dist/rest/index.d.mts +0 -23
  187. package/dist/rest/index.mjs +0 -4036
  188. package/dist/structures/Collection.d.mts +0 -19
  189. package/dist/structures/Collection.mjs +0 -87
  190. package/dist/structures/automaticmessage/AutomaticMessage.d.mts +0 -21
  191. package/dist/structures/automaticmessage/AutomaticMessage.mjs +0 -609
  192. package/dist/structures/bet/GuildBet.d.mts +0 -21
  193. package/dist/structures/bet/GuildBet.mjs +0 -881
  194. package/dist/structures/betuser/GuildBetUser.d.mts +0 -21
  195. package/dist/structures/betuser/GuildBetUser.mjs +0 -326
  196. package/dist/structures/guild/Guild.d.mts +0 -21
  197. package/dist/structures/guild/Guild.mjs +0 -3690
  198. package/dist/structures/index.d.mts +0 -21
  199. package/dist/structures/index.mjs +0 -3773
  200. package/dist/structures/logentry/LogEntry.d.mts +0 -21
  201. package/dist/structures/logentry/LogEntry.mjs +0 -575
  202. package/dist/structures/match/GuildMatch.d.mts +0 -21
  203. package/dist/structures/match/GuildMatch.mjs +0 -1191
  204. package/dist/structures/mediator/GuildMediator.d.mts +0 -21
  205. package/dist/structures/mediator/GuildMediator.mjs +0 -246
  206. package/dist/structures/minesgame/MinesGame.d.mts +0 -21
  207. package/dist/structures/minesgame/MinesGame.mjs +0 -579
  208. package/dist/structures/ticket/Ticket.d.mts +0 -21
  209. package/dist/structures/ticket/Ticket.mjs +0 -626
  210. package/dist/structures/tournament/Tournament.d.mts +0 -21
  211. package/dist/structures/tournament/Tournament.mjs +0 -585
  212. package/dist/structures/user/GuildUser.d.mts +0 -21
  213. package/dist/structures/user/GuildUser.mjs +0 -382
  214. package/dist/structures/vipmember/VipMember.d.mts +0 -21
  215. package/dist/structures/vipmember/VipMember.mjs +0 -250
  216. package/dist/types/RestTypes.d.mts +0 -21
  217. package/dist/types/RestTypes.mjs +0 -0
  218. package/dist/types/api/APIAdvert.d.mts +0 -13
  219. package/dist/types/api/APIAdvert.mjs +0 -0
  220. package/dist/types/api/APIAutomaticMessage.d.mts +0 -21
  221. package/dist/types/api/APIAutomaticMessage.mjs +0 -0
  222. package/dist/types/api/APIBaseChannel.d.mts +0 -12
  223. package/dist/types/api/APIBaseChannel.mjs +0 -0
  224. package/dist/types/api/APIBetChannel.d.mts +0 -12
  225. package/dist/types/api/APIBetChannel.mjs +0 -0
  226. package/dist/types/api/APICode.d.mts +0 -12
  227. package/dist/types/api/APICode.mjs +0 -0
  228. package/dist/types/api/APIGiveaway.d.mts +0 -29
  229. package/dist/types/api/APIGiveaway.mjs +0 -0
  230. package/dist/types/api/APIGuild.d.mts +0 -21
  231. package/dist/types/api/APIGuild.mjs +0 -46
  232. package/dist/types/api/APIGuildAdvert.d.mts +0 -10
  233. package/dist/types/api/APIGuildAdvert.mjs +0 -0
  234. package/dist/types/api/APIGuildBet.d.mts +0 -21
  235. package/dist/types/api/APIGuildBet.mjs +0 -8
  236. package/dist/types/api/APIGuildBetUser.d.mts +0 -21
  237. package/dist/types/api/APIGuildBetUser.mjs +0 -0
  238. package/dist/types/api/APIGuildChannel.d.mts +0 -12
  239. package/dist/types/api/APIGuildChannel.mjs +0 -0
  240. package/dist/types/api/APIGuildGroupedChannel.d.mts +0 -21
  241. package/dist/types/api/APIGuildGroupedChannel.mjs +0 -0
  242. package/dist/types/api/APIGuildMatch.d.mts +0 -21
  243. package/dist/types/api/APIGuildMatch.mjs +0 -14
  244. package/dist/types/api/APIGuildMediator.d.mts +0 -16
  245. package/dist/types/api/APIGuildMediator.mjs +0 -0
  246. package/dist/types/api/APIGuildPermissions.d.mts +0 -15
  247. package/dist/types/api/APIGuildPermissions.mjs +0 -13
  248. package/dist/types/api/APIGuildShop.d.mts +0 -15
  249. package/dist/types/api/APIGuildShop.mjs +0 -0
  250. package/dist/types/api/APIGuildTicket.d.mts +0 -19
  251. package/dist/types/api/APIGuildTicket.mjs +0 -0
  252. package/dist/types/api/APIGuildUser.d.mts +0 -21
  253. package/dist/types/api/APIGuildUser.mjs +0 -0
  254. package/dist/types/api/APILogEntry.d.mts +0 -32
  255. package/dist/types/api/APILogEntry.mjs +0 -20
  256. package/dist/types/api/APIMessage.d.mts +0 -13
  257. package/dist/types/api/APIMessage.mjs +0 -0
  258. package/dist/types/api/APIMinesGame.d.mts +0 -15
  259. package/dist/types/api/APIMinesGame.mjs +0 -0
  260. package/dist/types/api/APIPlayer.d.mts +0 -10
  261. package/dist/types/api/APIPlayer.mjs +0 -0
  262. package/dist/types/api/APIProduct.d.mts +0 -22
  263. package/dist/types/api/APIProduct.mjs +0 -0
  264. package/dist/types/api/APITournament.d.mts +0 -16
  265. package/dist/types/api/APITournament.mjs +0 -0
  266. package/dist/types/api/APIVipMember.d.mts +0 -22
  267. package/dist/types/api/APIVipMember.mjs +0 -0
  268. package/dist/types/api/index.d.mts +0 -21
  269. package/dist/types/api/index.mjs +0 -135
  270. package/dist/types/index.d.mts +0 -21
  271. package/dist/types/index.mjs +0 -135
  272. package/dist/utils/Assertion.d.mts +0 -34
  273. package/dist/utils/Assertion.mjs +0 -52
  274. package/dist/utils/getRandomNumber.d.mts +0 -3
  275. package/dist/utils/getRandomNumber.mjs +0 -7
  276. package/dist/utils/randomKeyGenerator.d.mts +0 -3
  277. package/dist/utils/randomKeyGenerator.mjs +0 -8
@@ -1,1191 +0,0 @@
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/rest/Routes.ts
401
- var Routes = {
402
- //base: "http://localhost:80/api/v1",
403
- base: "https://duqueapi.shardweb.app/api/v1",
404
- field: (field) => `/${field}`,
405
- fields: (...fields) => `${fields.join("/")}`,
406
- guilds: {
407
- create: () => `/guilds`,
408
- get: (guildId) => `/guilds/${guildId}`,
409
- getAll: () => `/guilds`,
410
- delete: (guildId) => `/guilds/${guildId}`,
411
- deleteAll: () => `/guilds`,
412
- resource: (guildId, ...resources) => `/guilds/${guildId}/manage/${resources.join("/")}`,
413
- resources: (guildId, ...resources) => `/guilds/${guildId}/manage/${resources.join("/")}`,
414
- users: {
415
- create: (guildId) => `/guilds/${guildId}/users`,
416
- update: (guildId, userId) => `/guilds/${guildId}/users/${userId}`,
417
- getAll: (guildId) => `/guilds/${guildId}/users`,
418
- get: (guildId, userId) => `/guilds/${guildId}/users/${userId}`,
419
- delete: (guildId, userId) => `/guilds/${guildId}/users/${userId}`,
420
- deleteAll: (guildId) => `/guilds/${guildId}/users`,
421
- resource: (guildId, userId, ...resource) => `/guilds/${guildId}/users/${userId}/${resource.join("/")}`
422
- },
423
- betusers: {
424
- getAll: (guildId) => `/guilds/${guildId}/betusers`,
425
- get: (guildId, userId) => `/guilds/${guildId}/betusers/${userId}`,
426
- create: (guildId) => `/guilds/${guildId}/betusers`,
427
- update: (guildId, userId) => `/guilds/${guildId}/betusers/${userId}`,
428
- delete: (guildId, userId) => `/guilds/${guildId}/betusers/${userId}`,
429
- deleteAll: (guildId) => `/guilds/${guildId}/betusers`,
430
- resource: (guildId, userId, resourceName) => `/guilds/${guildId}/betusers/${userId}/${resourceName}`
431
- },
432
- matches: {
433
- getAll: (guildId) => `/guilds/${guildId}/matches`,
434
- get: (guildId, matchId) => `/guilds/${guildId}/matches/${matchId}`,
435
- create: (guildId) => `/guilds/${guildId}/matches`,
436
- update: (guildId, matchId) => `/guilds/${guildId}/matches/${matchId}`,
437
- delete: (guildId, matchId) => `/guilds/${guildId}/matches/${matchId}`,
438
- deleteAll: (guildId) => `/guilds/${guildId}/matches`,
439
- resource: (guildId, matchId, ...resources) => `/guilds/${guildId}/matches/${matchId}/${resources.join("/")}`
440
- },
441
- bets: {
442
- getAll: (guildId) => `/guilds/${guildId}/bets`,
443
- get: (guildId, betId) => `/guilds/${guildId}/bets/${betId}`,
444
- create: (guildId) => `/guilds/${guildId}/bets`,
445
- update: (guildId, betId) => `/guilds/${guildId}/bets/${betId}`,
446
- delete: (guildId, betId) => `/guilds/${guildId}/bets/${betId}`,
447
- deleteAll: (guildId) => `/guilds/${guildId}/bets`,
448
- resource: (guildId, betId, ...resources) => `/guilds/${guildId}/bets/${betId}/${resources.join("/")}`
449
- },
450
- tickets: {
451
- getAll: (guildId) => `/guilds/${guildId}/tickets`,
452
- get: (guildId, ticketId) => `/guilds/${guildId}/tickets/${ticketId}`,
453
- create: (guildId) => `/guilds/${guildId}/tickets`,
454
- update: (guildId, ticketId) => `/guilds/${guildId}/tickets/${ticketId}`,
455
- delete: (guildId, ticketId) => `/guilds/${guildId}/tickets/${ticketId}`,
456
- deleteAll: (guildId) => `/guilds/${guildId}/tickets`,
457
- resource: (guildId, ticketId, ...resources) => `/guilds/${guildId}/tickets/${ticketId}/${resources.join("/")}`
458
- },
459
- mediators: {
460
- getAll: (guildId) => `/guilds/${guildId}/mediators`,
461
- get: (guildId, mediatorId) => `/guilds/${guildId}/mediators/${mediatorId}`,
462
- create: (guildId) => `/guilds/${guildId}/mediators`,
463
- update: (guildId, mediatorId) => `/guilds/${guildId}/mediators/${mediatorId}`,
464
- delete: (guildId, mediatorId) => `/guilds/${guildId}/mediators/${mediatorId}`,
465
- deleteAll: (guildId) => `/guilds/${guildId}/mediators`,
466
- resource: (guildId, mediatorId, ...resources) => `/guilds/${guildId}/mediators/${mediatorId}/${resources.join("/")}`
467
- },
468
- shop: {
469
- get: (guildId) => `/guilds/${guildId}/manage/shop`,
470
- update: (guildId) => `/guilds/${guildId}/manage/shop`,
471
- delete: (guildId) => `/guilds/${guildId}/manage/shop/ `,
472
- resource: (guildId, ...resources) => `/guilds/${guildId}/manage/shop/${resources.join("/")}`,
473
- products: {
474
- getAll: (guildId) => `/guilds/${guildId}/manage/shop/products`,
475
- get: (guildId, productId) => `/guilds/${guildId}/manage/shop/${productId}/products`,
476
- create: (guildId) => `/guilds/${guildId}/manage/shop/products`,
477
- update: (guildId, productId) => `/guilds/${guildId}/manage/shop/products/${productId}`,
478
- delete: (guildId, productId) => `/guilds/${guildId}/manage/shop/products/${productId}`,
479
- deleteAll: (guildId) => `/guilds/${guildId}/products/shop`,
480
- resource: (guildId, productId, ...resources) => `/guilds/${guildId}/manage/shop/products/${productId}/${resources.join("/")}`
481
- }
482
- }
483
- },
484
- vipmembers: {
485
- get: (guildId, memberId) => `/guilds/${guildId}/vipmembers/${memberId}`,
486
- getAll: (guildId) => `/guilds/${guildId}/vipmembers`,
487
- deleteAll: (guildId) => `/guilds/${guildId}/vipmembers`,
488
- create: (guildId) => `/guilds/${guildId}/vipmembers`,
489
- update: (guildId, memberId) => `/guilds/${guildId}/vipmembers/${memberId}`,
490
- delete: (guildId, memberId) => `/guilds/${guildId}/vipmembers/${memberId}`
491
- },
492
- giveaways: {
493
- get: (giveawayId) => `/giveaways/${giveawayId}`,
494
- getAll: () => `/giveaways`,
495
- deleteAll: () => `/giveaways`,
496
- create: () => `/giveaways`,
497
- update: (giveawayId) => `/giveaways/${giveawayId}`,
498
- delete: (giveawayId) => `/giveaways/${giveawayId}`
499
- }
500
- };
501
-
502
- // src/utils/Assertion.ts
503
- var Assertion = class {
504
- constructor() {
505
- }
506
- /**
507
- * Tests if given key is a string
508
- * @param key Key to test
509
- */
510
- static assertString(key) {
511
- if (typeof key !== "string") throw new Error(`${key} must be a string`);
512
- if (!key || key === "") throw new Error(`${key} must be a string`);
513
- return true;
514
- }
515
- /**
516
- * Tests if given key is a number
517
- * @param key Key to test
518
- */
519
- static assertNumber(key) {
520
- if (typeof key !== "number") throw new Error(`${key} must be a number`);
521
- return true;
522
- }
523
- /**
524
- * Tests if given key is a boolean
525
- * @param key Key to test
526
- */
527
- static assertBoolean(key) {
528
- if (typeof key !== "boolean") throw new Error(`${key} must be a boolean`);
529
- return true;
530
- }
531
- /**
532
- * Tests if given key is an array
533
- * @param key Key to test
534
- */
535
- static assertArray(key) {
536
- if (!Array.isArray(key)) throw new Error(`${key} must be an array`);
537
- return true;
538
- }
539
- /**
540
- * Tests if given key is an object
541
- * @param key Key to test
542
- */
543
- static assertObject(key) {
544
- if (typeof key !== "object") throw new Error(`${key} must be an object`);
545
- return true;
546
- }
547
- toString() {
548
- return "string, number, boolean, array, object";
549
- }
550
- };
551
-
552
- // src/structures/Collection.ts
553
- var Collection = class _Collection extends Map {
554
- constructor(key, data) {
555
- super();
556
- __publicField(this, "key");
557
- this.key = key;
558
- if (data && Array.isArray(data) && key) {
559
- if (data.length > 0) return;
560
- for (let v of data) this.set(key, v);
561
- }
562
- }
563
- at(index) {
564
- if (index < 0 || index >= this.size) {
565
- return void 0;
566
- }
567
- let i = 0;
568
- for (let [, value] of this) {
569
- if (i === index) {
570
- return value;
571
- }
572
- i++;
573
- }
574
- }
575
- has(key) {
576
- return this.get(key) !== void 0 ? true : false;
577
- }
578
- get first() {
579
- return this.values().next().value;
580
- }
581
- get last() {
582
- return [...this.values()].at(-1);
583
- }
584
- get length() {
585
- return this.toArray().length;
586
- }
587
- find(predicate) {
588
- for (const [key, value] of this) {
589
- if (predicate(value, key, this)) return value;
590
- }
591
- return void 0;
592
- }
593
- filter(predicate) {
594
- const results = new _Collection(this.key, []);
595
- for (const [key, value] of this) {
596
- if (predicate(value, key, this)) results.set(key, value);
597
- }
598
- return results;
599
- }
600
- some(predicate) {
601
- const results = new _Collection(this.key, []);
602
- for (const [key, value] of this) {
603
- if (predicate(value, key, this)) results.set(key, value);
604
- }
605
- return results;
606
- }
607
- map(callback) {
608
- return [...this].map(([key, val]) => callback(val, key, this));
609
- }
610
- toArray() {
611
- return [...this.values()];
612
- }
613
- toJSON() {
614
- let obj = {};
615
- for (let [k, v] of this.entries()) {
616
- obj[`${k}`] = v;
617
- }
618
- return obj;
619
- }
620
- sort(compareFunction) {
621
- const sortedEntries = [...this.entries()].sort((ab, ba) => {
622
- return compareFunction(ab[1], ba[1], this);
623
- });
624
- const coll = new _Collection();
625
- for (let [k, v] of sortedEntries) coll.set(k, v);
626
- return coll;
627
- }
628
- toString() {
629
- return `${this.size}`;
630
- }
631
- };
632
-
633
- // src/managers/player/PlayerManager.ts
634
- var PlayerManager = class extends Collection {
635
- constructor(structure, base_url) {
636
- super("players");
637
- __publicField(this, "base_url");
638
- __publicField(this, "rest");
639
- __publicField(this, "guild");
640
- this.base_url = base_url;
641
- this.guild = structure.guild;
642
- this.rest = structure.rest;
643
- }
644
- _set(data) {
645
- this.clear();
646
- if (Array.isArray(data)) {
647
- for (let p of data) {
648
- if (!p.id) continue;
649
- this.set(p.id, {
650
- id: p.id,
651
- createdAt: p.createdAt ? new Date(p.createdAt) : /* @__PURE__ */ new Date(),
652
- updateAt: p.updateAt ? new Date(p.updateAt) : /* @__PURE__ */ new Date()
653
- });
654
- }
655
- } else {
656
- if (!data.id) return;
657
- this.set(data.id, {
658
- id: data.id,
659
- createdAt: data.createdAt ? new Date(data.createdAt) : /* @__PURE__ */ new Date(),
660
- updateAt: data.updateAt ? new Date(data.updateAt) : /* @__PURE__ */ new Date()
661
- });
662
- }
663
- return this;
664
- }
665
- /**
666
- * Adds a player or an array of players to the structure.
667
- * @param player A player or an array of players to be added
668
- * @returns returns a collection of players
669
- */
670
- async add(player) {
671
- let players = [];
672
- if (Array.isArray(player)) {
673
- for (let p of player) this.has(p.id) ? null : players.push(p);
674
- } else this.has(player.id) ? null : players.push(player);
675
- const payload = { set: players };
676
- const response = await this.rest.request({
677
- method: "PATCH",
678
- payload,
679
- url: this.base_url
680
- });
681
- return this._set(response.players);
682
- }
683
- /**
684
- * Remover a player or an array of players.
685
- * @param player The player or an array of players to be removed
686
- * @returns Player manager
687
- */
688
- async remove(player) {
689
- const ids = new Set(Array.isArray(player) ? player.map((p) => p.id) : [player.id]);
690
- const players = this.toArray().filter((p) => !ids.has(p.id));
691
- const payload = { set: players };
692
- const response = await this.rest.request({
693
- method: "PATCH",
694
- payload,
695
- url: this.base_url
696
- });
697
- return this._set(response.players);
698
- }
699
- };
700
-
701
- // src/rest/REST.ts
702
- var import_dotenv = __toESM(require_main());
703
- import { request, Headers } from "undici";
704
- import_dotenv.default.config();
705
-
706
- // src/structures/bet/GuildBet.ts
707
- var _GuildBet_instances, updateInternals_fn;
708
- var GuildBet = class {
709
- constructor(data, manager) {
710
- __privateAdd(this, _GuildBet_instances);
711
- /** The bet's type */
712
- __publicField(this, "type");
713
- /** The bet's mode */
714
- __publicField(this, "mode");
715
- /** The bet's status */
716
- __publicField(this, "status");
717
- /** The bet's maximum size */
718
- __publicField(this, "maximumSize");
719
- /** The bet's price */
720
- __publicField(this, "price");
721
- /** The bet's players */
722
- __publicField(this, "players");
723
- __publicField(this, "teams");
724
- /** The bet's channel */
725
- __publicField(this, "channels");
726
- /** The bet's messages */
727
- __publicField(this, "messages");
728
- /** The id of the winner */
729
- __publicField(this, "winners");
730
- /** The id of the loser */
731
- __publicField(this, "losers");
732
- /** The bet's creator id */
733
- __publicField(this, "creatorId");
734
- /** The bet's mediator */
735
- __publicField(this, "mediatorId");
736
- /** The bet's confirmers */
737
- __publicField(this, "confirmed");
738
- /** Creation Date */
739
- __publicField(this, "createdAt");
740
- /** Updated Date */
741
- __publicField(this, "updatedAt");
742
- /** Bet's id */
743
- __publicField(this, "_id");
744
- __publicField(this, "queues");
745
- __publicField(this, "guild_id");
746
- __publicField(this, "rest");
747
- __publicField(this, "guild");
748
- __publicField(this, "manager");
749
- this.manager = manager;
750
- this.guild = manager.guild;
751
- this.rest = manager.rest;
752
- this._id = data?._id;
753
- this.guild_id = data?.guild_id;
754
- this.type = data?.type;
755
- this.mode = data?.mode;
756
- this.status = data?.status;
757
- this.maximumSize = data?.maximumSize;
758
- this.price = data?.price;
759
- this.teams = data?.teams;
760
- this.channels = data?.channels;
761
- this.players = new PlayerManager(this, Routes.guilds.bets.resource(this.guild_id, this._id, "players"));
762
- this.messages = new MessagesManager(this, Routes.guilds.bets.resource(this.guild_id, this._id, "messages"));
763
- this.winners = data?.winners;
764
- this.losers = data?.losers;
765
- this.creatorId = data?.creatorId;
766
- this.mediatorId = data?.mediatorId;
767
- this.confirmed = data?.confirmed;
768
- this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
769
- this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
770
- this.queues = [];
771
- for (let queue of data.queues ?? []) {
772
- this.queues.push({
773
- _id: queue?._id,
774
- type: queue?.type,
775
- players: queue?.players,
776
- updatedAt: queue?.updatedAt ? new Date(queue?.updatedAt) : /* @__PURE__ */ new Date(),
777
- createdAt: queue?.createdAt ? new Date(queue?.createdAt) : /* @__PURE__ */ new Date()
778
- });
779
- }
780
- if (data?.messages?.length !== 0) this.messages.set(data.messages);
781
- if (data?.players.length !== 0) this.players._set(data.players);
782
- }
783
- toString() {
784
- return this._id;
785
- }
786
- async fetch() {
787
- const route = Routes.guilds.bets.get(this.guild.id, this._id);
788
- const response = await this.rest.request({ url: route, method: "GET" });
789
- return __privateMethod(this, _GuildBet_instances, updateInternals_fn).call(this, response);
790
- }
791
- async addPlayer(player, queue_type) {
792
- if (this.players.length === 2) return this;
793
- if (this.players.has(player.id)) return this;
794
- this.players.set(player.id, player);
795
- if (queue_type) {
796
- const queue = this.queues.find((q) => q.type === queue_type);
797
- if (!queue) return this;
798
- for (const q of this.queues) {
799
- q.players = q.players.filter((p) => p.id !== player.id);
800
- }
801
- if (!queue.players.some((p) => p.id === player.id)) {
802
- queue.players.push({ id: player.id });
803
- }
804
- }
805
- return await this.update({
806
- players: this.players.toArray(),
807
- queues: this.queues
808
- });
809
- }
810
- async removePlayer(player) {
811
- if (!this.players.some((p) => p.id === player.id)) return this;
812
- let players = this.players.toArray();
813
- players = this.players.filter((p) => p.id !== player.id).toArray();
814
- for (const q of this.queues) {
815
- q.players = q.players.filter((p) => p.id !== player.id);
816
- }
817
- return await this.update({
818
- players,
819
- queues: this.queues
820
- });
821
- }
822
- async update(data) {
823
- const payload = data;
824
- const route = Routes.guilds.bets.update(this.guild.id, this._id);
825
- const response = await this.rest.request({ method: "patch", url: route, payload });
826
- return __privateMethod(this, _GuildBet_instances, updateInternals_fn).call(this, response);
827
- }
828
- async delete() {
829
- const route = Routes.guilds.bets.delete(this.manager.guild.id, this._id);
830
- const response = await this.rest.request({
831
- method: "DELETE",
832
- url: route
833
- });
834
- this.rest.emit("betDelete", this);
835
- this.manager.cache.delete(this._id);
836
- return response;
837
- }
838
- toJSON() {
839
- let json = {};
840
- for (const [key, value] of Object.entries(this)) {
841
- const exclude = ["rest", "guild", "manager"];
842
- if (exclude.includes(key)) continue;
843
- if (typeof value !== "function") {
844
- json[key] = value;
845
- }
846
- }
847
- return {
848
- ...json,
849
- messages: this?.messages instanceof MessagesManager ? this.messages?.cache?.toArray() : [],
850
- players: this.players.toArray()
851
- };
852
- }
853
- };
854
- _GuildBet_instances = new WeakSet();
855
- updateInternals_fn = function(data) {
856
- for (let key in data) {
857
- if (key === "_id" || key === "createdAt") continue;
858
- if (key === "messages") {
859
- this.messages.set(data[key]);
860
- continue;
861
- }
862
- if (key === "players") {
863
- this.players._set(data[key]);
864
- continue;
865
- }
866
- if (key in this) {
867
- this[key] = data[key];
868
- }
869
- }
870
- if (data?.messages?.length !== 0) {
871
- if (this?.messages instanceof MessagesManager) this.messages.set(data.messages);
872
- else {
873
- this.messages = new MessagesManager(this, Routes.guilds.matches.resource(this.guild_id, this._id, "messages"));
874
- this.messages.set(data.messages);
875
- }
876
- }
877
- this.updatedAt = /* @__PURE__ */ new Date();
878
- this.createdAt = new Date(data.createdAt);
879
- this.manager.set(this);
880
- return this;
881
- };
882
-
883
- // src/managers/message/MessagesManager.ts
884
- var MessagesManager = class {
885
- constructor(structure, base_url) {
886
- __publicField(this, "cache");
887
- __publicField(this, "base_url");
888
- __publicField(this, "rest");
889
- __publicField(this, "guild");
890
- this.rest = structure.rest;
891
- this.guild = structure.guild;
892
- this.cache = new Collection("messages");
893
- this.base_url = base_url;
894
- }
895
- async fetch() {
896
- const response = await this.rest.request({
897
- method: "GET",
898
- url: this.base_url,
899
- payload: {}
900
- });
901
- this.cache.set(response._id, response);
902
- return response;
903
- }
904
- async create(data) {
905
- const messages = [...this.cache.toArray()];
906
- if (Array.isArray(data)) messages.push(...data);
907
- else messages.push(data);
908
- const response = await this.rest.request({
909
- method: "PATCH",
910
- url: this.base_url,
911
- payload: { set: messages }
912
- });
913
- return this.set(response.messages);
914
- }
915
- set(data) {
916
- if (!data) return this.cache;
917
- if (Array.isArray(data)) {
918
- for (let message of data) {
919
- if (message && !message._id) continue;
920
- this.cache.set(message._id, message);
921
- }
922
- } else {
923
- if (data && !data._id) return this.cache;
924
- this.cache.set(data._id, data);
925
- }
926
- return this.cache;
927
- }
928
- };
929
-
930
- // src/structures/match/GuildMatch.ts
931
- var _GuildMatch_instances, updateInternals_fn2;
932
- var _GuildMatch = class _GuildMatch {
933
- /**
934
- * GuildMatch match
935
- * @param data The match's data
936
- * @param guild The guild
937
- * @param rest The rest client
938
- */
939
- constructor(data, manager) {
940
- __privateAdd(this, _GuildMatch_instances);
941
- __publicField(this, "_id");
942
- __publicField(this, "selections");
943
- /** Match's type */
944
- __publicField(this, "type");
945
- __publicField(this, "channels");
946
- __publicField(this, "guild_id");
947
- /** Match's status */
948
- __publicField(this, "status");
949
- /** Match's challenge */
950
- __publicField(this, "challenge");
951
- /** Match's players */
952
- __publicField(this, "players");
953
- __publicField(this, "teams");
954
- /** Match's winners */
955
- __publicField(this, "winners");
956
- /** Match's losers */
957
- __publicField(this, "losers");
958
- /** Match's maximum size */
959
- __publicField(this, "maximumSize");
960
- /** Match's kicked out */
961
- __publicField(this, "kickedOut");
962
- /** Match's confirmed */
963
- __publicField(this, "confirmed");
964
- /** Match's leaders */
965
- __publicField(this, "leaders");
966
- /** Match's creator id */
967
- __publicField(this, "creatorId");
968
- /** Match's room creator id */
969
- __publicField(this, "roomCreatorId");
970
- /** Creation Date */
971
- __publicField(this, "createdAt");
972
- /** Updated Date */
973
- __publicField(this, "updatedAt");
974
- __publicField(this, "messages");
975
- /** Match's id */
976
- __publicField(this, "mvps");
977
- __publicField(this, "manager");
978
- __publicField(this, "bet");
979
- __publicField(this, "admin_id");
980
- /** The given guild */
981
- __publicField(this, "guild");
982
- /** The rest client */
983
- __publicField(this, "rest");
984
- __publicField(this, "key");
985
- this._id = data?._id;
986
- this.guild_id = data?.guild_id;
987
- this.manager = manager;
988
- this.guild = manager.guild;
989
- this.rest = manager.rest;
990
- this.admin_id = data?.admin_id;
991
- this.challenge = data?.challenge;
992
- this.players = data?.players;
993
- this.messages = new MessagesManager(this, Routes.guilds.matches.resource(this.guild_id, this._id, "messages"));
994
- this.channels = data?.channels;
995
- this.type = data?.type;
996
- this.status = data?.status;
997
- this.bet = this.guild.bets.cache.get(data?.bet?._id);
998
- this.mvps = data?.mvps;
999
- this.winners = data?.winners;
1000
- this.losers = data?.losers;
1001
- this.maximumSize = data?.maximumSize;
1002
- this.kickedOut = data?.kickedOut;
1003
- this.confirmed = data?.confirmed;
1004
- this.teams = data?.teams;
1005
- this.leaders = data?.leaders;
1006
- this.creatorId = data?.creatorId;
1007
- this.roomCreatorId = data?.roomCreatorId;
1008
- this.selections = data?.selections;
1009
- this.key = "matches";
1010
- this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
1011
- this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
1012
- if (data?.messages?.length !== 0) this.messages.set(data.messages);
1013
- }
1014
- /**
1015
- * Fetches the match
1016
- * @returns New Instance of the match
1017
- */
1018
- async fetch() {
1019
- const route = Routes.guilds.matches.get(this.guild.id, this._id);
1020
- const response = await this.rest.request({
1021
- method: "get",
1022
- url: route
1023
- });
1024
- return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn2).call(this, response);
1025
- }
1026
- async addConfirmed(type, id) {
1027
- const confirmed = this.confirmed.find((c) => c.type === type);
1028
- const idsToAdd = Array.isArray(id) ? id : [id];
1029
- if (!confirmed) {
1030
- this.confirmed.push({ type, ids: [...idsToAdd], count: idsToAdd.length });
1031
- } else {
1032
- const chIndex = this.confirmed.findIndex((ch) => ch.type === type);
1033
- const mergedIds = [.../* @__PURE__ */ new Set([...confirmed.ids || [], ...idsToAdd])];
1034
- this.confirmed[chIndex] = { ...confirmed, ids: mergedIds, count: mergedIds.length };
1035
- }
1036
- return this.update({ confirmed: this.confirmed });
1037
- }
1038
- async setConfirmed(set) {
1039
- Assertion.assertObject(set);
1040
- const route = Routes.guilds.matches.resource(this.guild.id, this._id, "confirmed");
1041
- const response = await this.rest.request({
1042
- method: "PATCH",
1043
- url: route,
1044
- payload: set
1045
- });
1046
- return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn2).call(this, response);
1047
- }
1048
- async setStatus(status) {
1049
- Assertion.assertString(status);
1050
- const payload = { set: status.toLowerCase() };
1051
- const route = Routes.guilds.matches.resource(this.guild.id, this._id, "status");
1052
- const response = await this.rest.request({
1053
- method: "PATCH",
1054
- url: route,
1055
- payload
1056
- });
1057
- return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn2).call(this, response);
1058
- }
1059
- async setWinners(players) {
1060
- if (!Array.isArray(players)) players = [players];
1061
- const payload = { set: players };
1062
- const route = Routes.guilds.matches.resource(this.guild.id, this._id, "winners");
1063
- const response = await this.rest.request({
1064
- method: "PATCH",
1065
- url: route,
1066
- payload
1067
- });
1068
- return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn2).call(this, response);
1069
- }
1070
- async setLoser(players) {
1071
- if (!Array.isArray(players)) players = [players];
1072
- const payload = { set: players };
1073
- const route = Routes.guilds.matches.resource(this.guild.id, this._id, "losers");
1074
- const response = await this.rest.request({
1075
- method: "PATCH",
1076
- url: route,
1077
- payload
1078
- });
1079
- return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn2).call(this, response);
1080
- }
1081
- async setMvps(...usersId) {
1082
- const payload = { set: usersId };
1083
- const route = Routes.guilds.matches.resource(this.guild.id, this._id, "mvps");
1084
- const response = await this.rest.request({
1085
- method: "PATCH",
1086
- url: route,
1087
- payload
1088
- });
1089
- return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn2).call(this, response);
1090
- }
1091
- async setRoomCreatorId(userId) {
1092
- Assertion.assertString(userId);
1093
- const payload = { set: userId };
1094
- const route = Routes.guilds.matches.resource(this.guild.id, this._id, "roomCreatorId");
1095
- const response = await this.rest.request({
1096
- method: "PATCH",
1097
- url: route,
1098
- payload
1099
- });
1100
- return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn2).call(this, response);
1101
- }
1102
- async setRoomAdminId(userId) {
1103
- Assertion.assertString(userId);
1104
- const payload = { set: userId };
1105
- const route = Routes.guilds.matches.resource(this.guild.id, this._id, "admin_id");
1106
- const response = await this.rest.request({
1107
- method: "PATCH",
1108
- url: route,
1109
- payload
1110
- });
1111
- return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn2).call(this, response);
1112
- }
1113
- async kick(player) {
1114
- this.players = this.players.filter((p) => p.id !== player.id);
1115
- this.leaders = this.leaders.filter((p) => p.id !== player.id);
1116
- const teamIndex = this.teams.findIndex((t) => t.some((p) => p.id === player.id));
1117
- if (teamIndex !== -1) {
1118
- let team = this.teams.find((t) => t.some((p) => p.id === player.id));
1119
- team = team.filter((p) => p.id === player.id);
1120
- this.teams[teamIndex] = team;
1121
- }
1122
- return await this.update(this.toJSON());
1123
- }
1124
- async update(data) {
1125
- const route = Routes.guilds.matches.get(this.guild.id, this._id);
1126
- if (data?.bet && data?.bet instanceof GuildBet) {
1127
- data.bet = data.bet.toJSON();
1128
- }
1129
- const response = await this.rest.request({
1130
- method: "patch",
1131
- url: route,
1132
- payload: data
1133
- });
1134
- this.rest.emit("matchUpdate", this, new _GuildMatch(response, this.manager));
1135
- return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn2).call(this, response);
1136
- }
1137
- async delete() {
1138
- const route = Routes.guilds.matches.resource(this.guild.id, this._id);
1139
- const response = await this.rest.request({
1140
- method: "DELETE",
1141
- url: route
1142
- });
1143
- this.manager.cache.delete(this?._id);
1144
- this.rest.matches.delete(this?._id);
1145
- return response;
1146
- }
1147
- toJSON() {
1148
- let json = {};
1149
- for (const [key, value] of Object.entries(this)) {
1150
- const exclude = ["rest", "guilds", "guild", "manager"];
1151
- if (exclude.includes(key)) continue;
1152
- if (typeof value !== "function") {
1153
- json[key] = value;
1154
- }
1155
- }
1156
- return {
1157
- ...json,
1158
- messages: this?.messages instanceof MessagesManager ? this.messages?.cache?.toArray() : []
1159
- };
1160
- }
1161
- };
1162
- _GuildMatch_instances = new WeakSet();
1163
- updateInternals_fn2 = async function(data) {
1164
- if (!data) return;
1165
- for (let key in data) {
1166
- if (key === "id" || key === "createdAt" || key === "messages") continue;
1167
- if (key in this) {
1168
- this[key] = data[key];
1169
- }
1170
- if (key === "bet") {
1171
- this.bet = this.guild.bets.set(data.bet);
1172
- }
1173
- }
1174
- if (data?.messages?.length !== 0) {
1175
- if (this?.messages instanceof MessagesManager) this.messages.set(data.messages);
1176
- else {
1177
- this.messages = new MessagesManager(this, Routes.guilds.matches.resource(this.guild_id, this._id, "messages"));
1178
- this.messages.set(data.messages);
1179
- }
1180
- }
1181
- if (!(this.bet instanceof GuildBet) && data?.bet) {
1182
- this.bet = this.guild.bets.cache.get(data._id) ?? await this.guild.bets.fetch({ betId: data?.bet?._id });
1183
- }
1184
- this.updatedAt = /* @__PURE__ */ new Date();
1185
- this.manager.set(this);
1186
- return this;
1187
- };
1188
- var GuildMatch = _GuildMatch;
1189
- export {
1190
- GuildMatch
1191
- };