@duque.edits/sdk 0.2.0 → 0.2.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.
package/dist/rest/REST.js
CHANGED
|
@@ -53,15 +53,6 @@ class REST extends events_1.default {
|
|
|
53
53
|
await Promise.all([this.guilds.fetch(), this.minesGames.fetch()]);
|
|
54
54
|
return this;
|
|
55
55
|
}
|
|
56
|
-
/**
|
|
57
|
-
* Ping the api
|
|
58
|
-
*/
|
|
59
|
-
async ping() {
|
|
60
|
-
return this.request({
|
|
61
|
-
url: "/status",
|
|
62
|
-
method: "get",
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
56
|
/**
|
|
66
57
|
* Request Data from a certain url
|
|
67
58
|
* @param options
|
|
@@ -164,6 +164,29 @@ class Guild {
|
|
|
164
164
|
});
|
|
165
165
|
return this._updateInternals(response);
|
|
166
166
|
}
|
|
167
|
+
async setChannelIds(type, ...ids) {
|
|
168
|
+
const channel = this.channels.find((c) => c.type === type);
|
|
169
|
+
if (!ids || ids.length === 0)
|
|
170
|
+
return;
|
|
171
|
+
if (!channel) {
|
|
172
|
+
// create new channel if it doesn't exist
|
|
173
|
+
this.channels.push({ type, ids });
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
// merge IDs, remove duplicates
|
|
177
|
+
const chIndex = this.channels.findIndex((ch) => ch.type === type);
|
|
178
|
+
const mergedIds = [...new Set([...ids])];
|
|
179
|
+
this.channels[chIndex] = { ...channel, ids: mergedIds };
|
|
180
|
+
}
|
|
181
|
+
const route = Routes_1.Routes.guilds.get(this.id);
|
|
182
|
+
const payload = { channels: this.channels };
|
|
183
|
+
const response = await this.rest.request({
|
|
184
|
+
method: "PATCH",
|
|
185
|
+
url: route,
|
|
186
|
+
payload,
|
|
187
|
+
});
|
|
188
|
+
return this._updateInternals(response);
|
|
189
|
+
}
|
|
167
190
|
async removeIdInChannel(type, id) {
|
|
168
191
|
const chIndex = this.channels.findIndex((c) => c.type === type);
|
|
169
192
|
if (chIndex !== -1) {
|
|
@@ -220,15 +220,15 @@ class GuildUser {
|
|
|
220
220
|
const route = Routes_1.Routes.guilds.users.get(this.manager.guild.id, this.id);
|
|
221
221
|
let payload = {};
|
|
222
222
|
const numericFields = ["wins", "points", "losses", "mvps", "games", "creations"];
|
|
223
|
-
const arrayFields = ["items", "original_channels"];
|
|
223
|
+
const arrayFields = ["items", "original_channels", "adverts"];
|
|
224
224
|
if (data?.type === "add" || data?.type === "remove") {
|
|
225
225
|
for (const key in data) {
|
|
226
226
|
if (key === "type")
|
|
227
227
|
continue;
|
|
228
228
|
const value = data[key];
|
|
229
229
|
if (numericFields.includes(key)) {
|
|
230
|
-
const current = this[key];
|
|
231
|
-
const num = value;
|
|
230
|
+
const current = (this[key] || 0);
|
|
231
|
+
const num = (value || 0);
|
|
232
232
|
payload[key] = Math.max(0, data?.type === "add" ? current + num : current - num);
|
|
233
233
|
}
|
|
234
234
|
else if (key === "blacklist") {
|
package/package.json
CHANGED
package/types/rest/REST.d.ts
CHANGED
|
@@ -31,10 +31,6 @@ export declare class REST extends EventEmitter {
|
|
|
31
31
|
constructor(options: ClientOptions);
|
|
32
32
|
/** Initialize the caching sistem */
|
|
33
33
|
init(): Promise<this>;
|
|
34
|
-
/**
|
|
35
|
-
* Ping the api
|
|
36
|
-
*/
|
|
37
|
-
ping(): Promise<unknown>;
|
|
38
34
|
/**
|
|
39
35
|
* Request Data from a certain url
|
|
40
36
|
* @param options
|
|
@@ -55,6 +55,7 @@ export declare class Guild {
|
|
|
55
55
|
createCode(data: Optional<APICode>): Promise<this>;
|
|
56
56
|
removeCode(codeId: string): Promise<this>;
|
|
57
57
|
addIdToChannel(type: GuildChannelsType, id: string | string[]): Promise<this>;
|
|
58
|
+
setChannelIds(type: GuildChannelsType, ...ids: string[]): Promise<this>;
|
|
58
59
|
removeIdInChannel(type: GuildChannelsType, id: string): Promise<this>;
|
|
59
60
|
_start(): Promise<this>;
|
|
60
61
|
_updateInternals(data: Optional<APIGuild>): this;
|