@duque.edits/sdk 0.1.5 → 0.1.6
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/index.js +4 -31
- package/dist/managers/base.js +26 -0
- package/dist/managers/buffer/BufferManager.js +2 -2
- package/dist/managers/guild/GuildManager.js +42 -25
- package/dist/managers/index.js +23 -0
- package/dist/managers/match/GuildMatchManager.js +42 -31
- package/dist/managers/message/MessagesManager.js +48 -0
- package/dist/managers/permission/GuildPermissionManager.js +29 -52
- package/dist/managers/ticket/TicketManager.js +77 -0
- package/dist/managers/user/GuildUserManager.js +73 -85
- package/dist/managers/vipmember/VipMemberManager.js +23 -23
- package/dist/rest/REST.js +40 -24
- package/dist/rest/Routes.js +15 -17
- package/dist/rest/index.js +19 -0
- package/dist/structures/Collection.js +1 -1
- package/dist/structures/guild/Guild.js +59 -94
- package/dist/structures/index.js +22 -0
- package/dist/structures/match/GuildMatch.js +64 -111
- package/dist/structures/ticket/Ticket.js +119 -0
- package/dist/structures/user/GuildUser.js +46 -40
- package/dist/structures/vipmember/VipMember.js +5 -5
- package/dist/types/api/APILogMessage.js +2 -0
- package/dist/types/api/index.js +36 -0
- package/dist/types/index.js +1 -22
- package/package.json +11 -18
- package/types/index.d.ts +4 -0
- package/types/managers/base.d.ts +17 -0
- package/{dist → types}/managers/buffer/BufferManager.d.ts +2 -1
- package/{dist → types}/managers/guild/GuildManager.d.ts +12 -4
- package/types/managers/index.d.ts +7 -0
- package/{dist → types}/managers/match/GuildMatchManager.d.ts +10 -12
- package/types/managers/message/MessagesManager.d.ts +17 -0
- package/types/managers/permission/GuildPermissionManager.d.ts +8 -0
- package/types/managers/ticket/TicketManager.d.ts +22 -0
- package/types/managers/user/GuildUserManager.d.ts +19 -0
- package/{dist → types}/managers/vipmember/VipMemberManager.d.ts +8 -8
- package/types/rest/APIEndpoints.d.ts +11 -0
- package/{dist → types}/rest/REST.d.ts +9 -18
- package/{dist → types}/rest/Routes.d.ts +2 -2
- package/types/rest/index.d.ts +3 -0
- package/{dist → types}/structures/guild/Guild.d.ts +12 -29
- package/types/structures/index.d.ts +6 -0
- package/{dist → types}/structures/match/GuildMatch.d.ts +12 -22
- package/types/structures/ticket/Ticket.d.ts +30 -0
- package/{dist → types}/structures/user/GuildUser.d.ts +5 -3
- package/{dist → types}/structures/vipmember/VipMember.d.ts +1 -1
- package/types/types/RestTypes.d.ts +34 -0
- package/{dist → types}/types/api/APIGuild.d.ts +9 -2
- package/{dist → types}/types/api/APIGuildMatch.d.ts +9 -7
- package/types/types/api/APIGuildTicket.d.ts +16 -0
- package/{dist → types}/types/api/APIGuildUser.d.ts +3 -1
- package/types/types/api/APILogMessage.d.ts +7 -0
- package/{dist → types}/types/api/APIMessage.d.ts +3 -4
- package/{dist → types}/types/api/APIPlayer.d.ts +1 -1
- package/{dist → types}/types/api/index.d.ts +23 -1
- package/types/types/index.d.ts +2 -0
- package/dist/index.d.ts +0 -31
- package/dist/managers/bet/GuildBetManager.d.ts +0 -35
- package/dist/managers/bet/GuildBetManager.js +0 -126
- package/dist/managers/betuser/GuildBetUserManager.d.ts +0 -36
- package/dist/managers/betuser/GuildBetUserManager.js +0 -151
- package/dist/managers/channel/ChannelManager.d.ts +0 -39
- package/dist/managers/channel/ChannelManager.js +0 -148
- package/dist/managers/giveaway/GiveawayManager.d.ts +0 -16
- package/dist/managers/giveaway/GiveawayManager.js +0 -57
- package/dist/managers/groupedchannel/GroupedChannelManager.d.ts +0 -34
- package/dist/managers/groupedchannel/GroupedChannelManager.js +0 -92
- package/dist/managers/mediator/GuildMediatorManager.d.ts +0 -32
- package/dist/managers/mediator/GuildMediatorManager.js +0 -98
- package/dist/managers/messages/MessagesManager.d.ts +0 -32
- package/dist/managers/messages/MessagesManager.js +0 -89
- package/dist/managers/permission/GuildPermissionManager.d.ts +0 -26
- package/dist/managers/product/GuildProductManager.d.ts +0 -32
- package/dist/managers/product/GuildProductManager.js +0 -103
- package/dist/managers/ticket/GuildTicketManager.d.ts +0 -32
- package/dist/managers/ticket/GuildTicketManager.js +0 -100
- package/dist/managers/user/GuildUserManager.d.ts +0 -33
- package/dist/rest/APIEndpoints.d.ts +0 -11
- package/dist/structures/bet/GuildBet.d.ts +0 -87
- package/dist/structures/bet/GuildBet.js +0 -286
- package/dist/structures/betuser/GuildBetUser.d.ts +0 -85
- package/dist/structures/betuser/GuildBetUser.js +0 -211
- package/dist/structures/channel/Channel.d.ts +0 -31
- package/dist/structures/channel/Channel.js +0 -57
- package/dist/structures/giveaway/Giveaway.d.ts +0 -37
- package/dist/structures/giveaway/Giveaway.js +0 -208
- package/dist/structures/groupedchannel/GroupedChannel.d.ts +0 -34
- package/dist/structures/groupedchannel/GroupedChannel.js +0 -121
- package/dist/structures/mediator/GuildMediator.d.ts +0 -41
- package/dist/structures/mediator/GuildMediator.js +0 -131
- package/dist/structures/product/GuildProduct.d.ts +0 -52
- package/dist/structures/product/GuildProduct.js +0 -175
- package/dist/structures/shop/GuildShop.d.ts +0 -34
- package/dist/structures/shop/GuildShop.js +0 -80
- package/dist/structures/ticket/GuildTicket.d.ts +0 -52
- package/dist/structures/ticket/GuildTicket.js +0 -172
- package/dist/types/api/APIGuildTicket.d.ts +0 -26
- package/dist/types/index.d.ts +0 -23
- /package/dist/types/{api/APIGuildMessage.js → RestTypes.js} +0 -0
- /package/{dist → types}/structures/Collection.d.ts +0 -0
- /package/{dist → types}/types/api/APIBaseChannel.d.ts +0 -0
- /package/{dist → types}/types/api/APIBetChannel.d.ts +0 -0
- /package/{dist → types}/types/api/APIBetMessage.d.ts +0 -0
- /package/{dist → types}/types/api/APIGiveaway.d.ts +0 -0
- /package/{dist → types}/types/api/APIGuildBet.d.ts +0 -0
- /package/{dist → types}/types/api/APIGuildBetUser.d.ts +0 -0
- /package/{dist → types}/types/api/APIGuildChannel.d.ts +0 -0
- /package/{dist → types}/types/api/APIGuildEmoji.d.ts +0 -0
- /package/{dist → types}/types/api/APIGuildGroupedChannel.d.ts +0 -0
- /package/{dist → types}/types/api/APIGuildMediator.d.ts +0 -0
- /package/{dist → types}/types/api/APIGuildMessage.d.ts +0 -0
- /package/{dist → types}/types/api/APIGuildPermissions.d.ts +0 -0
- /package/{dist → types}/types/api/APIGuildRole.d.ts +0 -0
- /package/{dist → types}/types/api/APIGuildShop.d.ts +0 -0
- /package/{dist → types}/types/api/APIProduct.d.ts +0 -0
- /package/{dist → types}/types/api/APIVipMember.d.ts +0 -0
- /package/{dist → types}/utils/Assertion.d.ts +0 -0
- /package/{dist → types}/utils/getRandomNumber.d.ts +0 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GuildTicket = void 0;
|
|
4
|
+
const rest_1 = require("../../rest");
|
|
5
|
+
class GuildTicket {
|
|
6
|
+
_id;
|
|
7
|
+
guild_id;
|
|
8
|
+
type;
|
|
9
|
+
status;
|
|
10
|
+
admin_id;
|
|
11
|
+
channel_id;
|
|
12
|
+
closed_by_id;
|
|
13
|
+
creator_id;
|
|
14
|
+
customer_rating;
|
|
15
|
+
messages;
|
|
16
|
+
createdAt;
|
|
17
|
+
updatedAt;
|
|
18
|
+
rest;
|
|
19
|
+
guild;
|
|
20
|
+
manager;
|
|
21
|
+
constructor(data, manager) {
|
|
22
|
+
this.manager = manager;
|
|
23
|
+
this.guild = manager.guild;
|
|
24
|
+
this.rest = manager.rest;
|
|
25
|
+
this._id = data?._id;
|
|
26
|
+
this.type = data?.type;
|
|
27
|
+
this.admin_id = data?.admin_id;
|
|
28
|
+
this.guild_id = data?.guild_id;
|
|
29
|
+
this.channel_id = data?.channel_id;
|
|
30
|
+
this.creator_id = data?.creator_id;
|
|
31
|
+
this.status = data?.status;
|
|
32
|
+
this.customer_rating = data?.customer_rating;
|
|
33
|
+
this.messages = data?.messages;
|
|
34
|
+
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
|
|
35
|
+
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
|
|
36
|
+
}
|
|
37
|
+
async fetch() {
|
|
38
|
+
const route = rest_1.Routes.guilds.tickets.get(this.guild.id, this._id);
|
|
39
|
+
const response = await this.rest.request({
|
|
40
|
+
method: "GET",
|
|
41
|
+
url: route,
|
|
42
|
+
});
|
|
43
|
+
return this._updateInternals(response);
|
|
44
|
+
}
|
|
45
|
+
async setCustomerRating(rating) {
|
|
46
|
+
const route = rest_1.Routes.guilds.tickets.resource(this.guild.id, this._id, "customer_rating");
|
|
47
|
+
const payload = { set: rating };
|
|
48
|
+
const response = await this.rest.request({
|
|
49
|
+
method: "PATCH",
|
|
50
|
+
url: route,
|
|
51
|
+
payload,
|
|
52
|
+
});
|
|
53
|
+
return this._updateInternals(response);
|
|
54
|
+
}
|
|
55
|
+
async setAdminId(id) {
|
|
56
|
+
const route = rest_1.Routes.guilds.tickets.resource(this.guild.id, this._id, "admin_id");
|
|
57
|
+
const payload = { set: id };
|
|
58
|
+
const response = await this.rest.request({
|
|
59
|
+
method: "PATCH",
|
|
60
|
+
url: route,
|
|
61
|
+
payload,
|
|
62
|
+
});
|
|
63
|
+
return this._updateInternals(response);
|
|
64
|
+
}
|
|
65
|
+
async setChannelId(id) {
|
|
66
|
+
const route = rest_1.Routes.guilds.tickets.resource(this.guild.id, this._id, "channel_id");
|
|
67
|
+
const payload = { set: id };
|
|
68
|
+
const response = await this.rest.request({
|
|
69
|
+
method: "PATCH",
|
|
70
|
+
url: route,
|
|
71
|
+
payload,
|
|
72
|
+
});
|
|
73
|
+
return this._updateInternals(response);
|
|
74
|
+
}
|
|
75
|
+
async setClosedById(id) {
|
|
76
|
+
const route = rest_1.Routes.guilds.tickets.resource(this.guild.id, this._id, "closed_by_id");
|
|
77
|
+
const payload = { set: id };
|
|
78
|
+
const response = await this.rest.request({
|
|
79
|
+
method: "PATCH",
|
|
80
|
+
url: route,
|
|
81
|
+
payload,
|
|
82
|
+
});
|
|
83
|
+
return this._updateInternals(response);
|
|
84
|
+
}
|
|
85
|
+
async setStatus(status) {
|
|
86
|
+
const route = rest_1.Routes.guilds.tickets.resource(this.guild.id, this._id, "status");
|
|
87
|
+
const payload = { set: status };
|
|
88
|
+
const response = await this.rest.request({
|
|
89
|
+
method: "PATCH",
|
|
90
|
+
url: route,
|
|
91
|
+
payload,
|
|
92
|
+
});
|
|
93
|
+
return this._updateInternals(response);
|
|
94
|
+
}
|
|
95
|
+
async addMessage(message) {
|
|
96
|
+
const route = rest_1.Routes.guilds.tickets.resource(this.guild.id, this._id, "messages");
|
|
97
|
+
const payload = { set: [...this.messages, message] };
|
|
98
|
+
const response = await this.rest.request({
|
|
99
|
+
method: "PATCH",
|
|
100
|
+
url: route,
|
|
101
|
+
payload,
|
|
102
|
+
});
|
|
103
|
+
return this._updateInternals(response);
|
|
104
|
+
}
|
|
105
|
+
_updateInternals(data) {
|
|
106
|
+
for (let key in data) {
|
|
107
|
+
if (key === "id" || key === "createdAt")
|
|
108
|
+
continue;
|
|
109
|
+
if (key in this) {
|
|
110
|
+
this[key] = data[key];
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
this.updatedAt = new Date();
|
|
114
|
+
this.createdAt = new Date(data.createdAt);
|
|
115
|
+
this.manager.set(this);
|
|
116
|
+
return this;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
exports.GuildTicket = GuildTicket;
|
|
@@ -5,6 +5,7 @@ const Routes_1 = require("../../rest/Routes");
|
|
|
5
5
|
class GuildUser {
|
|
6
6
|
/** User's id */
|
|
7
7
|
id;
|
|
8
|
+
guild_id;
|
|
8
9
|
/** User name */
|
|
9
10
|
name;
|
|
10
11
|
/** User's daily */
|
|
@@ -24,7 +25,8 @@ class GuildUser {
|
|
|
24
25
|
/** User's accessories such as double point */
|
|
25
26
|
accessories;
|
|
26
27
|
/** User's original channels */
|
|
27
|
-
|
|
28
|
+
original_channels;
|
|
29
|
+
creations;
|
|
28
30
|
/** User's items */
|
|
29
31
|
items;
|
|
30
32
|
/** Creation Date */
|
|
@@ -41,26 +43,27 @@ class GuildUser {
|
|
|
41
43
|
* @param manager The manager
|
|
42
44
|
* @param rest The rest client
|
|
43
45
|
*/
|
|
44
|
-
constructor(data, manager
|
|
45
|
-
this.
|
|
46
|
-
this.
|
|
47
|
-
this.
|
|
48
|
-
this.
|
|
49
|
-
this.
|
|
50
|
-
this.
|
|
51
|
-
this.
|
|
52
|
-
this.
|
|
53
|
-
this.
|
|
54
|
-
this.
|
|
55
|
-
this.
|
|
56
|
-
this.
|
|
57
|
-
this.
|
|
58
|
-
this.
|
|
46
|
+
constructor(data, manager) {
|
|
47
|
+
this.id = data?.id;
|
|
48
|
+
this.guild_id = data?.guild_id;
|
|
49
|
+
this.manager = manager;
|
|
50
|
+
this.rest = manager.rest;
|
|
51
|
+
this.name = data?.name;
|
|
52
|
+
this.wins = data?.wins;
|
|
53
|
+
this.creations = data?.creations;
|
|
54
|
+
this.losses = data?.losses;
|
|
55
|
+
this.blacklist = data?.blacklist;
|
|
56
|
+
this.items = data?.items;
|
|
57
|
+
this.points = data?.points;
|
|
58
|
+
this.mvps = data?.mvps;
|
|
59
|
+
this.games = data?.games;
|
|
60
|
+
this.losses = data?.losses;
|
|
61
|
+
this.original_channels = data?.original_channels;
|
|
62
|
+
this.accessories = data?.accessories;
|
|
63
|
+
this.items = data?.items;
|
|
59
64
|
this.daily = data?.daily;
|
|
60
65
|
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
|
|
61
66
|
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
|
|
62
|
-
this.manager = manager;
|
|
63
|
-
this.rest = rest;
|
|
64
67
|
}
|
|
65
68
|
/** String representation of this user */
|
|
66
69
|
toString() {
|
|
@@ -76,7 +79,7 @@ class GuildUser {
|
|
|
76
79
|
method: "get",
|
|
77
80
|
url: route,
|
|
78
81
|
});
|
|
79
|
-
const user = new GuildUser(response, this.manager
|
|
82
|
+
const user = new GuildUser(response, this.manager);
|
|
80
83
|
this.manager.cache.set(user.id, user);
|
|
81
84
|
this.rest.users.set(user.id, user);
|
|
82
85
|
return user;
|
|
@@ -89,7 +92,7 @@ class GuildUser {
|
|
|
89
92
|
*/
|
|
90
93
|
async add(key, value) {
|
|
91
94
|
const route = Routes_1.Routes.guilds.users.resource(this.manager.guild.id, this.id, key);
|
|
92
|
-
const payload = {
|
|
95
|
+
const payload = { set: value };
|
|
93
96
|
const resp = await this.rest.request({
|
|
94
97
|
method: "patch",
|
|
95
98
|
url: route,
|
|
@@ -107,7 +110,7 @@ class GuildUser {
|
|
|
107
110
|
*/
|
|
108
111
|
async setBlacklist(value) {
|
|
109
112
|
const route = Routes_1.Routes.guilds.users.resource(this.manager.guild.id, this.id, "blacklist");
|
|
110
|
-
const payload = {
|
|
113
|
+
const payload = { set: value };
|
|
111
114
|
await this.rest.request({
|
|
112
115
|
method: "patch",
|
|
113
116
|
url: route,
|
|
@@ -126,18 +129,21 @@ class GuildUser {
|
|
|
126
129
|
url: route,
|
|
127
130
|
payload,
|
|
128
131
|
});
|
|
129
|
-
this
|
|
132
|
+
this._updateInternals(response);
|
|
130
133
|
return this;
|
|
131
134
|
}
|
|
132
|
-
|
|
133
|
-
for (
|
|
134
|
-
if (
|
|
135
|
+
_updateInternals(data) {
|
|
136
|
+
for (let key in data) {
|
|
137
|
+
if (key === "id" || key === "createdAt")
|
|
135
138
|
continue;
|
|
136
|
-
if (
|
|
137
|
-
this[
|
|
138
|
-
this.data[k] = data[k];
|
|
139
|
+
if (key in this) {
|
|
140
|
+
this[key] = data[key];
|
|
139
141
|
}
|
|
140
142
|
}
|
|
143
|
+
this.updatedAt = new Date();
|
|
144
|
+
this.createdAt = new Date(data.createdAt);
|
|
145
|
+
this.manager.set(this);
|
|
146
|
+
return this;
|
|
141
147
|
}
|
|
142
148
|
/**
|
|
143
149
|
* Update certain property
|
|
@@ -145,13 +151,13 @@ class GuildUser {
|
|
|
145
151
|
* @returns
|
|
146
152
|
*/
|
|
147
153
|
async update(data) {
|
|
148
|
-
if (!data
|
|
154
|
+
if (!data?.type)
|
|
149
155
|
data.type = "add";
|
|
150
156
|
const route = Routes_1.Routes.guilds.users.get(this.manager.guild.id, this.id);
|
|
151
157
|
const payload = {};
|
|
152
158
|
const numericFields = ["coins", "wins", "points", "losses", "mvps", "games"];
|
|
153
|
-
const arrayFields = ["items", "
|
|
154
|
-
if (data
|
|
159
|
+
const arrayFields = ["items", "original_channels"];
|
|
160
|
+
if (data?.type === "add" || data?.type === "remove") {
|
|
155
161
|
for (const key in data) {
|
|
156
162
|
if (key === "type")
|
|
157
163
|
continue;
|
|
@@ -159,31 +165,31 @@ class GuildUser {
|
|
|
159
165
|
if (numericFields.includes(key)) {
|
|
160
166
|
const current = this[key];
|
|
161
167
|
const num = value;
|
|
162
|
-
payload[key] = Math.max(0, data
|
|
168
|
+
payload[key] = Math.max(0, data?.type === "add" ? current + num : num - current);
|
|
163
169
|
}
|
|
164
170
|
else if (key === "blacklist") {
|
|
165
171
|
payload["blacklist"] = value;
|
|
166
172
|
}
|
|
167
173
|
else if (arrayFields.includes(key)) {
|
|
168
|
-
if (key === "
|
|
169
|
-
const current = this.
|
|
170
|
-
const fromData = data["
|
|
174
|
+
if (key === "original_channels") {
|
|
175
|
+
const current = this.original_channels;
|
|
176
|
+
const fromData = data["original_channels"];
|
|
171
177
|
let channels = [];
|
|
172
|
-
if (data
|
|
178
|
+
if (data?.type === "add") {
|
|
173
179
|
const existingIds = new Set(current.map((ch) => ch.matchId));
|
|
174
180
|
channels = [...current, ...fromData.filter((ch) => !existingIds.has(ch.matchId))];
|
|
175
181
|
}
|
|
176
|
-
else if (data
|
|
182
|
+
else if (data?.type === "remove") {
|
|
177
183
|
const idsToRemove = new Set(fromData.map((ch) => ch.matchId));
|
|
178
184
|
channels = current.filter((ch) => !idsToRemove.has(ch.matchId));
|
|
179
185
|
}
|
|
180
|
-
payload["
|
|
186
|
+
payload["original_channels"] = channels;
|
|
181
187
|
continue;
|
|
182
188
|
}
|
|
183
189
|
const current = this[key];
|
|
184
190
|
const incoming = value;
|
|
185
191
|
payload[key] =
|
|
186
|
-
data
|
|
192
|
+
data?.type === "add"
|
|
187
193
|
? [...new Set([...current, ...incoming])]
|
|
188
194
|
: current.filter((x) => !incoming.includes(x));
|
|
189
195
|
}
|
|
@@ -213,7 +219,7 @@ class GuildUser {
|
|
|
213
219
|
method: "DELETE",
|
|
214
220
|
url: route,
|
|
215
221
|
});
|
|
216
|
-
this.rest.emit("
|
|
222
|
+
this.rest.emit("userDelete", this);
|
|
217
223
|
this.manager.cache.delete(this.id);
|
|
218
224
|
return response;
|
|
219
225
|
}
|
|
@@ -32,9 +32,12 @@ class VipMember {
|
|
|
32
32
|
* @param manager The manager
|
|
33
33
|
* @param rest The rest client
|
|
34
34
|
*/
|
|
35
|
-
constructor(data, manager
|
|
35
|
+
constructor(data, manager) {
|
|
36
36
|
this.name = data?.name;
|
|
37
37
|
this.id = data?.id;
|
|
38
|
+
this.manager = manager;
|
|
39
|
+
this.rest = manager.rest;
|
|
40
|
+
this.guild = manager.guild;
|
|
38
41
|
this.duration = data?.duration ? new Date(data?.duration) : new Date();
|
|
39
42
|
this.status = data?.status;
|
|
40
43
|
this.type = data?.type;
|
|
@@ -43,9 +46,6 @@ class VipMember {
|
|
|
43
46
|
this.guild_id = data?.guild_id;
|
|
44
47
|
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
|
|
45
48
|
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
|
|
46
|
-
this.manager = manager;
|
|
47
|
-
this.rest = rest;
|
|
48
|
-
this.guild = manager.guild;
|
|
49
49
|
}
|
|
50
50
|
/** String representation of this member */
|
|
51
51
|
toString() {
|
|
@@ -61,7 +61,7 @@ class VipMember {
|
|
|
61
61
|
method: "get",
|
|
62
62
|
url: route,
|
|
63
63
|
});
|
|
64
|
-
const member = new VipMember(response, this.manager
|
|
64
|
+
const member = new VipMember(response, this.manager);
|
|
65
65
|
this.manager.cache.set(member.id, member);
|
|
66
66
|
return member;
|
|
67
67
|
}
|
package/dist/types/api/index.js
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
17
|
exports.STATES = exports.BETSTATUS = exports.MATCHSTATUS = exports.MATCHTYPES = void 0;
|
|
4
18
|
var MATCHTYPES;
|
|
@@ -33,3 +47,25 @@ var STATES;
|
|
|
33
47
|
STATES["SHUTTED"] = "shutted";
|
|
34
48
|
STATES["WAITING"] = "waiting";
|
|
35
49
|
})(STATES || (exports.STATES = STATES = {}));
|
|
50
|
+
__exportStar(require("./APIBaseChannel"), exports);
|
|
51
|
+
__exportStar(require("./APIBetChannel"), exports);
|
|
52
|
+
__exportStar(require("./APIBetMessage"), exports);
|
|
53
|
+
__exportStar(require("./APIGuild"), exports);
|
|
54
|
+
__exportStar(require("./APIGuildBet"), exports);
|
|
55
|
+
__exportStar(require("./APIGuildBetUser"), exports);
|
|
56
|
+
__exportStar(require("./APIGuildChannel"), exports);
|
|
57
|
+
__exportStar(require("./APIGuildEmoji"), exports);
|
|
58
|
+
__exportStar(require("./APIGuildGroupedChannel"), exports);
|
|
59
|
+
__exportStar(require("./APIGuildMatch"), exports);
|
|
60
|
+
__exportStar(require("./APIGuildMediator"), exports);
|
|
61
|
+
__exportStar(require("./APIGuildPermissions"), exports);
|
|
62
|
+
__exportStar(require("./APIGuildRole"), exports);
|
|
63
|
+
__exportStar(require("./APIGuildShop"), exports);
|
|
64
|
+
__exportStar(require("./APIGuildTicket"), exports);
|
|
65
|
+
__exportStar(require("./APIGuildUser"), exports);
|
|
66
|
+
__exportStar(require("./APIMessage"), exports);
|
|
67
|
+
__exportStar(require("./APIPlayer"), exports);
|
|
68
|
+
__exportStar(require("./APIProduct"), exports);
|
|
69
|
+
__exportStar(require("./APIVipMember"), exports);
|
|
70
|
+
__exportStar(require("./APIGiveaway"), exports);
|
|
71
|
+
__exportStar(require("./APILogMessage"), exports);
|
package/dist/types/index.js
CHANGED
|
@@ -14,26 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./api/APIBaseChannel"), exports);
|
|
18
|
-
__exportStar(require("./api/APIBetChannel"), exports);
|
|
19
|
-
__exportStar(require("./api/APIBetMessage"), exports);
|
|
20
|
-
__exportStar(require("./api/APIGuild"), exports);
|
|
21
|
-
__exportStar(require("./api/APIGuildBet"), exports);
|
|
22
|
-
__exportStar(require("./api/APIGuildBetUser"), exports);
|
|
23
|
-
__exportStar(require("./api/APIGuildChannel"), exports);
|
|
24
|
-
__exportStar(require("./api/APIGuildEmoji"), exports);
|
|
25
|
-
__exportStar(require("./api/APIGuildGroupedChannel"), exports);
|
|
26
|
-
__exportStar(require("./api/APIGuildMatch"), exports);
|
|
27
|
-
__exportStar(require("./api/APIGuildMediator"), exports);
|
|
28
|
-
__exportStar(require("./api/APIGuildMessage"), exports);
|
|
29
|
-
__exportStar(require("./api/APIGuildPermissions"), exports);
|
|
30
|
-
__exportStar(require("./api/APIGuildRole"), exports);
|
|
31
|
-
__exportStar(require("./api/APIGuildShop"), exports);
|
|
32
|
-
__exportStar(require("./api/APIGuildTicket"), exports);
|
|
33
|
-
__exportStar(require("./api/APIGuildUser"), exports);
|
|
34
|
-
__exportStar(require("./api/APIMessage"), exports);
|
|
35
|
-
__exportStar(require("./api/APIPlayer"), exports);
|
|
36
|
-
__exportStar(require("./api/APIProduct"), exports);
|
|
37
|
-
__exportStar(require("./api/APIVipMember"), exports);
|
|
38
|
-
__exportStar(require("./api/APIGiveaway"), exports);
|
|
39
17
|
__exportStar(require("./api/index"), exports);
|
|
18
|
+
__exportStar(require("./RestTypes"), exports);
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duque.edits/sdk",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"main": "
|
|
5
|
-
"types": "./
|
|
6
|
-
"typings": "./
|
|
3
|
+
"version": "0.1.6",
|
|
4
|
+
"main": "dist/index",
|
|
5
|
+
"types": "./types/index.d.ts",
|
|
6
|
+
"typings": "./types/index.d.ts",
|
|
7
7
|
"type": "commonjs",
|
|
8
8
|
"description": "An SDK that facilitates interaction with my API.",
|
|
9
|
+
"module": "dist/duque.edits-sdk.esm.js",
|
|
9
10
|
"keywords": [
|
|
10
11
|
"REST",
|
|
11
12
|
"API",
|
|
@@ -13,11 +14,13 @@
|
|
|
13
14
|
"DuqueEdits"
|
|
14
15
|
],
|
|
15
16
|
"files": [
|
|
16
|
-
"
|
|
17
|
-
"
|
|
17
|
+
"dist",
|
|
18
|
+
"types"
|
|
18
19
|
],
|
|
19
20
|
"scripts": {
|
|
20
|
-
"test": "ts-node tests/index.ts"
|
|
21
|
+
"test": "ts-node tests/index.ts",
|
|
22
|
+
"match": "ts-node tests/match.ts",
|
|
23
|
+
"guild": "ts-node tests/guild.ts"
|
|
21
24
|
},
|
|
22
25
|
"author": "Duque Edits jedits077@gmail.com",
|
|
23
26
|
"license": "ISC",
|
|
@@ -42,20 +45,10 @@
|
|
|
42
45
|
"ts-node": "^10.9.2",
|
|
43
46
|
"typescript": "^5.8.3"
|
|
44
47
|
},
|
|
45
|
-
"exports": {
|
|
46
|
-
".": {
|
|
47
|
-
"require": "./dist/index.js",
|
|
48
|
-
"types": "./dist/index.d.ts"
|
|
49
|
-
},
|
|
50
|
-
"./v1": {
|
|
51
|
-
"require": "./dist/v1",
|
|
52
|
-
"types": "./dist/index.d.ts"
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
48
|
"publishConfig": {
|
|
56
49
|
"access": "public"
|
|
57
50
|
},
|
|
58
51
|
"engines": {
|
|
59
|
-
"node": ">=
|
|
52
|
+
"node": ">=20"
|
|
60
53
|
}
|
|
61
54
|
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { REST } from "../rest/REST";
|
|
2
|
+
import { Collection } from "../structures/Collection";
|
|
3
|
+
import { Guild } from "../structures/guild/Guild";
|
|
4
|
+
export declare class BaseManager<S> {
|
|
5
|
+
/** This url of the manager */
|
|
6
|
+
base_url: string;
|
|
7
|
+
/** The rest client */
|
|
8
|
+
rest: REST;
|
|
9
|
+
/** The guild of the manager */
|
|
10
|
+
guild: Guild;
|
|
11
|
+
/** Cache */
|
|
12
|
+
cache: Collection<string, S>;
|
|
13
|
+
/** Internal data when manager is initialized */
|
|
14
|
+
_data: unknown;
|
|
15
|
+
constructor(guild: Guild, data?: unknown);
|
|
16
|
+
get data(): unknown;
|
|
17
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Collection } from "../../structures/Collection";
|
|
2
2
|
import { Guild } from "../../structures/guild/Guild";
|
|
3
|
+
import { GuildMatch } from "../../structures/match/GuildMatch";
|
|
3
4
|
import { APIGuildMatch, APIGuildTicket, Optional } from "../../types";
|
|
4
5
|
export type BufferMatch = Optional<APIGuildMatch & {
|
|
5
6
|
id: string;
|
|
@@ -8,7 +9,7 @@ export type BufferTicket = Optional<APIGuildTicket & {
|
|
|
8
9
|
id: string;
|
|
9
10
|
}>;
|
|
10
11
|
export declare class BufferManager {
|
|
11
|
-
matches: Collection<string, BufferMatch>;
|
|
12
|
+
matches: Collection<string, BufferMatch | GuildMatch>;
|
|
12
13
|
tickets: Collection<string, BufferTicket>;
|
|
13
14
|
guild: Guild;
|
|
14
15
|
constructor(guild: Guild);
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { REST } from "../../rest/REST";
|
|
2
2
|
import { Collection } from "../../structures/Collection";
|
|
3
3
|
import { Guild } from "../../structures/guild/Guild";
|
|
4
|
+
import { APIGuild } from "../../types/api/APIGuild";
|
|
5
|
+
type FetchOptions = {
|
|
6
|
+
guildId?: string;
|
|
7
|
+
cache?: boolean;
|
|
8
|
+
};
|
|
9
|
+
type DeleteOptions = {
|
|
10
|
+
guildId?: string;
|
|
11
|
+
};
|
|
4
12
|
export declare class GuildManager {
|
|
5
13
|
/** A cache of guilds */
|
|
6
14
|
cache: Collection<string, Guild>;
|
|
@@ -17,8 +25,8 @@ export declare class GuildManager {
|
|
|
17
25
|
* @param id Id of the guild to fetch
|
|
18
26
|
* @returns APIGuild
|
|
19
27
|
*/
|
|
20
|
-
fetch(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
deleteAll(): Promise<boolean>;
|
|
28
|
+
fetch(options?: FetchOptions): Promise<Collection<string, Guild> | Guild>;
|
|
29
|
+
delete(options: DeleteOptions): Promise<Collection<string, Guild> | boolean>;
|
|
30
|
+
set(data: APIGuild | APIGuild[]): Guild | Collection<string, Guild>;
|
|
24
31
|
}
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./buffer/BufferManager";
|
|
2
|
+
export * from "./guild/GuildManager";
|
|
3
|
+
export * from "./match/GuildMatchManager";
|
|
4
|
+
export * from "./permission/GuildPermissionManager";
|
|
5
|
+
export * from "./user/GuildUserManager";
|
|
6
|
+
export * from "./vipmember/VipMemberManager";
|
|
7
|
+
export * from "./ticket/TicketManager";
|
|
@@ -1,32 +1,30 @@
|
|
|
1
|
-
import { REST } from "../../rest/REST";
|
|
2
1
|
import { GuildMatch } from "../../structures/match/GuildMatch";
|
|
3
2
|
import { Collection } from "../../structures/Collection";
|
|
4
3
|
import { Guild } from "../../structures/guild/Guild";
|
|
5
4
|
import { APIGuildMatch } from "../../types/api/APIGuildMatch";
|
|
6
5
|
import { Optional } from "../../types/api";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
cache:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
guild: Guild;
|
|
6
|
+
import { BaseManager } from "../base";
|
|
7
|
+
type FetchOptions = {
|
|
8
|
+
cache: boolean;
|
|
9
|
+
matchId: string;
|
|
10
|
+
};
|
|
11
|
+
export declare class GuildMatchManager extends BaseManager<GuildMatch> {
|
|
14
12
|
/**
|
|
15
13
|
* Manage users with the given client
|
|
16
14
|
* @param users An array of users
|
|
17
15
|
* @param rest The rest client
|
|
18
16
|
*/
|
|
19
|
-
constructor(guild: Guild
|
|
17
|
+
constructor(guild: Guild);
|
|
20
18
|
/**
|
|
21
19
|
* Fetch a match
|
|
22
20
|
* @param id Id of the match to fetch
|
|
23
21
|
* @returns APIBetUser
|
|
24
22
|
*/
|
|
25
|
-
fetch(
|
|
23
|
+
fetch(options?: Optional<FetchOptions>): Promise<GuildMatch | Collection<string, GuildMatch>>;
|
|
26
24
|
fetchAll(): Promise<Collection<string, GuildMatch>>;
|
|
27
|
-
set(data: APIGuildMatch): GuildMatch
|
|
28
|
-
setAll(data: APIGuildMatch[]): Collection<string, GuildMatch>;
|
|
25
|
+
set(data: APIGuildMatch | APIGuildMatch[]): GuildMatch | Collection<string, GuildMatch>;
|
|
29
26
|
create(payload: Optional<APIGuildMatch>): Promise<GuildMatch>;
|
|
30
27
|
delete(id: string): Promise<Collection<string, GuildMatch>>;
|
|
31
28
|
deleteAll(): Promise<boolean>;
|
|
32
29
|
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { REST } from "../../rest";
|
|
2
|
+
import { Collection } from "../../structures/Collection";
|
|
3
|
+
import { APIMessage, Optional } from "../../types";
|
|
4
|
+
type T<e> = e & {
|
|
5
|
+
rest: REST;
|
|
6
|
+
messages: MessagesManager<e>;
|
|
7
|
+
};
|
|
8
|
+
export declare class MessagesManager<Structure> {
|
|
9
|
+
cache: Collection<string, APIMessage>;
|
|
10
|
+
readonly base_url: string;
|
|
11
|
+
readonly rest: REST;
|
|
12
|
+
constructor(structure: T<Structure>, base_url: string);
|
|
13
|
+
fetch(): Promise<APIMessage>;
|
|
14
|
+
create(data: Optional<APIMessage> | Optional<APIMessage>[]): Promise<APIMessage[]>;
|
|
15
|
+
setAll(data: APIMessage | APIMessage[]): Collection<string, APIMessage>;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Guild } from "../../structures/guild/Guild";
|
|
2
|
+
import { APIGuild, APIGuildPermissions } from "../../types";
|
|
3
|
+
import { BaseManager } from "../base";
|
|
4
|
+
export declare class GuildPermissionManager extends BaseManager<APIGuildPermissions> {
|
|
5
|
+
constructor(guild: Guild);
|
|
6
|
+
addRole(permissionId: keyof APIGuildPermissions, roleId: string): Promise<APIGuild | Guild>;
|
|
7
|
+
removeRole(permissionId: keyof APIGuildPermissions, roleId: string): Promise<APIGuild | Guild>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { REST } from "../../rest";
|
|
2
|
+
import { Guild, GuildTicket } from "../../structures";
|
|
3
|
+
import { Collection } from "../../structures/Collection";
|
|
4
|
+
import { APIGuildTicket, Optional } from "../../types";
|
|
5
|
+
type FecthOptions = {
|
|
6
|
+
ticketId?: string;
|
|
7
|
+
cache?: boolean;
|
|
8
|
+
};
|
|
9
|
+
type DeleteOptions = {
|
|
10
|
+
ticketId?: string;
|
|
11
|
+
};
|
|
12
|
+
export declare class TicketManager {
|
|
13
|
+
cache: Collection<string, GuildTicket>;
|
|
14
|
+
readonly guild: Guild;
|
|
15
|
+
readonly rest: REST;
|
|
16
|
+
constructor(guild: Guild);
|
|
17
|
+
fetch(options?: FecthOptions): Promise<GuildTicket | Collection<string, GuildTicket>>;
|
|
18
|
+
create(data: Optional<APIGuildTicket>): Promise<GuildTicket>;
|
|
19
|
+
delete(options?: DeleteOptions): Promise<boolean>;
|
|
20
|
+
set(data: APIGuildTicket | APIGuildTicket[]): GuildTicket | Collection<string, GuildTicket>;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Collection } from "../../structures/Collection";
|
|
2
|
+
import { Guild } from "../../structures/guild/Guild";
|
|
3
|
+
import { GuildUser } from "../../structures/user/GuildUser";
|
|
4
|
+
import { APIGuildUser } from "../../types";
|
|
5
|
+
import { BaseManager } from "../base";
|
|
6
|
+
type FetchOptions = {
|
|
7
|
+
userId?: string;
|
|
8
|
+
cache?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare class GuildUserManager extends BaseManager<GuildUser> {
|
|
11
|
+
constructor(guild: Guild);
|
|
12
|
+
fetch(options?: FetchOptions): Promise<Collection<string, GuildUser> | GuildUser>;
|
|
13
|
+
updateMany(users: APIGuildUser[] | GuildUser[]): Promise<Collection<string, GuildUser>>;
|
|
14
|
+
deleteAll(): Promise<void>;
|
|
15
|
+
resetAll(): Promise<Collection<string, GuildUser>>;
|
|
16
|
+
_setUsers(data: (APIGuildUser | GuildUser) | (APIGuildUser[] | GuildUser[])): void;
|
|
17
|
+
set(data: APIGuildUser | APIGuildUser[]): GuildUser | Collection<string, GuildUser>;
|
|
18
|
+
}
|
|
19
|
+
export {};
|