@duque.edits/sdk 0.1.8 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/managers/permission/GuildPermissionManager.js +13 -11
- package/dist/rest/REST.js +3 -0
- package/dist/rest/Routes.js +2 -2
- package/dist/structures/guild/Guild.js +81 -1
- package/dist/structures/user/GuildUser.js +69 -12
- package/dist/types/api/APIAdvert.js +2 -0
- package/dist/types/api/APICode.js +2 -0
- package/dist/types/api/APIGuildAdvert.js +2 -0
- package/dist/types/api/APIGuildMatch.js +1 -0
- package/dist/types/api/APIGuildPermissions.js +5 -0
- package/dist/types/api/index.js +3 -0
- package/package.json +1 -2
- package/types/managers/permission/GuildPermissionManager.d.ts +3 -3
- package/types/rest/REST.d.ts +2 -0
- package/types/rest/Routes.d.ts +1 -1
- package/types/structures/guild/Guild.d.ts +7 -1
- package/types/structures/user/GuildUser.d.ts +5 -1
- package/types/types/api/APIAdvert.d.ts +11 -0
- package/types/types/api/APICode.d.ts +10 -0
- package/types/types/api/APIGuild.d.ts +4 -1
- package/types/types/api/APIGuildAdvert.d.ts +8 -0
- package/types/types/api/APIGuildMatch.d.ts +2 -1
- package/types/types/api/APIGuildPermissions.d.ts +7 -5
- package/types/types/api/APIGuildUser.d.ts +2 -1
- package/types/types/api/index.d.ts +18 -0
|
@@ -10,12 +10,13 @@ class GuildPermissionManager extends base_1.BaseManager {
|
|
|
10
10
|
this.rest = guild.rest;
|
|
11
11
|
this.base_url = Routes_1.Routes.guilds.resource(guild.id, "permissions");
|
|
12
12
|
}
|
|
13
|
-
async addRole(
|
|
14
|
-
const perm = this.guild.permissions[
|
|
15
|
-
if (perm.includes(roleId))
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
async addRole(type, roleId) {
|
|
14
|
+
const perm = this.guild.permissions.find((p) => p.type === type) || { ids: [roleId], type };
|
|
15
|
+
// if (perm.ids.includes(roleId)) return this.guild;
|
|
16
|
+
perm.ids.push(roleId);
|
|
17
|
+
const perms = { ...this.guild.permissions };
|
|
18
|
+
let permsIndex = this.guild.permissions.findIndex((p) => p.type === type);
|
|
19
|
+
perms[permsIndex] = perm;
|
|
19
20
|
const payload = { set: perms };
|
|
20
21
|
const response = await this.rest.request({
|
|
21
22
|
method: "PATCH",
|
|
@@ -26,13 +27,14 @@ class GuildPermissionManager extends base_1.BaseManager {
|
|
|
26
27
|
this.rest.guilds.cache.set(this.guild.id, this.guild);
|
|
27
28
|
return response;
|
|
28
29
|
}
|
|
29
|
-
async removeRole(
|
|
30
|
-
|
|
31
|
-
if (!perm.includes(roleId))
|
|
30
|
+
async removeRole(type, roleId) {
|
|
31
|
+
const perm = this.guild.permissions.find((p) => p.type === type) || { ids: [], type };
|
|
32
|
+
if (!perm.ids.includes(roleId))
|
|
32
33
|
return this.guild;
|
|
33
|
-
perm = perm.filter((i) => i !== roleId);
|
|
34
|
+
perm.ids = perm.ids.filter((i) => i !== roleId);
|
|
34
35
|
let perms = { ...this.guild.permissions };
|
|
35
|
-
|
|
36
|
+
let permsIndex = this.guild.permissions.findIndex((p) => p.type === type);
|
|
37
|
+
perms[permsIndex] = perm;
|
|
36
38
|
const payload = { set: perms };
|
|
37
39
|
const response = await this.rest.request({
|
|
38
40
|
method: "PATCH",
|
package/dist/rest/REST.js
CHANGED
|
@@ -100,6 +100,9 @@ class REST extends events_1.default {
|
|
|
100
100
|
this.emit("debug", `[Request]${FgGreen} ${(now - before) / 1000}s done.${Reset}`);
|
|
101
101
|
return data;
|
|
102
102
|
}
|
|
103
|
+
async getStatus() {
|
|
104
|
+
return await this.request({ method: "GET", url: "/status" });
|
|
105
|
+
}
|
|
103
106
|
emit(event, ...args // tuple type is spread automatically
|
|
104
107
|
) {
|
|
105
108
|
return super.emit(event, ...args);
|
package/dist/rest/Routes.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Routes = void 0;
|
|
4
4
|
exports.Routes = {
|
|
5
|
-
//
|
|
5
|
+
//base: "http://localhost:80/api/v1",
|
|
6
6
|
base: "https://dpqd.shardweb.app/api/v1",
|
|
7
7
|
field: (field) => `/${field}`,
|
|
8
8
|
fields: (...fields) => `${fields.join("/")}`,
|
|
@@ -21,7 +21,7 @@ exports.Routes = {
|
|
|
21
21
|
get: (guildId, userId) => `/guilds/${guildId}/users/${userId}`,
|
|
22
22
|
delete: (guildId, userId) => `/guilds/${guildId}/users/${userId}`,
|
|
23
23
|
deleteAll: (guildId) => `/guilds/${guildId}/users`,
|
|
24
|
-
resource: (guildId, userId, resource) => `/guilds/${guildId}/users/${userId}/${resource}`,
|
|
24
|
+
resource: (guildId, userId, ...resource) => `/guilds/${guildId}/users/${userId}/${resource.join("/")}`,
|
|
25
25
|
},
|
|
26
26
|
betUsers: {
|
|
27
27
|
getAll: (guildId) => `/guilds/${guildId}/betusers`,
|
|
@@ -43,6 +43,8 @@ class Guild {
|
|
|
43
43
|
users;
|
|
44
44
|
logEntries;
|
|
45
45
|
shop;
|
|
46
|
+
adverts;
|
|
47
|
+
codes;
|
|
46
48
|
/**
|
|
47
49
|
* The guild structure
|
|
48
50
|
* @param data The guild's data
|
|
@@ -58,6 +60,7 @@ class Guild {
|
|
|
58
60
|
this.modes = data?.modes;
|
|
59
61
|
this.prices = data?.prices;
|
|
60
62
|
this.scores = data?.scores;
|
|
63
|
+
this.codes = data?.codes;
|
|
61
64
|
this.prefix = data?.prefix;
|
|
62
65
|
this.status = data?.status;
|
|
63
66
|
this.tickets_configuration = data?.tickets_configuration;
|
|
@@ -72,6 +75,30 @@ class Guild {
|
|
|
72
75
|
this.tickets = new managers_1.GuildTicketManager(this);
|
|
73
76
|
this.vipMembers = new managers_1.VipMemberManager(this);
|
|
74
77
|
this.logEntries = new managers_1.LogManager(this);
|
|
78
|
+
this.adverts = [];
|
|
79
|
+
for (let _adv of data?.adverts || []) {
|
|
80
|
+
this.adverts.push({
|
|
81
|
+
_id: _adv._id,
|
|
82
|
+
admin_id: _adv.admin_id,
|
|
83
|
+
points_to_remove: _adv.points_to_remove,
|
|
84
|
+
role_id: _adv.role_id,
|
|
85
|
+
createdAt: _adv.createdAt ? new Date(_adv.createdAt) : new Date(),
|
|
86
|
+
updatedAt: _adv.updatedAt ? new Date(_adv.updatedAt) : new Date(),
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
this.codes = [];
|
|
90
|
+
for (let _adv of data?.codes || []) {
|
|
91
|
+
this.codes.push({
|
|
92
|
+
_id: _adv._id,
|
|
93
|
+
admin_id: _adv.admin_id,
|
|
94
|
+
type: _adv.type,
|
|
95
|
+
add: _adv.add,
|
|
96
|
+
code: _adv.code,
|
|
97
|
+
expire: _adv.expire ? new Date(_adv.expire) : new Date(),
|
|
98
|
+
createdAt: _adv.createdAt ? new Date(_adv.createdAt) : new Date(),
|
|
99
|
+
updatedAt: _adv.updatedAt ? new Date(_adv.updatedAt) : new Date(),
|
|
100
|
+
});
|
|
101
|
+
}
|
|
75
102
|
}
|
|
76
103
|
async getChannel(type) {
|
|
77
104
|
const channel = this.channels.find((c) => c.type === type);
|
|
@@ -88,7 +115,32 @@ class Guild {
|
|
|
88
115
|
this._updateInternals(response);
|
|
89
116
|
return response.channels.find((t) => t.type === type);
|
|
90
117
|
}
|
|
91
|
-
|
|
118
|
+
}
|
|
119
|
+
async createAdvert(data) {
|
|
120
|
+
this.adverts.push(data);
|
|
121
|
+
const route = Routes_1.Routes.guilds.get(this.id);
|
|
122
|
+
const payload = { adverts: this.adverts };
|
|
123
|
+
const response = await this.rest.request({ method: "PATCH", url: route, payload });
|
|
124
|
+
return this._updateInternals(response);
|
|
125
|
+
}
|
|
126
|
+
async removeAdvert(advertId) {
|
|
127
|
+
const route = Routes_1.Routes.guilds.get(this.id);
|
|
128
|
+
const payload = { adverts: this.adverts.filter((a) => a._id !== advertId) };
|
|
129
|
+
const response = await this.rest.request({ method: "PATCH", url: route, payload });
|
|
130
|
+
return this._updateInternals(response);
|
|
131
|
+
}
|
|
132
|
+
async createCode(data) {
|
|
133
|
+
this.codes.push(data);
|
|
134
|
+
const route = Routes_1.Routes.guilds.get(this.id);
|
|
135
|
+
const payload = { codes: this.codes };
|
|
136
|
+
const response = await this.rest.request({ method: "PATCH", url: route, payload });
|
|
137
|
+
return this._updateInternals(response);
|
|
138
|
+
}
|
|
139
|
+
async removeCode(codeId) {
|
|
140
|
+
const route = Routes_1.Routes.guilds.get(this.id);
|
|
141
|
+
const payload = { codes: this.codes.filter((a) => a._id !== codeId) };
|
|
142
|
+
const response = await this.rest.request({ method: "PATCH", url: route, payload });
|
|
143
|
+
return this._updateInternals(response);
|
|
92
144
|
}
|
|
93
145
|
async addIdToChannel(type, id) {
|
|
94
146
|
const channel = this.channels.find((c) => c.type === type);
|
|
@@ -155,6 +207,34 @@ class Guild {
|
|
|
155
207
|
if (key in this) {
|
|
156
208
|
this[key] = data[key];
|
|
157
209
|
}
|
|
210
|
+
if (key === "adverts") {
|
|
211
|
+
this.adverts = [];
|
|
212
|
+
for (let _adv of data.adverts) {
|
|
213
|
+
this.adverts.push({
|
|
214
|
+
_id: _adv._id,
|
|
215
|
+
admin_id: _adv.admin_id,
|
|
216
|
+
points_to_remove: _adv.points_to_remove,
|
|
217
|
+
role_id: _adv.role_id,
|
|
218
|
+
createdAt: _adv.createdAt ? new Date(_adv.createdAt) : new Date(),
|
|
219
|
+
updatedAt: _adv.updatedAt ? new Date(_adv.updatedAt) : new Date(),
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (key === "code") {
|
|
224
|
+
this.codes = [];
|
|
225
|
+
for (let _adv of data.codes) {
|
|
226
|
+
this.codes.push({
|
|
227
|
+
_id: _adv._id,
|
|
228
|
+
admin_id: _adv.admin_id,
|
|
229
|
+
type: _adv.type,
|
|
230
|
+
add: _adv.add,
|
|
231
|
+
code: _adv.code,
|
|
232
|
+
expire: _adv.expire ? new Date(_adv.expire) : new Date(),
|
|
233
|
+
createdAt: _adv.createdAt ? new Date(_adv.createdAt) : new Date(),
|
|
234
|
+
updatedAt: _adv.updatedAt ? new Date(_adv.updatedAt) : new Date(),
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
}
|
|
158
238
|
}
|
|
159
239
|
this.updatedAt = new Date();
|
|
160
240
|
this.rest.guilds.cache.set(this.id, this);
|
|
@@ -28,6 +28,7 @@ class GuildUser {
|
|
|
28
28
|
creations;
|
|
29
29
|
/** User's items */
|
|
30
30
|
items;
|
|
31
|
+
adverts;
|
|
31
32
|
/** Creation Date */
|
|
32
33
|
createdAt;
|
|
33
34
|
/** Updated Date */
|
|
@@ -61,6 +62,20 @@ class GuildUser {
|
|
|
61
62
|
this.profile = data?.profile;
|
|
62
63
|
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
|
|
63
64
|
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
|
|
65
|
+
this.adverts = [];
|
|
66
|
+
for (let _adv of data?.adverts || []) {
|
|
67
|
+
this.adverts.push({
|
|
68
|
+
_id: _adv._id,
|
|
69
|
+
admin_id: _adv.admin_id,
|
|
70
|
+
role_id: _adv.role_id,
|
|
71
|
+
reason: _adv.reason,
|
|
72
|
+
points_removed: _adv.points_removed,
|
|
73
|
+
proof: _adv.proof,
|
|
74
|
+
proof_ext: _adv.proof_ext,
|
|
75
|
+
createdAt: _adv.createdAt ? new Date(_adv.createdAt) : new Date(),
|
|
76
|
+
updatedAt: _adv.updatedAt ? new Date(_adv.updatedAt) : new Date(),
|
|
77
|
+
});
|
|
78
|
+
}
|
|
64
79
|
}
|
|
65
80
|
/** String representation of this user */
|
|
66
81
|
toString() {
|
|
@@ -129,6 +144,24 @@ class GuildUser {
|
|
|
129
144
|
this._updateInternals(response);
|
|
130
145
|
return this;
|
|
131
146
|
}
|
|
147
|
+
async updateProfile(data) {
|
|
148
|
+
const _data = {
|
|
149
|
+
profile: {
|
|
150
|
+
avatarUrl: data.avatarUrl || this.profile.avatarUrl || "",
|
|
151
|
+
bannerUrl: data.bannerUrl || this.profile.bannerUrl || "",
|
|
152
|
+
bio: data.bio || this.profile.bio || "",
|
|
153
|
+
name: data.name || this.profile.name || "",
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
const route = Routes_1.Routes.guilds.users.update(this.manager.guild.id, this.id);
|
|
157
|
+
const response = await this.rest.request({
|
|
158
|
+
method: "patch",
|
|
159
|
+
url: route,
|
|
160
|
+
payload: _data,
|
|
161
|
+
});
|
|
162
|
+
this._updateInternals(response);
|
|
163
|
+
return this;
|
|
164
|
+
}
|
|
132
165
|
_updateInternals(data) {
|
|
133
166
|
for (let key in data) {
|
|
134
167
|
if (key === "id" || key === "createdAt")
|
|
@@ -136,12 +169,46 @@ class GuildUser {
|
|
|
136
169
|
if (key in this) {
|
|
137
170
|
this[key] = data[key];
|
|
138
171
|
}
|
|
172
|
+
if (key === "adverts") {
|
|
173
|
+
this.adverts = [];
|
|
174
|
+
for (let _adv of data.adverts) {
|
|
175
|
+
this.adverts.push({
|
|
176
|
+
_id: _adv._id,
|
|
177
|
+
admin_id: _adv.admin_id,
|
|
178
|
+
role_id: _adv.role_id,
|
|
179
|
+
reason: _adv.reason,
|
|
180
|
+
points_removed: _adv.points_removed,
|
|
181
|
+
proof: _adv.proof,
|
|
182
|
+
proof_ext: _adv.proof_ext,
|
|
183
|
+
createdAt: _adv.createdAt ? new Date(_adv.createdAt) : new Date(),
|
|
184
|
+
updatedAt: _adv.updatedAt ? new Date(_adv.updatedAt) : new Date(),
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
139
188
|
}
|
|
140
189
|
this.updatedAt = new Date();
|
|
141
190
|
this.createdAt = new Date(data.createdAt);
|
|
142
191
|
this.manager.set(this);
|
|
192
|
+
this.rest.emit("userUpdate", this);
|
|
143
193
|
return this;
|
|
144
194
|
}
|
|
195
|
+
async addAdvert(data) {
|
|
196
|
+
const route = Routes_1.Routes.guilds.users.resource(this.manager.guild.id, this.id, "adverts");
|
|
197
|
+
const payload = data;
|
|
198
|
+
const response = await this.rest.request({ method: "POST", url: route, payload });
|
|
199
|
+
return this._updateInternals(response);
|
|
200
|
+
}
|
|
201
|
+
async removeAdvert(advertId) {
|
|
202
|
+
let advs = this.adverts;
|
|
203
|
+
if (advertId)
|
|
204
|
+
advs = advs.filter((a) => a._id !== advertId);
|
|
205
|
+
else
|
|
206
|
+
advs.pop();
|
|
207
|
+
const payload = { adverts: advs };
|
|
208
|
+
const route = Routes_1.Routes.guilds.users.update(this.manager.guild.id, this.id);
|
|
209
|
+
const response = await this.rest.request({ method: "PATCH", url: route, payload });
|
|
210
|
+
return this._updateInternals(response);
|
|
211
|
+
}
|
|
145
212
|
/**
|
|
146
213
|
* Update certain property
|
|
147
214
|
* @param data The new data to update with
|
|
@@ -152,7 +219,7 @@ class GuildUser {
|
|
|
152
219
|
data.type = "add";
|
|
153
220
|
const route = Routes_1.Routes.guilds.users.get(this.manager.guild.id, this.id);
|
|
154
221
|
let payload = {};
|
|
155
|
-
const numericFields = ["
|
|
222
|
+
const numericFields = ["wins", "points", "losses", "mvps", "games", "creations"];
|
|
156
223
|
const arrayFields = ["items", "original_channels"];
|
|
157
224
|
if (data?.type === "add" || data?.type === "remove") {
|
|
158
225
|
for (const key in data) {
|
|
@@ -200,17 +267,7 @@ class GuildUser {
|
|
|
200
267
|
url: route,
|
|
201
268
|
payload,
|
|
202
269
|
});
|
|
203
|
-
|
|
204
|
-
if (k === "id")
|
|
205
|
-
continue;
|
|
206
|
-
if (Object.hasOwn(this, k)) {
|
|
207
|
-
this[k] = response[k];
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
this.updatedAt = response?.updatedAt ? new Date(response?.updatedAt) : new Date();
|
|
211
|
-
this.createdAt = response?.createdAt ? new Date(response?.createdAt) : new Date();
|
|
212
|
-
this.rest.users.set(this.id, this);
|
|
213
|
-
this.manager.cache.set(this.id, this);
|
|
270
|
+
this._updateInternals(response);
|
|
214
271
|
return this;
|
|
215
272
|
}
|
|
216
273
|
async delete() {
|
|
@@ -4,6 +4,7 @@ exports.GuildMatchMessagesType = exports.GuildMatchChannelsType = void 0;
|
|
|
4
4
|
var GuildMatchChannelsType;
|
|
5
5
|
(function (GuildMatchChannelsType) {
|
|
6
6
|
GuildMatchChannelsType["CreationChannel"] = "creation_channel";
|
|
7
|
+
GuildMatchChannelsType["TextChannel"] = "text_channel";
|
|
7
8
|
})(GuildMatchChannelsType || (exports.GuildMatchChannelsType = GuildMatchChannelsType = {}));
|
|
8
9
|
var GuildMatchMessagesType;
|
|
9
10
|
(function (GuildMatchMessagesType) {
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GuildPermissionsTypes = void 0;
|
|
4
|
+
var GuildPermissionsTypes;
|
|
5
|
+
(function (GuildPermissionsTypes) {
|
|
6
|
+
GuildPermissionsTypes["ManageBot"] = "manage_bot";
|
|
7
|
+
})(GuildPermissionsTypes || (exports.GuildPermissionsTypes = GuildPermissionsTypes = {}));
|
package/dist/types/api/index.js
CHANGED
|
@@ -47,11 +47,14 @@ var STATES;
|
|
|
47
47
|
STATES["SHUTTED"] = "shutted";
|
|
48
48
|
STATES["WAITING"] = "waiting";
|
|
49
49
|
})(STATES || (exports.STATES = STATES = {}));
|
|
50
|
+
__exportStar(require("./APIAdvert"), exports);
|
|
50
51
|
__exportStar(require("./APIBaseChannel"), exports);
|
|
51
52
|
__exportStar(require("./APIBetChannel"), exports);
|
|
52
53
|
__exportStar(require("./APIBetMessage"), exports);
|
|
54
|
+
__exportStar(require("./APICode"), exports);
|
|
53
55
|
__exportStar(require("./APIGiveaway"), exports);
|
|
54
56
|
__exportStar(require("./APIGuild"), exports);
|
|
57
|
+
__exportStar(require("./APIGuildAdvert"), exports);
|
|
55
58
|
__exportStar(require("./APIGuildBet"), exports);
|
|
56
59
|
__exportStar(require("./APIGuildBetUser"), exports);
|
|
57
60
|
__exportStar(require("./APIGuildChannel"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duque.edits/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"main": "dist/index",
|
|
5
5
|
"types": "./types/index.d.ts",
|
|
6
6
|
"typings": "./types/index.d.ts",
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
"dist",
|
|
18
18
|
"types"
|
|
19
19
|
],
|
|
20
|
-
|
|
21
20
|
"scripts": {
|
|
22
21
|
"test": "ts-node --transpile-only tests/index.ts",
|
|
23
22
|
"match": "ts-node --transpile-only tests/match.ts",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Guild } from "../../structures/guild/Guild";
|
|
2
|
-
import { APIGuild, APIGuildPermissions } from "../../types";
|
|
2
|
+
import { APIGuild, APIGuildPermissions, GuildPermissionsTypes } from "../../types";
|
|
3
3
|
import { BaseManager } from "../base";
|
|
4
4
|
export declare class GuildPermissionManager extends BaseManager<APIGuildPermissions> {
|
|
5
5
|
constructor(guild: Guild);
|
|
6
|
-
addRole(
|
|
7
|
-
removeRole(
|
|
6
|
+
addRole(type: GuildPermissionsTypes, roleId: string): Promise<APIGuild>;
|
|
7
|
+
removeRole(type: GuildPermissionsTypes, roleId: string): Promise<APIGuild | Guild>;
|
|
8
8
|
}
|
package/types/rest/REST.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { GuildMatch } from "../structures/match/GuildMatch";
|
|
|
5
5
|
import { GuildUser } from "../structures/user/GuildUser";
|
|
6
6
|
import { RestEvents, RequestOptions } from "../types/RestTypes";
|
|
7
7
|
import { MinesGameManager } from "../managers";
|
|
8
|
+
import { StatusResponse } from "../types";
|
|
8
9
|
interface ClientOptions {
|
|
9
10
|
clientKey: string;
|
|
10
11
|
authKey: string;
|
|
@@ -40,6 +41,7 @@ export declare class REST extends EventEmitter {
|
|
|
40
41
|
* @returns
|
|
41
42
|
*/
|
|
42
43
|
request<Expecting, Payload>(options: RequestOptions<Payload>): Promise<Expecting>;
|
|
44
|
+
getStatus(): Promise<StatusResponse>;
|
|
43
45
|
emit<K extends keyof RestEvents>(event: K, ...args: RestEvents[K]): boolean;
|
|
44
46
|
on<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void): this;
|
|
45
47
|
once<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void): this;
|
package/types/rest/Routes.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare const Routes: {
|
|
|
18
18
|
get: (guildId: string, userId: string) => string;
|
|
19
19
|
delete: (guildId: string, userId: string) => string;
|
|
20
20
|
deleteAll: (guildId: string) => string;
|
|
21
|
-
resource: (guildId: string, userId: string, resource: string) => string;
|
|
21
|
+
resource: (guildId: string, userId: string, ...resource: string[]) => string;
|
|
22
22
|
};
|
|
23
23
|
betUsers: {
|
|
24
24
|
getAll: (guildId: string) => string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BufferManager, GuildMatchManager, GuildPermissionManager, GuildTicketManager, GuildUserManager, LogManager, VipMemberManager } from "../../managers";
|
|
2
2
|
import { REST } from "../../rest/REST";
|
|
3
|
-
import { APIGuildGroupedChannel, APIGuildPermissions, APIGuildShop, Daily, Optional } from "../../types/api";
|
|
3
|
+
import { APICode, APIGuildAdvert, APIGuildGroupedChannel, APIGuildPermissions, APIGuildShop, Daily, Optional } from "../../types/api";
|
|
4
4
|
import { APIGuild, DailyCategories, GuildChannelsType, GuildModes, GuildPrices, GuildScores, GuildStatus, GuildTicketConfiguration } from "../../types/api/APIGuild";
|
|
5
5
|
export declare class Guild {
|
|
6
6
|
/** The data of this guild */
|
|
@@ -41,6 +41,8 @@ export declare class Guild {
|
|
|
41
41
|
users: GuildUserManager;
|
|
42
42
|
logEntries: LogManager;
|
|
43
43
|
shop: APIGuildShop;
|
|
44
|
+
adverts: APIGuildAdvert[];
|
|
45
|
+
codes: APICode[];
|
|
44
46
|
/**
|
|
45
47
|
* The guild structure
|
|
46
48
|
* @param data The guild's data
|
|
@@ -48,6 +50,10 @@ export declare class Guild {
|
|
|
48
50
|
*/
|
|
49
51
|
constructor(data: APIGuild, rest: REST);
|
|
50
52
|
getChannel(type: GuildChannelsType): Promise<APIGuildGroupedChannel>;
|
|
53
|
+
createAdvert(data: Optional<APIGuildAdvert>): Promise<this>;
|
|
54
|
+
removeAdvert(advertId: string): Promise<this>;
|
|
55
|
+
createCode(data: Optional<APICode>): Promise<this>;
|
|
56
|
+
removeCode(codeId: string): Promise<this>;
|
|
51
57
|
addIdToChannel(type: GuildChannelsType, id: string | string[]): Promise<this>;
|
|
52
58
|
removeIdInChannel(type: GuildChannelsType, id: string): Promise<this>;
|
|
53
59
|
_start(): Promise<this>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { REST } from "../../rest/REST";
|
|
2
|
-
import { Accessory, Daily, Items, Optional, OriginalChannels } from "../../types/api";
|
|
2
|
+
import { Accessory, APIAdvert, Daily, Items, Optional, OriginalChannels } from "../../types/api";
|
|
3
3
|
import { APIGuildUser, Profile } from "../../types/api/APIGuildUser";
|
|
4
4
|
import { GuildUserManager } from "../../managers/user/GuildUserManager";
|
|
5
5
|
export declare class GuildUser implements APIGuildUser {
|
|
@@ -28,6 +28,7 @@ export declare class GuildUser implements APIGuildUser {
|
|
|
28
28
|
creations: number;
|
|
29
29
|
/** User's items */
|
|
30
30
|
items: Items;
|
|
31
|
+
adverts: APIAdvert[];
|
|
31
32
|
/** Creation Date */
|
|
32
33
|
createdAt: Date;
|
|
33
34
|
/** Updated Date */
|
|
@@ -64,7 +65,10 @@ export declare class GuildUser implements APIGuildUser {
|
|
|
64
65
|
*/
|
|
65
66
|
setBlacklist(value: boolean): Promise<this>;
|
|
66
67
|
reset(): Promise<this>;
|
|
68
|
+
updateProfile(data: Optional<Profile>): Promise<this>;
|
|
67
69
|
_updateInternals(data: Optional<APIGuildUser>): this;
|
|
70
|
+
addAdvert(data: Optional<Omit<APIAdvert, "_id">>): Promise<GuildUser>;
|
|
71
|
+
removeAdvert(advertId?: string): Promise<GuildUser>;
|
|
68
72
|
/**
|
|
69
73
|
* Update certain property
|
|
70
74
|
* @param data The new data to update with
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { APITicketCategory } from ".";
|
|
1
|
+
import { APICode, APIGuildAdvert, APITicketCategory } from ".";
|
|
2
2
|
import { APIGuildGroupedChannel } from "./APIGuildGroupedChannel";
|
|
3
3
|
import { APIGuildPermissions } from "./APIGuildPermissions";
|
|
4
4
|
import { APIGuildShop } from "./APIGuildShop";
|
|
@@ -73,6 +73,9 @@ export interface APIGuild {
|
|
|
73
73
|
updatedAt: Date;
|
|
74
74
|
/** Guild Shop */
|
|
75
75
|
shop: APIGuildShop;
|
|
76
|
+
adverts: APIGuildAdvert[];
|
|
77
|
+
max_advert_per_user: number;
|
|
78
|
+
codes: APICode[];
|
|
76
79
|
}
|
|
77
80
|
export declare enum GuildChannelsType {
|
|
78
81
|
DailyRank = "daily_rank",
|
|
@@ -47,7 +47,8 @@ export interface APIGuildMatch {
|
|
|
47
47
|
mvps: [];
|
|
48
48
|
}
|
|
49
49
|
export declare enum GuildMatchChannelsType {
|
|
50
|
-
CreationChannel = "creation_channel"
|
|
50
|
+
CreationChannel = "creation_channel",
|
|
51
|
+
TextChannel = "text_channel"
|
|
51
52
|
}
|
|
52
53
|
export declare enum GuildMatchMessagesType {
|
|
53
54
|
CreationMessage = "creation_message"
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
export interface
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
export interface Permission {
|
|
2
|
+
type: string;
|
|
3
|
+
ids: string[];
|
|
4
|
+
}
|
|
5
|
+
export type APIGuildPermissions = Permission[];
|
|
6
|
+
export declare enum GuildPermissionsTypes {
|
|
7
|
+
ManageBot = "manage_bot"
|
|
6
8
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Accessory, Daily, Items, OriginalChannels } from ".";
|
|
1
|
+
import { Accessory, APIAdvert, Daily, Items, OriginalChannels } from ".";
|
|
2
2
|
export interface Profile {
|
|
3
3
|
bannerUrl?: string;
|
|
4
4
|
avatarUrl?: string;
|
|
@@ -17,6 +17,7 @@ export interface APIGuildUser {
|
|
|
17
17
|
creations: number;
|
|
18
18
|
/** User's wins */
|
|
19
19
|
wins: number;
|
|
20
|
+
adverts: APIAdvert[];
|
|
20
21
|
/** User's mvps */
|
|
21
22
|
mvps: number;
|
|
22
23
|
/** User's losses */
|
|
@@ -123,11 +123,29 @@ export declare enum STATES {
|
|
|
123
123
|
SHUTTED = "shutted",
|
|
124
124
|
WAITING = "waiting"
|
|
125
125
|
}
|
|
126
|
+
export interface StatusResponse {
|
|
127
|
+
status: "ok" | "error";
|
|
128
|
+
services: {
|
|
129
|
+
fastify: boolean;
|
|
130
|
+
mongo: {
|
|
131
|
+
ok: boolean;
|
|
132
|
+
latency: number;
|
|
133
|
+
};
|
|
134
|
+
redis: {
|
|
135
|
+
ok: boolean;
|
|
136
|
+
latency: number;
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
timestamp: string;
|
|
140
|
+
}
|
|
141
|
+
export * from "./APIAdvert";
|
|
126
142
|
export * from "./APIBaseChannel";
|
|
127
143
|
export * from "./APIBetChannel";
|
|
128
144
|
export * from "./APIBetMessage";
|
|
145
|
+
export * from "./APICode";
|
|
129
146
|
export * from "./APIGiveaway";
|
|
130
147
|
export * from "./APIGuild";
|
|
148
|
+
export * from "./APIGuildAdvert";
|
|
131
149
|
export * from "./APIGuildBet";
|
|
132
150
|
export * from "./APIGuildBetUser";
|
|
133
151
|
export * from "./APIGuildChannel";
|