@duque.edits/sdk 0.1.6 → 0.1.8
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.
- package/dist/managers/base.js +0 -6
- package/dist/managers/buffer/BufferManager.js +2 -2
- package/dist/managers/guild/GuildManager.js +6 -4
- package/dist/managers/index.js +5 -1
- package/dist/managers/logs/LogManager.js +60 -0
- package/dist/managers/match/GuildMatchManager.js +1 -1
- package/dist/managers/message/MessagesManager.js +1 -1
- package/dist/managers/minesgame/MinesGameManager.js +67 -0
- package/dist/managers/ticket/TicketManager.js +3 -3
- package/dist/managers/user/GuildUserManager.js +13 -21
- package/dist/managers/vipmember/VipMemberManager.js +2 -2
- package/dist/rest/REST.js +16 -17
- package/dist/rest/Routes.js +3 -3
- package/dist/structures/Collection.js +2 -2
- package/dist/structures/guild/Guild.js +142 -75
- package/dist/structures/index.js +1 -0
- package/dist/structures/match/GuildMatch.js +32 -74
- package/dist/structures/minesgame/MinesGame.js +72 -0
- package/dist/structures/user/GuildUser.js +16 -13
- package/dist/types/api/APIGuild.js +16 -0
- package/dist/types/api/APIGuildMatch.js +9 -0
- package/dist/types/api/APILogEntry.js +2 -0
- package/dist/types/api/APIMinesGame.js +2 -0
- package/dist/types/api/index.js +4 -4
- package/package.json +6 -4
- package/types/managers/base.d.ts +0 -3
- package/types/managers/index.d.ts +5 -1
- package/types/managers/logs/LogManager.d.ts +11 -0
- package/types/managers/minesgame/MinesGameManager.d.ts +17 -0
- package/types/managers/ticket/TicketManager.d.ts +1 -1
- package/types/managers/user/GuildUserManager.d.ts +2 -3
- package/types/managers/vipmember/VipMemberManager.d.ts +1 -2
- package/types/rest/REST.d.ts +10 -7
- package/types/structures/guild/Guild.d.ts +16 -32
- package/types/structures/index.d.ts +1 -0
- package/types/structures/match/GuildMatch.d.ts +4 -7
- package/types/structures/minesgame/MinesGame.d.ts +23 -0
- package/types/structures/ticket/Ticket.d.ts +3 -3
- package/types/structures/user/GuildUser.d.ts +3 -4
- package/types/types/api/APIGuild.d.ts +22 -38
- package/types/types/api/APIGuildGroupedChannel.d.ts +2 -5
- package/types/types/api/APIGuildMatch.d.ts +6 -0
- package/types/types/api/APIGuildUser.d.ts +7 -2
- package/types/types/api/APILogEntry.d.ts +9 -0
- package/types/types/api/APIMessage.d.ts +2 -1
- package/types/types/api/APIMinesGame.d.ts +13 -0
- package/types/types/api/index.d.ts +6 -15
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Guild = void 0;
|
|
4
|
-
const
|
|
5
|
-
const BufferManager_1 = require("../../managers/buffer/BufferManager");
|
|
6
|
-
const GuildMatchManager_1 = require("../../managers/match/GuildMatchManager");
|
|
4
|
+
const managers_1 = require("../../managers");
|
|
7
5
|
const Routes_1 = require("../../rest/Routes");
|
|
8
6
|
const Assertion_1 = require("../../utils/Assertion");
|
|
9
|
-
const GuildUserManager_1 = require("../../managers/user/GuildUserManager");
|
|
10
|
-
const managers_1 = require("../../managers");
|
|
11
|
-
/** The Guild */
|
|
12
7
|
class Guild {
|
|
13
8
|
/** The data of this guild */
|
|
14
9
|
data;
|
|
@@ -18,84 +13,140 @@ class Guild {
|
|
|
18
13
|
id;
|
|
19
14
|
modes;
|
|
20
15
|
/** Guild's client key */
|
|
21
|
-
|
|
16
|
+
client_key;
|
|
22
17
|
/** Guild Permissions */
|
|
23
18
|
permissions;
|
|
24
19
|
/** Guild Ticket */
|
|
25
|
-
|
|
20
|
+
tickets;
|
|
26
21
|
/** Guild Ticket Configuration */
|
|
27
22
|
tickets_configuration;
|
|
28
23
|
/** Guild Daily Categories */
|
|
29
|
-
|
|
24
|
+
daily_categories;
|
|
30
25
|
/** Guild Scores */
|
|
31
26
|
scores;
|
|
32
27
|
/** Guild Status */
|
|
33
28
|
status;
|
|
34
|
-
|
|
35
|
-
//channels: GroupedChannelManager;
|
|
36
|
-
/** Guild Categories */
|
|
37
|
-
// categories: GroupedChannelManager;
|
|
38
|
-
/** Guild Blacklist */
|
|
39
|
-
blacklist;
|
|
29
|
+
channels;
|
|
40
30
|
/** Guild Prefix */
|
|
41
31
|
prefix;
|
|
42
|
-
/** Guild Prices */
|
|
43
|
-
pricesAvailable;
|
|
44
|
-
/** Guild Prices Used */
|
|
45
|
-
pricesOn;
|
|
46
32
|
/** Guild Creation Date */
|
|
47
33
|
createdAt;
|
|
48
34
|
/** Guild Updated Date */
|
|
49
35
|
updatedAt;
|
|
50
|
-
/** Guild Users */
|
|
51
|
-
//users: GuildUserManager;
|
|
52
|
-
/** Guild Bet Users */
|
|
53
|
-
// betUsers: GuildBetUserManager;
|
|
54
36
|
/** Guild Matches */
|
|
55
37
|
matches;
|
|
56
|
-
/** Guild Emojis */
|
|
57
|
-
emojis;
|
|
58
|
-
/** Guild Roles */
|
|
59
|
-
roles;
|
|
60
38
|
/** Guild Prices Used */
|
|
61
39
|
prices;
|
|
62
40
|
permissionsManager;
|
|
63
41
|
buffer;
|
|
64
42
|
vipMembers;
|
|
65
43
|
users;
|
|
66
|
-
|
|
44
|
+
logEntries;
|
|
45
|
+
shop;
|
|
67
46
|
/**
|
|
68
47
|
* The guild structure
|
|
69
48
|
* @param data The guild's data
|
|
70
49
|
* @param rest The rest client
|
|
71
50
|
*/
|
|
72
51
|
constructor(data, rest) {
|
|
73
|
-
this.id = data?.id;
|
|
74
52
|
this.data = data;
|
|
75
53
|
this.rest = rest;
|
|
76
|
-
this.
|
|
77
|
-
this.
|
|
78
|
-
this.
|
|
79
|
-
this.tickets_configuration = data?.tickets_configuration;
|
|
54
|
+
this.id = data?.id;
|
|
55
|
+
this.client_key = data?.client_key;
|
|
56
|
+
this.daily_categories = data?.daily_categories;
|
|
80
57
|
this.permissions = data?.permissions;
|
|
81
|
-
this.dailyCategories = data?.dailyCategories;
|
|
82
|
-
this.scores = data?.scores;
|
|
83
58
|
this.modes = data?.modes;
|
|
84
|
-
this.roles = data?.roles;
|
|
85
|
-
this.emojis = data?.emojis;
|
|
86
|
-
this.pricesAvailable = data?.pricesAvailable;
|
|
87
|
-
this.pricesOn = data?.pricesOn;
|
|
88
59
|
this.prices = data?.prices;
|
|
60
|
+
this.scores = data?.scores;
|
|
61
|
+
this.prefix = data?.prefix;
|
|
62
|
+
this.status = data?.status;
|
|
63
|
+
this.tickets_configuration = data?.tickets_configuration;
|
|
64
|
+
this.channels = data?.channels;
|
|
65
|
+
this.shop = data?.shop;
|
|
89
66
|
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
|
|
90
67
|
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
|
|
91
|
-
this.permissionsManager = new
|
|
92
|
-
this.
|
|
93
|
-
this.
|
|
94
|
-
this.
|
|
95
|
-
this.tickets = new managers_1.
|
|
96
|
-
this.
|
|
97
|
-
this.
|
|
98
|
-
|
|
68
|
+
this.permissionsManager = new managers_1.GuildPermissionManager(this);
|
|
69
|
+
this.buffer = new managers_1.BufferManager(this);
|
|
70
|
+
this.users = new managers_1.GuildUserManager(this);
|
|
71
|
+
this.matches = new managers_1.GuildMatchManager(this);
|
|
72
|
+
this.tickets = new managers_1.GuildTicketManager(this);
|
|
73
|
+
this.vipMembers = new managers_1.VipMemberManager(this);
|
|
74
|
+
this.logEntries = new managers_1.LogManager(this);
|
|
75
|
+
}
|
|
76
|
+
async getChannel(type) {
|
|
77
|
+
const channel = this.channels.find((c) => c.type === type);
|
|
78
|
+
if (channel)
|
|
79
|
+
return channel;
|
|
80
|
+
else {
|
|
81
|
+
const channels = [...this.channels, { type, ids: [] }];
|
|
82
|
+
const route = Routes_1.Routes.guilds.get(this.id);
|
|
83
|
+
const response = await this.rest.request({
|
|
84
|
+
method: "PATCH",
|
|
85
|
+
url: route,
|
|
86
|
+
payload: { channels },
|
|
87
|
+
});
|
|
88
|
+
this._updateInternals(response);
|
|
89
|
+
return response.channels.find((t) => t.type === type);
|
|
90
|
+
}
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
async addIdToChannel(type, id) {
|
|
94
|
+
const channel = this.channels.find((c) => c.type === type);
|
|
95
|
+
const idsToAdd = Array.isArray(id) ? id : [id];
|
|
96
|
+
if (!channel) {
|
|
97
|
+
// create new channel if it doesn't exist
|
|
98
|
+
this.channels.push({ type, ids: [...idsToAdd] });
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
// merge IDs, remove duplicates
|
|
102
|
+
const chIndex = this.channels.findIndex((ch) => ch.type === type);
|
|
103
|
+
const mergedIds = [...new Set([...(channel.ids || []), ...idsToAdd])];
|
|
104
|
+
this.channels[chIndex] = { ...channel, ids: mergedIds };
|
|
105
|
+
}
|
|
106
|
+
const route = Routes_1.Routes.guilds.get(this.id);
|
|
107
|
+
const payload = { channels: this.channels };
|
|
108
|
+
const response = await this.rest.request({
|
|
109
|
+
method: "PATCH",
|
|
110
|
+
url: route,
|
|
111
|
+
payload,
|
|
112
|
+
});
|
|
113
|
+
return this._updateInternals(response);
|
|
114
|
+
}
|
|
115
|
+
async removeIdInChannel(type, id) {
|
|
116
|
+
const chIndex = this.channels.findIndex((c) => c.type === type);
|
|
117
|
+
if (chIndex !== -1) {
|
|
118
|
+
const existing = this.channels[chIndex];
|
|
119
|
+
const updatedIds = existing.ids.filter((i) => i !== id);
|
|
120
|
+
this.channels[chIndex] = {
|
|
121
|
+
...existing,
|
|
122
|
+
ids: updatedIds,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
// If channel doesn't exist, create it with empty ids
|
|
127
|
+
this.channels.push({
|
|
128
|
+
type,
|
|
129
|
+
ids: [],
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
const route = Routes_1.Routes.guilds.get(this.id);
|
|
133
|
+
const payload = { channels: this.channels };
|
|
134
|
+
const response = await this.rest.request({
|
|
135
|
+
method: "PATCH",
|
|
136
|
+
url: route,
|
|
137
|
+
payload,
|
|
138
|
+
});
|
|
139
|
+
return this._updateInternals(response);
|
|
140
|
+
}
|
|
141
|
+
async _start() {
|
|
142
|
+
await Promise.all([
|
|
143
|
+
this.users.fetch(),
|
|
144
|
+
this.matches.fetch(),
|
|
145
|
+
this.tickets.fetch(),
|
|
146
|
+
this.vipMembers.fetch(),
|
|
147
|
+
this.logEntries.fetch(),
|
|
148
|
+
]);
|
|
149
|
+
return this;
|
|
99
150
|
}
|
|
100
151
|
_updateInternals(data) {
|
|
101
152
|
for (let key in data) {
|
|
@@ -107,6 +158,7 @@ class Guild {
|
|
|
107
158
|
}
|
|
108
159
|
this.updatedAt = new Date();
|
|
109
160
|
this.rest.guilds.cache.set(this.id, this);
|
|
161
|
+
this.rest.emit("guildUpdate", this);
|
|
110
162
|
return this;
|
|
111
163
|
}
|
|
112
164
|
async fetch() {
|
|
@@ -160,9 +212,7 @@ class Guild {
|
|
|
160
212
|
url: route,
|
|
161
213
|
payload,
|
|
162
214
|
});
|
|
163
|
-
this.
|
|
164
|
-
this.rest.guilds.cache.set(this.id, this);
|
|
165
|
-
this.rest.emit("guildUpdate", this);
|
|
215
|
+
this._updateInternals(response);
|
|
166
216
|
return this;
|
|
167
217
|
}
|
|
168
218
|
async removePrice(price) {
|
|
@@ -188,51 +238,68 @@ class Guild {
|
|
|
188
238
|
url: route,
|
|
189
239
|
payload,
|
|
190
240
|
});
|
|
191
|
-
this.
|
|
192
|
-
this.rest.guilds.cache.set(this.id, this);
|
|
193
|
-
this.rest.emit("guildUpdate", this);
|
|
241
|
+
this._updateInternals(response);
|
|
194
242
|
return this;
|
|
195
243
|
}
|
|
196
|
-
async
|
|
244
|
+
async toggleDailyCategory(category) {
|
|
197
245
|
Assertion_1.Assertion.assertString(category);
|
|
198
|
-
|
|
199
|
-
const
|
|
246
|
+
let categories = this.daily_categories;
|
|
247
|
+
const returnCategories = () => {
|
|
248
|
+
const isCategoryOn = categories.includes(category);
|
|
249
|
+
if (isCategoryOn)
|
|
250
|
+
categories = categories.filter((m) => m !== category);
|
|
251
|
+
else
|
|
252
|
+
categories = [...categories, category];
|
|
253
|
+
return categories;
|
|
254
|
+
};
|
|
255
|
+
const _categories = returnCategories();
|
|
256
|
+
const payload = { daily_categories: _categories };
|
|
257
|
+
const route = Routes_1.Routes.guilds.get(this.id);
|
|
200
258
|
const response = await this.rest.request({
|
|
201
|
-
method: "
|
|
259
|
+
method: "patch",
|
|
202
260
|
url: route,
|
|
203
261
|
payload,
|
|
204
262
|
});
|
|
205
|
-
this.
|
|
206
|
-
this.rest.guilds.cache.set(this.id, this);
|
|
207
|
-
this.rest.emit("guildUpdate", this);
|
|
263
|
+
this._updateInternals(response);
|
|
208
264
|
return this;
|
|
209
265
|
}
|
|
210
|
-
async
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
const payload = {
|
|
266
|
+
async setScores(name, amount) {
|
|
267
|
+
const route = Routes_1.Routes.guilds.get(this.id);
|
|
268
|
+
let scores = this.scores;
|
|
269
|
+
scores[name] = amount;
|
|
270
|
+
const payload = { scores };
|
|
215
271
|
const response = await this.rest.request({
|
|
216
|
-
method: "
|
|
272
|
+
method: "patch",
|
|
217
273
|
url: route,
|
|
218
274
|
payload,
|
|
219
275
|
});
|
|
220
|
-
this.
|
|
221
|
-
this.rest.guilds.cache.set(this.id, this);
|
|
222
|
-
this.rest.emit("guildUpdate", this);
|
|
276
|
+
this._updateInternals(response);
|
|
223
277
|
return this;
|
|
224
278
|
}
|
|
225
|
-
async
|
|
226
|
-
const route = Routes_1.Routes.
|
|
227
|
-
|
|
279
|
+
async toggleMode(mode) {
|
|
280
|
+
const route = Routes_1.Routes.guilds.get(this.id);
|
|
281
|
+
let modes = this.modes;
|
|
282
|
+
const returnModes = () => {
|
|
283
|
+
const isModeOn = modes.on.includes(mode);
|
|
284
|
+
if (isModeOn) {
|
|
285
|
+
modes.on = modes.on.filter((m) => m !== mode);
|
|
286
|
+
modes.off.push(mode);
|
|
287
|
+
return modes;
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
modes.off = modes.off.filter((m) => m !== mode);
|
|
291
|
+
modes.on.push(mode);
|
|
292
|
+
return modes;
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
const md = returnModes();
|
|
296
|
+
const payload = { modes: md };
|
|
228
297
|
const response = await this.rest.request({
|
|
229
298
|
method: "patch",
|
|
230
299
|
url: route,
|
|
231
300
|
payload,
|
|
232
301
|
});
|
|
233
|
-
this.
|
|
234
|
-
this.rest.guilds.cache.set(this.id, this);
|
|
235
|
-
this.rest.emit("guildUpdate", this);
|
|
302
|
+
this._updateInternals(response);
|
|
236
303
|
return this;
|
|
237
304
|
}
|
|
238
305
|
}
|
package/dist/structures/index.js
CHANGED
|
@@ -19,4 +19,5 @@ __exportStar(require("./match/GuildMatch"), exports);
|
|
|
19
19
|
__exportStar(require("./user/GuildUser"), exports);
|
|
20
20
|
__exportStar(require("./vipmember/VipMember"), exports);
|
|
21
21
|
__exportStar(require("./ticket/Ticket"), exports);
|
|
22
|
+
__exportStar(require("./minesgame/MinesGame"), exports);
|
|
22
23
|
__exportStar(require("./Collection"), exports);
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.GuildMatch = void 0;
|
|
4
4
|
const Routes_1 = require("../../rest/Routes");
|
|
5
5
|
const Assertion_1 = require("../../utils/Assertion");
|
|
6
|
-
const MessagesManager_1 = require("../../managers/message/MessagesManager");
|
|
7
6
|
class GuildMatch {
|
|
8
7
|
_id;
|
|
9
8
|
selections;
|
|
@@ -56,28 +55,29 @@ class GuildMatch {
|
|
|
56
55
|
constructor(data, manager) {
|
|
57
56
|
this._id = data?._id;
|
|
58
57
|
this.guild_id = data?.guild_id;
|
|
59
|
-
this.selections = data?.selections;
|
|
60
58
|
this.manager = manager;
|
|
61
59
|
this.guild = manager.guild;
|
|
62
60
|
this.rest = manager.rest;
|
|
63
61
|
this.challenge = data?.challenge;
|
|
64
|
-
this.
|
|
65
|
-
this.
|
|
66
|
-
this.
|
|
62
|
+
this.players = data?.players;
|
|
63
|
+
this.messages = data?.messages;
|
|
64
|
+
this.channels = data?.channels;
|
|
67
65
|
this.type = data?.type;
|
|
68
66
|
this.status = data?.status;
|
|
69
|
-
this.
|
|
70
|
-
this.players = data?.players;
|
|
67
|
+
this.mvps = data?.mvps;
|
|
71
68
|
this.winners = data?.winners;
|
|
72
69
|
this.losers = data?.losers;
|
|
70
|
+
this.maximumSize = data?.maximumSize;
|
|
71
|
+
this.kickedOut = data?.kickedOut;
|
|
72
|
+
this.confirmed = data?.confirmed;
|
|
73
|
+
this.teams = data?.teams;
|
|
74
|
+
this.leaders = data?.leaders;
|
|
73
75
|
this.creatorId = data?.creatorId;
|
|
74
76
|
this.roomCreatorId = data?.roomCreatorId;
|
|
75
|
-
this.
|
|
76
|
-
this.mvps = data?.mvps;
|
|
77
|
+
this.selections = data?.selections;
|
|
77
78
|
this.key = "matches";
|
|
78
79
|
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
|
|
79
80
|
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
|
|
80
|
-
this.messages = new MessagesManager_1.MessagesManager(this, Routes_1.Routes.guilds.matches.resource(data.guild_id, this._id, "messages"));
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
83
|
* Fetches the match
|
|
@@ -133,11 +133,7 @@ class GuildMatch {
|
|
|
133
133
|
url: route,
|
|
134
134
|
payload: set,
|
|
135
135
|
});
|
|
136
|
-
this.
|
|
137
|
-
this.rest.matches.set(this._id, this);
|
|
138
|
-
this.manager.cache.set(this._id, this);
|
|
139
|
-
this.guild.buffer.matches.set(this._id, this);
|
|
140
|
-
return this;
|
|
136
|
+
return this._updateInternals(response);
|
|
141
137
|
}
|
|
142
138
|
async setStatus(status) {
|
|
143
139
|
Assertion_1.Assertion.assertString(status);
|
|
@@ -148,12 +144,7 @@ class GuildMatch {
|
|
|
148
144
|
url: route,
|
|
149
145
|
payload,
|
|
150
146
|
});
|
|
151
|
-
this.
|
|
152
|
-
this.status = response.status;
|
|
153
|
-
this.rest.matches.set(this._id, this);
|
|
154
|
-
this.manager.cache.set(this._id, this);
|
|
155
|
-
this.guild.buffer.matches.set(this._id, this);
|
|
156
|
-
return this;
|
|
147
|
+
return this._updateInternals(response);
|
|
157
148
|
}
|
|
158
149
|
async setWinners(players) {
|
|
159
150
|
if (!Array.isArray(players))
|
|
@@ -165,12 +156,7 @@ class GuildMatch {
|
|
|
165
156
|
url: route,
|
|
166
157
|
payload,
|
|
167
158
|
});
|
|
168
|
-
this.
|
|
169
|
-
this.winners = response.winners;
|
|
170
|
-
this.rest.matches.set(this._id, this);
|
|
171
|
-
this.manager.cache.set(this._id, this);
|
|
172
|
-
this.guild.buffer.matches.set(this._id, this);
|
|
173
|
-
return this;
|
|
159
|
+
return this._updateInternals(response);
|
|
174
160
|
}
|
|
175
161
|
async setLoser(players) {
|
|
176
162
|
if (!Array.isArray(players))
|
|
@@ -182,12 +168,7 @@ class GuildMatch {
|
|
|
182
168
|
url: route,
|
|
183
169
|
payload,
|
|
184
170
|
});
|
|
185
|
-
this.
|
|
186
|
-
this.losers = response.losers;
|
|
187
|
-
this.rest.matches.set(this._id, this);
|
|
188
|
-
this.manager.cache.set(this._id, this);
|
|
189
|
-
this.guild.buffer.matches.set(this._id, this);
|
|
190
|
-
return this;
|
|
171
|
+
return this._updateInternals(response);
|
|
191
172
|
}
|
|
192
173
|
async setMvps(...usersId) {
|
|
193
174
|
const payload = { set: usersId };
|
|
@@ -197,12 +178,7 @@ class GuildMatch {
|
|
|
197
178
|
url: route,
|
|
198
179
|
payload,
|
|
199
180
|
});
|
|
200
|
-
this.
|
|
201
|
-
this.mvps = response.mvps;
|
|
202
|
-
this.rest.matches.set(this._id, this);
|
|
203
|
-
this.manager.cache.set(this._id, this);
|
|
204
|
-
this.guild.buffer.matches.set(this._id, this);
|
|
205
|
-
return this;
|
|
181
|
+
return this._updateInternals(response);
|
|
206
182
|
}
|
|
207
183
|
async setRoomCreatorId(userId) {
|
|
208
184
|
Assertion_1.Assertion.assertString(userId);
|
|
@@ -213,12 +189,7 @@ class GuildMatch {
|
|
|
213
189
|
url: route,
|
|
214
190
|
payload,
|
|
215
191
|
});
|
|
216
|
-
this.
|
|
217
|
-
this.roomCreatorId = response.roomCreatorId;
|
|
218
|
-
this.rest.matches.set(this._id, this);
|
|
219
|
-
this.manager.cache.set(this._id, this);
|
|
220
|
-
this.guild.buffer.matches.set(this._id, this);
|
|
221
|
-
return this;
|
|
192
|
+
return this._updateInternals(response);
|
|
222
193
|
}
|
|
223
194
|
async kick(player) {
|
|
224
195
|
const payload = { set: player };
|
|
@@ -228,12 +199,7 @@ class GuildMatch {
|
|
|
228
199
|
url: route,
|
|
229
200
|
payload,
|
|
230
201
|
});
|
|
231
|
-
this.
|
|
232
|
-
this.kickedOut = response.kickedOut;
|
|
233
|
-
this.rest.matches.set(this._id, this);
|
|
234
|
-
this.manager.cache.set(this._id, this);
|
|
235
|
-
this.guild.buffer.matches.set(this._id, this);
|
|
236
|
-
return this;
|
|
202
|
+
return this._updateInternals(response);
|
|
237
203
|
}
|
|
238
204
|
async update(data) {
|
|
239
205
|
const route = Routes_1.Routes.guilds.matches.get(this.guild.id, this._id);
|
|
@@ -243,29 +209,7 @@ class GuildMatch {
|
|
|
243
209
|
payload: data,
|
|
244
210
|
});
|
|
245
211
|
this.rest.emit("matchUpdate", this, new GuildMatch(response, this.manager));
|
|
246
|
-
|
|
247
|
-
if (k === "id" || k == "createdAt")
|
|
248
|
-
continue;
|
|
249
|
-
if (Object.hasOwn(this, k)) {
|
|
250
|
-
/* if (k === "channels") {
|
|
251
|
-
({ chs: response["channels"] });
|
|
252
|
-
this.channels.setAll(response["channels"]);
|
|
253
|
-
({ chs2: this.channels.cache });
|
|
254
|
-
continue;
|
|
255
|
-
}
|
|
256
|
-
*/
|
|
257
|
-
if (k === "messages") {
|
|
258
|
-
this.messages.setAll(response["messages"]);
|
|
259
|
-
continue;
|
|
260
|
-
}
|
|
261
|
-
this[k] = response[k];
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
this.updatedAt = new Date();
|
|
265
|
-
this.manager.cache.set(this._id, this);
|
|
266
|
-
this.rest.matches.set(this._id, this);
|
|
267
|
-
this.guild.buffer.matches.set(this._id, this);
|
|
268
|
-
return this;
|
|
212
|
+
return this._updateInternals(response);
|
|
269
213
|
}
|
|
270
214
|
async delete() {
|
|
271
215
|
const route = Routes_1.Routes.guilds.matches.resource(this.guild.id, this._id);
|
|
@@ -286,5 +230,19 @@ class GuildMatch {
|
|
|
286
230
|
}
|
|
287
231
|
return json;
|
|
288
232
|
}
|
|
233
|
+
_updateInternals(data) {
|
|
234
|
+
for (let key in data) {
|
|
235
|
+
if (key === "id" || key === "createdAt")
|
|
236
|
+
continue;
|
|
237
|
+
if (key in this) {
|
|
238
|
+
this[key] = data[key];
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
this.updatedAt = new Date();
|
|
242
|
+
this.manager.cache.set(this._id, this);
|
|
243
|
+
this.rest.matches.set(this._id, this);
|
|
244
|
+
this.guild.buffer.matches.set(this._id, this);
|
|
245
|
+
return this;
|
|
246
|
+
}
|
|
289
247
|
}
|
|
290
248
|
exports.GuildMatch = GuildMatch;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MinesGame = void 0;
|
|
4
|
+
const rest_1 = require("../../rest");
|
|
5
|
+
class MinesGame {
|
|
6
|
+
guild_id;
|
|
7
|
+
_id;
|
|
8
|
+
creatorId;
|
|
9
|
+
maxMines;
|
|
10
|
+
bombs;
|
|
11
|
+
bombsPosition;
|
|
12
|
+
bet;
|
|
13
|
+
multiplier;
|
|
14
|
+
status;
|
|
15
|
+
createdAt;
|
|
16
|
+
updatedAt;
|
|
17
|
+
rest;
|
|
18
|
+
manager;
|
|
19
|
+
constructor(data, manager) {
|
|
20
|
+
this.manager = manager;
|
|
21
|
+
this.rest = manager.rest;
|
|
22
|
+
this.guild_id = data?.guild_id;
|
|
23
|
+
this.bombsPosition = data?.bombsPosition;
|
|
24
|
+
this._id = data?._id;
|
|
25
|
+
this.multiplier = data?.multiplier;
|
|
26
|
+
this.creatorId = data?.creatorId;
|
|
27
|
+
this.maxMines = data?.maxMines;
|
|
28
|
+
this.bombs = data?.bombs;
|
|
29
|
+
this.bet = data?.bet;
|
|
30
|
+
this.status = data?.status;
|
|
31
|
+
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
|
|
32
|
+
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
|
|
33
|
+
}
|
|
34
|
+
async fetch() {
|
|
35
|
+
const route = `/${rest_1.Routes.fields("minesgames", this._id)}`;
|
|
36
|
+
const response = await this.rest.request({
|
|
37
|
+
method: "GET",
|
|
38
|
+
url: route,
|
|
39
|
+
});
|
|
40
|
+
return this._updateInternals(response);
|
|
41
|
+
}
|
|
42
|
+
async delete() {
|
|
43
|
+
const route = `/${rest_1.Routes.fields("minesgames", this._id)}`;
|
|
44
|
+
const response = await this.rest.request({
|
|
45
|
+
method: "delete",
|
|
46
|
+
url: route,
|
|
47
|
+
});
|
|
48
|
+
return this._updateInternals(response);
|
|
49
|
+
}
|
|
50
|
+
async update(data) {
|
|
51
|
+
const route = `/${rest_1.Routes.fields("minesgames", this._id)}`;
|
|
52
|
+
const response = await this.rest.request({
|
|
53
|
+
method: "PATCH",
|
|
54
|
+
url: route,
|
|
55
|
+
payload: data,
|
|
56
|
+
});
|
|
57
|
+
return this._updateInternals(response);
|
|
58
|
+
}
|
|
59
|
+
_updateInternals(data) {
|
|
60
|
+
for (let key in data) {
|
|
61
|
+
if (key === "id" || key === "createdAt")
|
|
62
|
+
continue;
|
|
63
|
+
if (key in this) {
|
|
64
|
+
this[key] = data[key];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
this.updatedAt = new Date();
|
|
68
|
+
this.manager.set(this);
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.MinesGame = MinesGame;
|
|
@@ -6,8 +6,6 @@ class GuildUser {
|
|
|
6
6
|
/** User's id */
|
|
7
7
|
id;
|
|
8
8
|
guild_id;
|
|
9
|
-
/** User name */
|
|
10
|
-
name;
|
|
11
9
|
/** User's daily */
|
|
12
10
|
daily;
|
|
13
11
|
/** User's points */
|
|
@@ -26,6 +24,7 @@ class GuildUser {
|
|
|
26
24
|
accessories;
|
|
27
25
|
/** User's original channels */
|
|
28
26
|
original_channels;
|
|
27
|
+
profile;
|
|
29
28
|
creations;
|
|
30
29
|
/** User's items */
|
|
31
30
|
items;
|
|
@@ -48,20 +47,18 @@ class GuildUser {
|
|
|
48
47
|
this.guild_id = data?.guild_id;
|
|
49
48
|
this.manager = manager;
|
|
50
49
|
this.rest = manager.rest;
|
|
51
|
-
this.name = data?.name;
|
|
52
50
|
this.wins = data?.wins;
|
|
53
|
-
this.creations = data?.creations;
|
|
54
51
|
this.losses = data?.losses;
|
|
55
|
-
this.blacklist = data?.blacklist;
|
|
56
|
-
this.items = data?.items;
|
|
57
|
-
this.points = data?.points;
|
|
58
52
|
this.mvps = data?.mvps;
|
|
53
|
+
this.points = data?.points;
|
|
54
|
+
this.creations = data?.creations;
|
|
55
|
+
this.daily = data?.daily;
|
|
59
56
|
this.games = data?.games;
|
|
60
|
-
this.
|
|
61
|
-
this.original_channels = data?.original_channels;
|
|
57
|
+
this.blacklist = data?.blacklist;
|
|
62
58
|
this.accessories = data?.accessories;
|
|
59
|
+
this.original_channels = data?.original_channels;
|
|
63
60
|
this.items = data?.items;
|
|
64
|
-
this.
|
|
61
|
+
this.profile = data?.profile;
|
|
65
62
|
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
|
|
66
63
|
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
|
|
67
64
|
}
|
|
@@ -154,7 +151,7 @@ class GuildUser {
|
|
|
154
151
|
if (!data?.type)
|
|
155
152
|
data.type = "add";
|
|
156
153
|
const route = Routes_1.Routes.guilds.users.get(this.manager.guild.id, this.id);
|
|
157
|
-
|
|
154
|
+
let payload = {};
|
|
158
155
|
const numericFields = ["coins", "wins", "points", "losses", "mvps", "games"];
|
|
159
156
|
const arrayFields = ["items", "original_channels"];
|
|
160
157
|
if (data?.type === "add" || data?.type === "remove") {
|
|
@@ -165,11 +162,14 @@ class GuildUser {
|
|
|
165
162
|
if (numericFields.includes(key)) {
|
|
166
163
|
const current = this[key];
|
|
167
164
|
const num = value;
|
|
168
|
-
payload[key] = Math.max(0, data?.type === "add" ? current + num :
|
|
165
|
+
payload[key] = Math.max(0, data?.type === "add" ? current + num : current - num);
|
|
169
166
|
}
|
|
170
167
|
else if (key === "blacklist") {
|
|
171
168
|
payload["blacklist"] = value;
|
|
172
169
|
}
|
|
170
|
+
else if (key === "profile") {
|
|
171
|
+
payload["profile"] = value;
|
|
172
|
+
}
|
|
173
173
|
else if (arrayFields.includes(key)) {
|
|
174
174
|
if (key === "original_channels") {
|
|
175
175
|
const current = this.original_channels;
|
|
@@ -224,8 +224,11 @@ class GuildUser {
|
|
|
224
224
|
return response;
|
|
225
225
|
}
|
|
226
226
|
toJSON() {
|
|
227
|
-
let json;
|
|
227
|
+
let json = {};
|
|
228
228
|
for (const [key, value] of Object.entries(this)) {
|
|
229
|
+
const exclude = ["rest", "guilds", "manager"];
|
|
230
|
+
if (exclude.includes(key))
|
|
231
|
+
continue;
|
|
229
232
|
if (typeof value !== "function") {
|
|
230
233
|
json[key] = value;
|
|
231
234
|
}
|
|
@@ -1,2 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GuildChannelsType = void 0;
|
|
4
|
+
var GuildChannelsType;
|
|
5
|
+
(function (GuildChannelsType) {
|
|
6
|
+
GuildChannelsType["DailyRank"] = "daily_rank";
|
|
7
|
+
GuildChannelsType["Commands"] = "command";
|
|
8
|
+
GuildChannelsType["Blacklist"] = "blacklist";
|
|
9
|
+
GuildChannelsType["Queues"] = "queue";
|
|
10
|
+
GuildChannelsType["VipMemebers"] = "vipmembers_category";
|
|
11
|
+
GuildChannelsType["QueueLogs"] = "queue_logs";
|
|
12
|
+
GuildChannelsType["UserLogs"] = "user_logs";
|
|
13
|
+
GuildChannelsType["ManagingLogs"] = "managing_logs";
|
|
14
|
+
GuildChannelsType["NormalQueue"] = "normal_queue";
|
|
15
|
+
GuildChannelsType["ChallengeQueue"] = "challenge_queue";
|
|
16
|
+
GuildChannelsType["MatchTextChannelParent"] = "match_text_channel_parent";
|
|
17
|
+
GuildChannelsType["VoiceChannelMatchCreation"] = "voice_channel_match_creation";
|
|
18
|
+
})(GuildChannelsType || (exports.GuildChannelsType = GuildChannelsType = {}));
|