@duque.edits/sdk 0.1.5 → 0.1.7

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 (118) hide show
  1. package/dist/index.js +4 -31
  2. package/dist/managers/base.js +26 -0
  3. package/dist/managers/buffer/BufferManager.js +2 -2
  4. package/dist/managers/guild/GuildManager.js +42 -25
  5. package/dist/managers/index.js +23 -0
  6. package/dist/managers/match/GuildMatchManager.js +42 -31
  7. package/dist/managers/message/MessagesManager.js +48 -0
  8. package/dist/managers/permission/GuildPermissionManager.js +29 -52
  9. package/dist/managers/ticket/TicketManager.js +77 -0
  10. package/dist/managers/user/GuildUserManager.js +73 -85
  11. package/dist/managers/vipmember/VipMemberManager.js +23 -23
  12. package/dist/rest/REST.js +40 -24
  13. package/dist/rest/Routes.js +15 -17
  14. package/dist/rest/index.js +19 -0
  15. package/dist/structures/Collection.js +1 -1
  16. package/dist/structures/guild/Guild.js +59 -94
  17. package/dist/structures/index.js +22 -0
  18. package/dist/structures/match/GuildMatch.js +64 -111
  19. package/dist/structures/ticket/Ticket.js +119 -0
  20. package/dist/structures/user/GuildUser.js +46 -40
  21. package/dist/structures/vipmember/VipMember.js +5 -5
  22. package/dist/types/api/APILogMessage.js +2 -0
  23. package/dist/types/api/index.js +36 -0
  24. package/dist/types/index.js +1 -22
  25. package/package.json +11 -18
  26. package/types/index.d.ts +4 -0
  27. package/types/managers/base.d.ts +17 -0
  28. package/{dist → types}/managers/buffer/BufferManager.d.ts +2 -1
  29. package/{dist → types}/managers/guild/GuildManager.d.ts +12 -4
  30. package/types/managers/index.d.ts +7 -0
  31. package/{dist → types}/managers/match/GuildMatchManager.d.ts +10 -12
  32. package/types/managers/message/MessagesManager.d.ts +17 -0
  33. package/types/managers/permission/GuildPermissionManager.d.ts +8 -0
  34. package/types/managers/ticket/TicketManager.d.ts +22 -0
  35. package/types/managers/user/GuildUserManager.d.ts +19 -0
  36. package/{dist → types}/managers/vipmember/VipMemberManager.d.ts +8 -8
  37. package/types/rest/APIEndpoints.d.ts +11 -0
  38. package/{dist → types}/rest/REST.d.ts +9 -18
  39. package/{dist → types}/rest/Routes.d.ts +2 -2
  40. package/types/rest/index.d.ts +3 -0
  41. package/{dist → types}/structures/guild/Guild.d.ts +12 -29
  42. package/types/structures/index.d.ts +6 -0
  43. package/{dist → types}/structures/match/GuildMatch.d.ts +12 -22
  44. package/types/structures/ticket/Ticket.d.ts +30 -0
  45. package/{dist → types}/structures/user/GuildUser.d.ts +5 -3
  46. package/{dist → types}/structures/vipmember/VipMember.d.ts +1 -1
  47. package/types/types/RestTypes.d.ts +34 -0
  48. package/{dist → types}/types/api/APIGuild.d.ts +9 -2
  49. package/{dist → types}/types/api/APIGuildMatch.d.ts +9 -7
  50. package/types/types/api/APIGuildTicket.d.ts +16 -0
  51. package/{dist → types}/types/api/APIGuildUser.d.ts +3 -1
  52. package/types/types/api/APILogMessage.d.ts +7 -0
  53. package/{dist → types}/types/api/APIMessage.d.ts +3 -4
  54. package/{dist → types}/types/api/APIPlayer.d.ts +1 -1
  55. package/{dist → types}/types/api/index.d.ts +23 -1
  56. package/types/types/index.d.ts +2 -0
  57. package/dist/index.d.ts +0 -31
  58. package/dist/managers/bet/GuildBetManager.d.ts +0 -35
  59. package/dist/managers/bet/GuildBetManager.js +0 -126
  60. package/dist/managers/betuser/GuildBetUserManager.d.ts +0 -36
  61. package/dist/managers/betuser/GuildBetUserManager.js +0 -151
  62. package/dist/managers/channel/ChannelManager.d.ts +0 -39
  63. package/dist/managers/channel/ChannelManager.js +0 -148
  64. package/dist/managers/giveaway/GiveawayManager.d.ts +0 -16
  65. package/dist/managers/giveaway/GiveawayManager.js +0 -57
  66. package/dist/managers/groupedchannel/GroupedChannelManager.d.ts +0 -34
  67. package/dist/managers/groupedchannel/GroupedChannelManager.js +0 -92
  68. package/dist/managers/mediator/GuildMediatorManager.d.ts +0 -32
  69. package/dist/managers/mediator/GuildMediatorManager.js +0 -98
  70. package/dist/managers/messages/MessagesManager.d.ts +0 -32
  71. package/dist/managers/messages/MessagesManager.js +0 -89
  72. package/dist/managers/permission/GuildPermissionManager.d.ts +0 -26
  73. package/dist/managers/product/GuildProductManager.d.ts +0 -32
  74. package/dist/managers/product/GuildProductManager.js +0 -103
  75. package/dist/managers/ticket/GuildTicketManager.d.ts +0 -32
  76. package/dist/managers/ticket/GuildTicketManager.js +0 -100
  77. package/dist/managers/user/GuildUserManager.d.ts +0 -33
  78. package/dist/rest/APIEndpoints.d.ts +0 -11
  79. package/dist/structures/bet/GuildBet.d.ts +0 -87
  80. package/dist/structures/bet/GuildBet.js +0 -286
  81. package/dist/structures/betuser/GuildBetUser.d.ts +0 -85
  82. package/dist/structures/betuser/GuildBetUser.js +0 -211
  83. package/dist/structures/channel/Channel.d.ts +0 -31
  84. package/dist/structures/channel/Channel.js +0 -57
  85. package/dist/structures/giveaway/Giveaway.d.ts +0 -37
  86. package/dist/structures/giveaway/Giveaway.js +0 -208
  87. package/dist/structures/groupedchannel/GroupedChannel.d.ts +0 -34
  88. package/dist/structures/groupedchannel/GroupedChannel.js +0 -121
  89. package/dist/structures/mediator/GuildMediator.d.ts +0 -41
  90. package/dist/structures/mediator/GuildMediator.js +0 -131
  91. package/dist/structures/product/GuildProduct.d.ts +0 -52
  92. package/dist/structures/product/GuildProduct.js +0 -175
  93. package/dist/structures/shop/GuildShop.d.ts +0 -34
  94. package/dist/structures/shop/GuildShop.js +0 -80
  95. package/dist/structures/ticket/GuildTicket.d.ts +0 -52
  96. package/dist/structures/ticket/GuildTicket.js +0 -172
  97. package/dist/types/api/APIGuildTicket.d.ts +0 -26
  98. package/dist/types/index.d.ts +0 -23
  99. /package/dist/types/{api/APIGuildMessage.js → RestTypes.js} +0 -0
  100. /package/{dist → types}/structures/Collection.d.ts +0 -0
  101. /package/{dist → types}/types/api/APIBaseChannel.d.ts +0 -0
  102. /package/{dist → types}/types/api/APIBetChannel.d.ts +0 -0
  103. /package/{dist → types}/types/api/APIBetMessage.d.ts +0 -0
  104. /package/{dist → types}/types/api/APIGiveaway.d.ts +0 -0
  105. /package/{dist → types}/types/api/APIGuildBet.d.ts +0 -0
  106. /package/{dist → types}/types/api/APIGuildBetUser.d.ts +0 -0
  107. /package/{dist → types}/types/api/APIGuildChannel.d.ts +0 -0
  108. /package/{dist → types}/types/api/APIGuildEmoji.d.ts +0 -0
  109. /package/{dist → types}/types/api/APIGuildGroupedChannel.d.ts +0 -0
  110. /package/{dist → types}/types/api/APIGuildMediator.d.ts +0 -0
  111. /package/{dist → types}/types/api/APIGuildMessage.d.ts +0 -0
  112. /package/{dist → types}/types/api/APIGuildPermissions.d.ts +0 -0
  113. /package/{dist → types}/types/api/APIGuildRole.d.ts +0 -0
  114. /package/{dist → types}/types/api/APIGuildShop.d.ts +0 -0
  115. /package/{dist → types}/types/api/APIProduct.d.ts +0 -0
  116. /package/{dist → types}/types/api/APIVipMember.d.ts +0 -0
  117. /package/{dist → types}/utils/Assertion.d.ts +0 -0
  118. /package/{dist → types}/utils/getRandomNumber.d.ts +0 -0
@@ -1,87 +0,0 @@
1
- import { REST } from "../../rest/REST";
2
- import { Guild } from "../guild/Guild";
3
- import { APIGuildBet } from "../../types/api/APIGuildBet";
4
- import { APIPlayer } from "../../types/api/APIPlayer";
5
- import { APIBetChannel } from "../../types/api/APIBetChannel";
6
- import { BaseMatchModes, BaseMatchStatus, Confirm, Logs, Optional } from "../../types/api";
7
- import { ChannelManager } from "../../managers/channel/ChannelManager";
8
- import { GuildBetManager } from "../../managers/bet/GuildBetManager";
9
- import { MessagesManager } from "../../managers/messages/MessagesManager";
10
- type ExtendedMatchStatus = BaseMatchStatus | "waiting";
11
- export declare class GuildBet {
12
- /** The bet's type */
13
- type: Omit<BaseMatchModes, "5x5" | "6x6" | "5v5" | "6v6">;
14
- /** The bet's mode */
15
- mode: "misto" | "emu" | "mob" | "MISTO" | "EMU" | "MOB";
16
- /** The bet's status */
17
- status: "off" | "created" | "on" | "shutted" | "waiting";
18
- /** The bet's maximum size */
19
- maximumSize: number;
20
- /** The bet's price */
21
- price: number;
22
- /** Who has payed the bet */
23
- payedBy: APIPlayer[];
24
- /** The bet's players */
25
- players: APIPlayer[];
26
- /** An array of team a */
27
- teamA: APIPlayer[];
28
- /** An array of team b */
29
- teamB: APIPlayer[];
30
- /** The bet's channel */
31
- channels: ChannelManager<GuildBet>;
32
- /** THe bet's messages */
33
- messages: MessagesManager;
34
- /** The id of the winner */
35
- winner: string;
36
- /** The id of the loser */
37
- loser: string;
38
- /** The bet's creator id */
39
- creatorId: string;
40
- /** The bet's mediator */
41
- mediatorId: string;
42
- /** The bet's confirmers */
43
- confirmed: Confirm[];
44
- /** The bet's embed id */
45
- embedMessageId: string;
46
- /** The bet's logs */
47
- logs: Logs;
48
- /** Creation Date */
49
- createdAt: Date;
50
- /** Updated Date */
51
- updatedAt: Date;
52
- /** GuildBet's id */
53
- _id: string;
54
- /** The given guild */
55
- readonly guild: Guild;
56
- /** The rest client */
57
- readonly rest: REST;
58
- readonly key: string;
59
- readonly manager: GuildBetManager;
60
- /**
61
- * GuildBet bet
62
- * @param data The bet's data
63
- * @param guild The guild
64
- * @param rest The rest client
65
- */
66
- constructor(data: APIGuildBet, guild: Guild, manager: GuildBetManager, rest: REST);
67
- toString(): string;
68
- /**
69
- * Fetches the bet
70
- * @returns New Instance of the bet
71
- */
72
- fetch(): Promise<GuildBet>;
73
- addConfirmed(type: string, id: string): Promise<Confirm>;
74
- setConfirmed(set: Confirm[]): Promise<Confirm[]>;
75
- setStatus(status: ExtendedMatchStatus): Promise<this>;
76
- setWinner(userId: string): Promise<string>;
77
- setLoser(userId: string): Promise<string>;
78
- delete(): Promise<boolean>;
79
- addChannel(id: string, type: string): Promise<import("../..").Channel<GuildBet>>;
80
- addMessage(id: string, type: string, content?: string): Promise<boolean>;
81
- setChannels(channels: APIBetChannel[]): Promise<ChannelManager<GuildBet>>;
82
- addPlayer(player: Optional<APIPlayer>): Promise<APIPlayer[]>;
83
- removePlayer(player: Optional<APIPlayer>): Promise<APIPlayer[]>;
84
- update(data: Optional<APIGuildBet>): Promise<this>;
85
- toJSON(): Record<string, unknown>;
86
- }
87
- export {};
@@ -1,286 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GuildBet = void 0;
4
- const Routes_1 = require("../../rest/Routes");
5
- const Assertion_1 = require("../../utils/Assertion");
6
- const ChannelManager_1 = require("../../managers/channel/ChannelManager");
7
- const MessagesManager_1 = require("../../managers/messages/MessagesManager");
8
- class GuildBet {
9
- /** The bet's type */
10
- type;
11
- /** The bet's mode */
12
- mode;
13
- /** The bet's status */
14
- status;
15
- /** The bet's maximum size */
16
- maximumSize;
17
- /** The bet's price */
18
- price;
19
- /** Who has payed the bet */
20
- payedBy;
21
- /** The bet's players */
22
- players;
23
- /** An array of team a */
24
- teamA;
25
- /** An array of team b */
26
- teamB;
27
- /** The bet's channel */
28
- channels;
29
- /** THe bet's messages */
30
- messages;
31
- /** The id of the winner */
32
- winner;
33
- /** The id of the loser */
34
- loser;
35
- /** The bet's creator id */
36
- creatorId;
37
- /** The bet's mediator */
38
- mediatorId;
39
- /** The bet's confirmers */
40
- confirmed;
41
- /** The bet's embed id */
42
- embedMessageId;
43
- /** The bet's logs */
44
- logs;
45
- /** Creation Date */
46
- createdAt;
47
- /** Updated Date */
48
- updatedAt;
49
- /** GuildBet's id */
50
- _id;
51
- /** The given guild */
52
- guild;
53
- /** The rest client */
54
- rest;
55
- key;
56
- manager;
57
- /**
58
- * GuildBet bet
59
- * @param data The bet's data
60
- * @param guild The guild
61
- * @param rest The rest client
62
- */
63
- constructor(data, guild, manager, rest) {
64
- this.type = data?.type;
65
- this.mode = data?.mode;
66
- this.status = data?.status;
67
- this.maximumSize = data?.maximumSize;
68
- this.price = data?.price;
69
- this.payedBy = data?.payedBy;
70
- this.players = data?.players;
71
- this.teamA = data?.teamA;
72
- this.teamB = data?.teamB;
73
- this.winner = data?.winner;
74
- this.loser = data?.loser;
75
- this.creatorId = data?.creatorId;
76
- this.mediatorId = data?.mediatorId;
77
- this.confirmed = data?.confirmed;
78
- this.embedMessageId = data?.embedMessageId;
79
- this.winner = data?.winner;
80
- this.loser = data?.loser;
81
- this._id = data?._id;
82
- this.logs = data?.logs;
83
- this.guild = guild;
84
- this.rest = rest;
85
- this.manager = manager;
86
- this.key = "bets";
87
- this.channels = new ChannelManager_1.ChannelManager(guild, this, rest);
88
- this.messages = new MessagesManager_1.MessagesManager(this?.guild, `bets/${data?._id}`, rest);
89
- this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
90
- this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
91
- this.channels.setAll(data?.channels);
92
- this.messages.setAll(data?.messages);
93
- }
94
- toString() {
95
- return this._id || "1";
96
- }
97
- /**
98
- * Fetches the bet
99
- * @returns New Instance of the bet
100
- */
101
- async fetch() {
102
- const route = Routes_1.Routes.guilds.bets.get(this.guild.id, this._id);
103
- const response = await this.rest.request({
104
- method: "get",
105
- url: route,
106
- });
107
- const bt = new GuildBet(response, this.guild, this.manager, this.rest);
108
- this.manager.cache.set(bt._id, bt);
109
- return bt;
110
- }
111
- async addConfirmed(type, id) {
112
- Assertion_1.Assertion.assertString(type);
113
- Assertion_1.Assertion.assertString(id);
114
- const route = Routes_1.Routes.guilds.bets.resource(this.guild.id, this._id, "confirmed");
115
- const payload = { entry: { type, id } };
116
- const response = await this.rest.request({
117
- method: "PATCH",
118
- url: route,
119
- payload,
120
- });
121
- this.rest.emit("betUpdate", this, new GuildBet(response, this.guild, this.manager, this.rest));
122
- this.confirmed = response.confirmed;
123
- this.manager.cache.set(this._id, this);
124
- return response.confirmed.find((cn) => cn.type == type);
125
- }
126
- async setConfirmed(set) {
127
- Assertion_1.Assertion.assertObject(set);
128
- const route = Routes_1.Routes.guilds.bets.resource(this.guild.id, this._id, "confirmed");
129
- const response = await this.rest.request({
130
- method: "PATCH",
131
- url: route,
132
- payload: set,
133
- });
134
- this.rest.emit("betUpdate", this, new GuildBet(response, this.guild, this.manager, this.rest));
135
- this.confirmed = response.confirmed;
136
- this.manager.cache.set(this._id, this);
137
- return this.confirmed;
138
- }
139
- async setStatus(status) {
140
- Assertion_1.Assertion.assertString(status);
141
- const payload = { set: status.toLowerCase() };
142
- const route = Routes_1.Routes.guilds.bets.resource(this.guild.id, this._id, "status");
143
- const response = await this.rest.request({
144
- method: "PATCH",
145
- url: route,
146
- payload,
147
- });
148
- this.rest.emit("betUpdate", this, new GuildBet(response, this.guild, this.manager, this.rest));
149
- this.status = response.status;
150
- this.manager.cache.set(this._id, this);
151
- return this;
152
- }
153
- async setWinner(userId) {
154
- Assertion_1.Assertion.assertString(userId);
155
- const payload = { set: userId };
156
- const route = Routes_1.Routes.guilds.bets.resource(this.guild.id, this._id, "winner");
157
- const response = await this.rest.request({
158
- method: "PATCH",
159
- url: route,
160
- payload,
161
- });
162
- this.rest.emit("betUpdate", this, new GuildBet(response, this.guild, this.manager, this.rest));
163
- this.winner = response.winner;
164
- this.manager.cache.set(this._id, this);
165
- return response.winner;
166
- }
167
- async setLoser(userId) {
168
- Assertion_1.Assertion.assertString(userId);
169
- const payload = { set: userId };
170
- const route = Routes_1.Routes.guilds.bets.resource(this.guild.id, this._id, "loser");
171
- const response = await this.rest.request({
172
- method: "PATCH",
173
- url: route,
174
- payload,
175
- });
176
- this.rest.emit("betUpdate", this, new GuildBet(response, this.guild, this.manager, this.rest));
177
- this.loser = response.loser;
178
- this.manager.cache.set(this._id, this);
179
- return response.loser;
180
- }
181
- async delete() {
182
- const route = Routes_1.Routes.guilds.bets.resource(this.guild.id, this._id);
183
- const response = await this.rest.request({
184
- method: "DELETE",
185
- url: route,
186
- });
187
- this.manager.cache.delete(this?._id);
188
- this.rest.bets.delete(this?._id);
189
- return response;
190
- }
191
- async addChannel(id, type) {
192
- const ch = await this.channels.create({ id, type });
193
- this.manager.cache.set(this._id, this);
194
- return ch;
195
- }
196
- async addMessage(id, type, content) {
197
- const response = await this.messages.create({
198
- userId: id,
199
- type: type,
200
- content,
201
- });
202
- this.manager.cache.set(this._id, this);
203
- this.rest.bets.set(this._id, this);
204
- return response;
205
- }
206
- async setChannels(channels) {
207
- Assertion_1.Assertion.assertObject(channels);
208
- const payload = { set: channels };
209
- const route = Routes_1.Routes.guilds.bets.resource(this.guild.id, this._id, "channels");
210
- const response = await this.rest.request({
211
- method: "PATCH",
212
- url: route,
213
- payload,
214
- });
215
- this.rest.emit("betUpdate", this, new GuildBet(response, this.guild, this.manager, this.rest));
216
- this.channels.setAll(response.channels);
217
- this.manager.cache.set(this._id, this);
218
- return this.channels;
219
- }
220
- async addPlayer(player) {
221
- Assertion_1.Assertion.assertObject(player);
222
- const route = Routes_1.Routes.guilds.bets.resource(this.guild.id, this._id, "players");
223
- const payload = { ...player };
224
- const response = await this.rest.request({
225
- method: "POST",
226
- url: route,
227
- payload,
228
- });
229
- this.players = response;
230
- this.manager.cache.set(this._id, this);
231
- return this.players;
232
- }
233
- async removePlayer(player) {
234
- Assertion_1.Assertion.assertObject(player);
235
- const route = Routes_1.Routes.guilds.bets.resource(this.guild.id, this._id, "players", player.id);
236
- const payload = { ...player };
237
- const response = await this.rest.request({
238
- method: "DELETE",
239
- url: route,
240
- payload,
241
- });
242
- this.players = response;
243
- this.manager.cache.set(this._id, this);
244
- return this.players;
245
- }
246
- async update(data) {
247
- const route = Routes_1.Routes.guilds.bets.get(this.guild.id, this._id);
248
- const payload = data;
249
- const response = await this.rest.request({
250
- method: "patch",
251
- url: route,
252
- payload,
253
- });
254
- this.rest.emit("betUpdate", this, new GuildBet(response, this.guild, this.manager, this.rest));
255
- for (const k in response) {
256
- if (k === "id")
257
- continue;
258
- if (Object.hasOwn(this, k)) {
259
- if (k === "channels") {
260
- this.channels.setAll(response["channels"]);
261
- continue;
262
- }
263
- if (k === "messages") {
264
- this.messages.setAll(response["messages"]);
265
- continue;
266
- }
267
- this[k] = response[k];
268
- }
269
- }
270
- this.rest.bets.set(this._id, this);
271
- this.manager.cache.set(this._id, this);
272
- this.updatedAt = response?.updatedAt ? new Date(response?.updatedAt) : new Date();
273
- this.createdAt = response?.createdAt ? new Date(response?.createdAt) : new Date();
274
- return this;
275
- }
276
- toJSON() {
277
- const json = {};
278
- for (const [key, value] of Object.entries(this)) {
279
- if (typeof value !== "function") {
280
- json[key] = value;
281
- }
282
- }
283
- return json;
284
- }
285
- }
286
- exports.GuildBet = GuildBet;
@@ -1,85 +0,0 @@
1
- import { REST } from "../../rest/REST";
2
- import { Daily, Items, Optional, ProfileCard } from "../../types/api";
3
- import { APIGuildBetUser } from "../../types/api/APIGuildBetUser";
4
- import { GuildBetUserManager } from "../../managers/betuser/GuildBetUserManager";
5
- export declare class GuildBetUser implements APIGuildBetUser {
6
- #private;
7
- /** User daily */
8
- daily: Omit<Daily, "points">;
9
- /** User's name */
10
- name: string;
11
- /** User's name */
12
- id: string;
13
- /** User's credit */
14
- credit: number;
15
- /** User's wins */
16
- wins: number;
17
- /** User's mvps */
18
- mvps: number;
19
- /** User's losses */
20
- losses: number;
21
- /** User's bets played */
22
- betsPlayed: string[];
23
- /** User's blacklist */
24
- blacklist: boolean;
25
- /** User's coins */
26
- coins: number;
27
- games: number;
28
- /** User's items */
29
- items: Items;
30
- /** User's profile card */
31
- profileCard: ProfileCard;
32
- /** Creation Date */
33
- createdAt: Date;
34
- /** Updated Date */
35
- updatedAt: Date;
36
- /** The given manager */
37
- readonly manager: GuildBetUserManager;
38
- /** The rest client */
39
- readonly rest: REST;
40
- /**
41
- * Bet user
42
- * @param data The user's data
43
- * @param manager The manager
44
- * @param rest The rest client
45
- */
46
- constructor(data: APIGuildBetUser, manager: GuildBetUserManager, rest: REST);
47
- /** String representation of this user */
48
- toString(): string;
49
- /**
50
- * Fetches the user
51
- * @returns New Instance of the user
52
- */
53
- fetch(): Promise<GuildBetUser>;
54
- /**
55
- * Add a propery
56
- * @param key The desired key
57
- * @param value The desired value
58
- * @returns GuildBetUser
59
- */
60
- add<K extends keyof BetUserAddOptions, V extends BetUserAddOptions[K]>(key: K, value: V): Promise<this>;
61
- reset(): Promise<this>;
62
- /**
63
- * Set the user blacklist
64
- * @param value Value to set to
65
- * @returns GuildBetUser
66
- */
67
- setBlacklist(value: boolean): Promise<this>;
68
- /**
69
- * Update certain property
70
- * @param data The new data to update with
71
- * @returns
72
- */
73
- update(data: Omit<Optional<APIGuildBetUser>, "daily"> & {
74
- type?: "add" | "remove";
75
- }): Promise<this>;
76
- delete(): Promise<boolean>;
77
- toJSON(): Record<string, unknown>;
78
- }
79
- export type BetUserAddOptions = {
80
- coins: number;
81
- credit: number;
82
- wins: number;
83
- losses: number;
84
- mvps: number;
85
- };
@@ -1,211 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GuildBetUser = void 0;
4
- const Routes_1 = require("../../rest/Routes");
5
- class GuildBetUser {
6
- /** User daily */
7
- daily;
8
- /** User's name */
9
- name;
10
- /** User's name */
11
- id;
12
- /** User's credit */
13
- credit;
14
- /** User's wins */
15
- wins;
16
- /** User's mvps */
17
- mvps;
18
- /** User's losses */
19
- losses;
20
- /** User's bets played */
21
- betsPlayed;
22
- /** User's blacklist */
23
- blacklist;
24
- /** User's coins */
25
- coins;
26
- games;
27
- /** User's items */
28
- items;
29
- /** User's profile card */
30
- profileCard;
31
- /** Creation Date */
32
- createdAt;
33
- /** Updated Date */
34
- updatedAt;
35
- /** The given manager */
36
- manager;
37
- /** The rest client */
38
- rest;
39
- /**
40
- * Bet user
41
- * @param data The user's data
42
- * @param manager The manager
43
- * @param rest The rest client
44
- */
45
- constructor(data, manager, rest) {
46
- this.name = data?.name;
47
- this.id = data?.id;
48
- this.credit = data?.credit;
49
- this.wins = data?.wins;
50
- this.mvps = data?.mvps;
51
- this.losses = data?.losses;
52
- this.games = data?.games;
53
- this.coins = data?.coins;
54
- this.blacklist = data?.blacklist;
55
- this.items = data?.items;
56
- this.betsPlayed = data?.betsPlayed;
57
- this.profileCard = data?.profileCard;
58
- this.daily = data?.daily;
59
- this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
60
- this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
61
- this.manager = manager;
62
- this.rest = rest;
63
- }
64
- /** String representation of this user */
65
- toString() {
66
- return `<@${this.id}>`;
67
- }
68
- /**
69
- * Fetches the user
70
- * @returns New Instance of the user
71
- */
72
- async fetch() {
73
- const route = Routes_1.Routes.guilds.betUsers.get(this.manager.guild.id, this.id);
74
- const response = await this.rest.request({
75
- method: "get",
76
- url: route,
77
- });
78
- const user = new GuildBetUser(response, this.manager, this.rest);
79
- this.manager.cache.set(user.id, user);
80
- this.rest.betUsers.set(user.id, user);
81
- return user;
82
- }
83
- /**
84
- * Add a propery
85
- * @param key The desired key
86
- * @param value The desired value
87
- * @returns GuildBetUser
88
- */
89
- async add(key, value) {
90
- const route = Routes_1.Routes.guilds.betUsers.resource(this.manager.guild.id, this.id, key);
91
- const payload = { [key]: value, name: this.name };
92
- const resp = await this.rest.request({
93
- method: "patch",
94
- url: route,
95
- payload,
96
- });
97
- this[key] = resp[key];
98
- this.manager.cache.set(this.id, this);
99
- this.rest.betUsers.set(this.id, this);
100
- return this;
101
- }
102
- async reset() {
103
- const route = Routes_1.Routes.guilds.betUsers.get(this.manager.guild.id, this.id);
104
- const payload = { reset: true };
105
- const response = await this.rest.request({
106
- method: "DELETE",
107
- url: route,
108
- payload,
109
- });
110
- this.#updateData(response);
111
- return this;
112
- }
113
- #updateData(data) {
114
- for (const k in data) {
115
- if (k === "id")
116
- continue;
117
- if (Object.hasOwn(this, k)) {
118
- this[k] = data[k];
119
- this.data[k] = data[k];
120
- }
121
- }
122
- }
123
- /**
124
- * Set the user blacklist
125
- * @param value Value to set to
126
- * @returns GuildBetUser
127
- */
128
- async setBlacklist(value) {
129
- const route = Routes_1.Routes.guilds.betUsers.resource(this.manager.guild.id, this.id, "blacklist");
130
- const payload = { value, name: this.name };
131
- await this.rest.request({
132
- method: "patch",
133
- url: route,
134
- payload,
135
- });
136
- this.blacklist = value;
137
- this.manager.cache.set(this.id, this);
138
- this.rest.betUsers.set(this.id, this);
139
- return this;
140
- }
141
- /**
142
- * Update certain property
143
- * @param data The new data to update with
144
- * @returns
145
- */
146
- async update(data) {
147
- const route = Routes_1.Routes.guilds.betUsers.get(this.manager.guild.id, this.id);
148
- const payload = {};
149
- const numericFields = ["coins", "wins", "credit", "losses", "mvps", "games"];
150
- const arrayFields = ["items", "betsPlayed"];
151
- if (data?.type === "add" || data?.type === "remove") {
152
- for (const key in data) {
153
- if (key === "type")
154
- continue;
155
- const value = data[key];
156
- if (numericFields.includes(key)) {
157
- const current = this[key];
158
- const num = value;
159
- payload[key] = Math.max(0, data?.type === "add" ? current + num : num - current);
160
- }
161
- else if (key === "blacklist") {
162
- payload["blacklist"] = value;
163
- }
164
- else if (arrayFields.includes(key)) {
165
- const current = this[key];
166
- const incoming = value;
167
- payload[key] =
168
- data?.type === "add"
169
- ? [...new Set([...current, ...incoming])]
170
- : current.filter((x) => !incoming.includes(x));
171
- }
172
- }
173
- }
174
- const response = await this.rest.request({
175
- method: "patch",
176
- url: route,
177
- payload,
178
- });
179
- for (const k in response) {
180
- if (k === "id")
181
- continue;
182
- if (Object.hasOwn(this, k)) {
183
- this[k] = response[k];
184
- }
185
- }
186
- this.updatedAt = new Date();
187
- this.rest.betUsers.set(this.id, this);
188
- this.manager.cache.set(this.id, this);
189
- return this;
190
- }
191
- async delete() {
192
- const route = Routes_1.Routes.guilds.betUsers.delete(this.manager.guild.id, this.id);
193
- const response = await this.rest.request({
194
- method: "DELETE",
195
- url: route,
196
- });
197
- this.rest.emit("betUserDelete", this);
198
- this.manager.cache.delete(this.id);
199
- return response;
200
- }
201
- toJSON() {
202
- const json = {};
203
- for (const [key, value] of Object.entries(this)) {
204
- if (typeof value !== "function") {
205
- json[key] = value;
206
- }
207
- }
208
- return json;
209
- }
210
- }
211
- exports.GuildBetUser = GuildBetUser;
@@ -1,31 +0,0 @@
1
- import { ChannelManager } from "../../managers/channel/ChannelManager";
2
- import { REST } from "../../rest/REST";
3
- import { APIBaseChannel } from "../../types/api/APIBaseChannel";
4
- import { GuildBet } from "../bet/GuildBet";
5
- import { Guild } from "../guild/Guild";
6
- import { GuildMatch } from "../match/GuildMatch";
7
- export interface ChannelData<S extends GuildBet | GuildMatch> {
8
- baseUrl: string;
9
- data: APIBaseChannel;
10
- guild: Guild;
11
- manager: ChannelManager<S>;
12
- }
13
- export declare class Channel<S extends GuildBet | GuildMatch> {
14
- /** Channel's type */
15
- type: string;
16
- /** Channel's id */
17
- id: string;
18
- /** Creation Date */
19
- createdAt: Date;
20
- /** Updated Date */
21
- updatedAt: Date;
22
- data: ChannelData<S>;
23
- rest: REST;
24
- baseUrl: string;
25
- guild: Guild;
26
- manager: ChannelManager<S>;
27
- constructor(data: ChannelData<S>, rest: REST);
28
- toString(): string;
29
- setId(id: string): Promise<this>;
30
- delete(): Promise<this>;
31
- }