seyfert 1.0.0 → 1.1.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/lib/api/CDN.d.ts +1 -1
- package/lib/api/CDN.js +0 -2
- package/lib/api/Router.js +2 -2
- package/lib/api/Routes/applications.d.ts +29 -33
- package/lib/api/Routes/channels.d.ts +11 -17
- package/lib/api/Routes/interactions.d.ts +3 -7
- package/lib/api/Routes/webhooks.d.ts +4 -6
- package/lib/api/api.d.ts +5 -0
- package/lib/api/api.js +36 -0
- package/lib/api/shared.d.ts +5 -3
- package/lib/builders/Attachment.d.ts +2 -3
- package/lib/builders/Button.d.ts +2 -2
- package/lib/cache/adapters/default.d.ts +1 -0
- package/lib/cache/adapters/default.js +1 -0
- package/lib/cache/adapters/redis.d.ts +1 -0
- package/lib/cache/adapters/redis.js +7 -0
- package/lib/cache/adapters/types.d.ts +1 -0
- package/lib/cache/adapters/workeradapter.d.ts +5 -4
- package/lib/cache/adapters/workeradapter.js +11 -5
- package/lib/cache/index.d.ts +4 -6
- package/lib/cache/index.js +5 -6
- package/lib/cache/resources/default/base.d.ts +2 -1
- package/lib/cache/resources/default/guild-based.d.ts +2 -1
- package/lib/cache/resources/default/guild-based.js +6 -6
- package/lib/cache/resources/default/guild-related.d.ts +2 -1
- package/lib/cache/resources/default/guild-related.js +1 -1
- package/lib/cache/resources/guilds.js +2 -1
- package/lib/cache/resources/overwrites.d.ts +1 -1
- package/lib/cache/resources/overwrites.js +7 -1
- package/lib/client/base.d.ts +18 -171
- package/lib/client/base.js +12 -15
- package/lib/client/client.d.ts +6 -1
- package/lib/client/client.js +13 -12
- package/lib/client/oninteractioncreate.js +4 -4
- package/lib/client/onmessagecreate.js +188 -152
- package/lib/client/workerclient.d.ts +15 -1
- package/lib/client/workerclient.js +135 -27
- package/lib/collection.js +2 -2
- package/lib/commands/applications/chat.d.ts +15 -7
- package/lib/commands/applications/chat.js +7 -7
- package/lib/commands/applications/chatcontext.d.ts +6 -4
- package/lib/commands/applications/chatcontext.js +12 -7
- package/lib/commands/applications/menu.d.ts +5 -1
- package/lib/commands/applications/menu.js +4 -0
- package/lib/commands/applications/menucontext.d.ts +5 -3
- package/lib/commands/applications/menucontext.js +9 -4
- package/lib/commands/applications/options.d.ts +1 -2
- package/lib/commands/decorators.d.ts +17 -5
- package/lib/commands/decorators.js +17 -7
- package/lib/commands/handler.d.ts +5 -5
- package/lib/commands/handler.js +40 -36
- package/lib/commands/optionresolver.d.ts +11 -4
- package/lib/commands/optionresolver.js +6 -4
- package/lib/common/index.d.ts +7 -0
- package/lib/common/index.js +7 -0
- package/lib/common/it/utils.js +2 -0
- package/lib/common/shorters/channels.d.ts +67 -129
- package/lib/common/shorters/channels.js +119 -135
- package/lib/common/shorters/emojis.d.ts +47 -0
- package/lib/common/shorters/emojis.js +80 -0
- package/lib/common/shorters/guilds.d.ts +22 -249
- package/lib/common/shorters/guilds.js +51 -140
- package/lib/common/shorters/members.d.ts +82 -108
- package/lib/common/shorters/members.js +151 -166
- package/lib/common/shorters/messages.d.ts +11 -23
- package/lib/common/shorters/messages.js +58 -104
- package/lib/common/shorters/reactions.d.ts +10 -0
- package/lib/common/shorters/reactions.js +45 -0
- package/lib/common/shorters/roles.d.ts +39 -7
- package/lib/common/shorters/roles.js +74 -42
- package/lib/common/shorters/templates.d.ts +6 -8
- package/lib/common/shorters/templates.js +17 -21
- package/lib/common/shorters/users.d.ts +4 -0
- package/lib/common/shorters/users.js +30 -0
- package/lib/common/shorters/webhook.d.ts +62 -26
- package/lib/common/shorters/webhook.js +113 -58
- package/lib/common/types/options.d.ts +2 -2
- package/lib/common/types/util.d.ts +1 -1
- package/lib/components/handler.d.ts +11 -8
- package/lib/components/handler.js +34 -22
- package/lib/index.d.ts +4 -2
- package/lib/langs/handler.js +7 -2
- package/lib/structures/AutoModerationRule.d.ts +2 -2
- package/lib/structures/ClientUser.d.ts +2 -2
- package/lib/structures/Guild.d.ts +2 -2
- package/lib/structures/GuildEmoji.d.ts +4 -4
- package/lib/structures/GuildEmoji.js +7 -7
- package/lib/structures/GuildMember.d.ts +6 -6
- package/lib/structures/GuildMember.js +2 -2
- package/lib/structures/GuildPreview.d.ts +2 -2
- package/lib/structures/GuildRole.d.ts +2 -2
- package/lib/structures/GuildTemplate.d.ts +2 -2
- package/lib/structures/Interaction.d.ts +7 -8
- package/lib/structures/Interaction.js +1 -1
- package/lib/structures/Message.d.ts +7 -6
- package/lib/structures/Message.js +7 -4
- package/lib/structures/Sticker.d.ts +2 -2
- package/lib/structures/Webhook.d.ts +2 -2
- package/lib/structures/Webhook.js +3 -3
- package/lib/structures/channels.d.ts +19 -20
- package/lib/structures/channels.js +13 -25
- package/lib/structures/extra/Base.d.ts +1 -2
- package/lib/structures/extra/DiscordBase.d.ts +2 -2
- package/lib/websocket/constants/index.js +2 -3
- package/lib/websocket/discord/shard.js +4 -2
- package/lib/websocket/discord/sharder.d.ts +3 -0
- package/lib/websocket/discord/sharder.js +12 -5
- package/lib/websocket/discord/shared.d.ts +3 -0
- package/lib/websocket/discord/worker.d.ts +24 -7
- package/lib/websocket/discord/workermanager.d.ts +30 -6
- package/lib/websocket/discord/workermanager.js +160 -51
- package/package.json +8 -5
|
@@ -9,11 +9,11 @@ function getCommandFromContent(commandRaw, self) {
|
|
|
9
9
|
const groupName = commandRaw.length === 3 ? commandRaw[1] : undefined;
|
|
10
10
|
const subcommandName = groupName ? commandRaw[2] : commandRaw[1];
|
|
11
11
|
const parent = self.commands.values.find(x => x.name === parentName);
|
|
12
|
-
const fullCommandName = `${parentName}${groupName ? ` ${groupName} ${subcommandName}` : ` ${subcommandName
|
|
12
|
+
const fullCommandName = `${parentName}${groupName ? ` ${groupName} ${subcommandName}` : `${subcommandName ? ` ${subcommandName}` : ''}`}`;
|
|
13
13
|
if (!(parent instanceof __1.Command))
|
|
14
14
|
return { fullCommandName };
|
|
15
15
|
if (groupName && !parent.groups?.[groupName])
|
|
16
|
-
return getCommandFromContent([parentName,
|
|
16
|
+
return getCommandFromContent([parentName, groupName], self);
|
|
17
17
|
if (subcommandName && !parent.options?.some(x => x instanceof __1.SubCommand && x.name === subcommandName))
|
|
18
18
|
return getCommandFromContent([parentName], self);
|
|
19
19
|
const command = groupName || subcommandName
|
|
@@ -50,7 +50,8 @@ async function onMessageCreate(self, rawMessage, shardId) {
|
|
|
50
50
|
return;
|
|
51
51
|
if (!command.run)
|
|
52
52
|
return self.logger.warn(`${fullCommandName} command does not have 'run' callback`);
|
|
53
|
-
if (
|
|
53
|
+
if ([__1.InteractionContextTypes.BOT_DM, __1.InteractionContextTypes.PRIVATE_CHANNEL].some(i => command.contexts?.includes(i)) &&
|
|
54
|
+
!message.guildId)
|
|
54
55
|
return;
|
|
55
56
|
if (command.guild_id && !command.guild_id?.includes(message.guildId))
|
|
56
57
|
return;
|
|
@@ -64,7 +65,10 @@ async function onMessageCreate(self, rawMessage, shardId) {
|
|
|
64
65
|
const args = (self.options?.commands?.argsParser ?? defaultArgsParser)(content, command);
|
|
65
66
|
const { options, errors } = await parseOptions(self, command, rawMessage, args, resolved);
|
|
66
67
|
const optionsResolver = new __1.OptionResolver(self, options, parent, message.guildId, resolved);
|
|
67
|
-
const context = new __1.CommandContext(self, message, optionsResolver, shardId);
|
|
68
|
+
const context = new __1.CommandContext(self, message, optionsResolver, shardId, command);
|
|
69
|
+
//@ts-expect-error
|
|
70
|
+
const extendContext = self.options?.context?.(message) ?? {};
|
|
71
|
+
Object.assign(context, extendContext);
|
|
68
72
|
try {
|
|
69
73
|
if (command.botPermissions && message.guildId) {
|
|
70
74
|
const meMember = await self.cache.members?.get(self.botId, message.guildId);
|
|
@@ -128,119 +132,192 @@ async function parseOptions(self, command, message, args, resolved) {
|
|
|
128
132
|
const options = [];
|
|
129
133
|
const errors = [];
|
|
130
134
|
for (const i of (command.options ?? [])) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
if (
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
135
|
+
try {
|
|
136
|
+
let value;
|
|
137
|
+
let indexAttachment = -1;
|
|
138
|
+
switch (i.type) {
|
|
139
|
+
case v10_1.ApplicationCommandOptionType.Attachment:
|
|
140
|
+
if (message.attachments[++indexAttachment]) {
|
|
141
|
+
value = message.attachments[indexAttachment].id;
|
|
142
|
+
resolved.attachments[value] = message.attachments[indexAttachment];
|
|
143
|
+
}
|
|
144
|
+
break;
|
|
145
|
+
case v10_1.ApplicationCommandOptionType.Boolean:
|
|
146
|
+
if (args[i.name]) {
|
|
147
|
+
value = ['yes', 'y', 'true', 'treu'].includes(args[i.name].toLowerCase());
|
|
148
|
+
}
|
|
149
|
+
break;
|
|
150
|
+
case v10_1.ApplicationCommandOptionType.Channel:
|
|
151
|
+
{
|
|
152
|
+
const rawId = message.content.match(/(?<=<#)[0-9]{17,19}(?=>)/g)?.find(x => args[i.name]?.includes(x)) ||
|
|
153
|
+
args[i.name]?.match(/[0-9]{17,19}/g)?.[0];
|
|
154
|
+
if (rawId) {
|
|
155
|
+
const channel = (await self.cache.channels?.get(rawId)) ?? (i.required ? await self.channels.fetch(rawId) : undefined);
|
|
156
|
+
if (channel) {
|
|
157
|
+
if ('channel_types' in i) {
|
|
158
|
+
if (!i.channel_types.includes(channel.type)) {
|
|
159
|
+
errors.push({
|
|
160
|
+
name: i.name,
|
|
161
|
+
error: `The entered channel type is not one of ${i
|
|
162
|
+
.channel_types.map(t => v10_1.ChannelType[t])
|
|
163
|
+
.join(', ')}`,
|
|
164
|
+
});
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
160
167
|
}
|
|
168
|
+
value = rawId;
|
|
169
|
+
resolved.channels[rawId] = channel;
|
|
161
170
|
}
|
|
162
|
-
value = rawId;
|
|
163
|
-
//@ts-expect-error
|
|
164
|
-
resolved.channels[rawId] = channel;
|
|
165
171
|
}
|
|
166
172
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
173
|
+
break;
|
|
174
|
+
case v10_1.ApplicationCommandOptionType.Mentionable:
|
|
175
|
+
{
|
|
176
|
+
const matches = message.content.match(/<@[0-9]{17,19}(?=>)|<@&[0-9]{17,19}(?=>)/g) ?? [];
|
|
177
|
+
for (const match of matches) {
|
|
178
|
+
if (match.includes('&')) {
|
|
179
|
+
const rawId = match.slice(3);
|
|
180
|
+
if (rawId) {
|
|
181
|
+
const role = (await self.cache.roles?.get(rawId)) ??
|
|
182
|
+
(i.required ? (await self.roles.list(message.guild_id)).find(x => x.id === rawId) : undefined);
|
|
183
|
+
if (role) {
|
|
184
|
+
value = rawId;
|
|
185
|
+
resolved.roles[rawId] = role;
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
const rawId = match.slice(2);
|
|
192
|
+
const raw = message.mentions.find(x => rawId === x.id);
|
|
193
|
+
if (raw) {
|
|
194
|
+
const { member, ...user } = raw;
|
|
195
|
+
value = raw.id;
|
|
196
|
+
resolved.users[raw.id] = user;
|
|
197
|
+
if (member)
|
|
198
|
+
resolved.members[raw.id] = member;
|
|
183
199
|
break;
|
|
184
200
|
}
|
|
185
201
|
}
|
|
186
202
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
203
|
+
}
|
|
204
|
+
break;
|
|
205
|
+
case v10_1.ApplicationCommandOptionType.Role:
|
|
206
|
+
{
|
|
207
|
+
const rawId = message.mention_roles.find(x => args[i.name]?.includes(x)) || args[i.name]?.match(/[0-9]{17,19}/g)?.[0];
|
|
208
|
+
if (rawId) {
|
|
209
|
+
const role = (await self.cache.roles?.get(rawId)) ??
|
|
210
|
+
(i.required ? (await self.roles.list(message.guild_id)).find(x => x.id === rawId) : undefined);
|
|
211
|
+
if (role) {
|
|
212
|
+
value = rawId;
|
|
213
|
+
resolved.roles[rawId] = role;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
break;
|
|
218
|
+
case v10_1.ApplicationCommandOptionType.User:
|
|
219
|
+
{
|
|
220
|
+
const rawId = message.mentions.find(x => args[i.name]?.includes(x.id))?.id || args[i.name]?.match(/[0-9]{17,19}/g)?.[0];
|
|
221
|
+
if (rawId) {
|
|
222
|
+
const raw = message.mentions.find(x => args[i.name]?.includes(x.id)) ??
|
|
223
|
+
(await self.cache.users?.get(rawId)) ??
|
|
224
|
+
(i.required ? await self.users.fetch(rawId) : undefined);
|
|
190
225
|
if (raw) {
|
|
191
226
|
value = raw.id;
|
|
192
|
-
|
|
193
|
-
|
|
227
|
+
if (raw instanceof __1.User) {
|
|
228
|
+
resolved.users[raw.id] = raw;
|
|
229
|
+
if (message.guild_id) {
|
|
230
|
+
const member = message.mentions.find(x => args[i.name]?.includes(x.id))?.member ??
|
|
231
|
+
(await self.cache.members?.get(rawId, message.guild_id)) ??
|
|
232
|
+
(i.required ? await self.members.fetch(rawId, message.guild_id) : undefined);
|
|
233
|
+
if (member)
|
|
234
|
+
resolved.members[raw.id] = member;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
const { member, ...user } = raw;
|
|
239
|
+
resolved.users[user.id] = user;
|
|
240
|
+
if (member)
|
|
241
|
+
resolved.members[user.id] = member;
|
|
242
|
+
}
|
|
194
243
|
}
|
|
195
244
|
}
|
|
196
245
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
246
|
+
break;
|
|
247
|
+
case v10_1.ApplicationCommandOptionType.String:
|
|
248
|
+
{
|
|
249
|
+
value = args[i.name];
|
|
250
|
+
const option = i;
|
|
251
|
+
if (value) {
|
|
252
|
+
if (option.min_length) {
|
|
253
|
+
if (value.length < option.min_length) {
|
|
254
|
+
value = undefined;
|
|
255
|
+
errors.push({
|
|
256
|
+
name: i.name,
|
|
257
|
+
error: `The entered string has less than ${option.min_length} characters. The minimum required is ${option.min_length} characters.`,
|
|
258
|
+
});
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
if (option.max_length) {
|
|
263
|
+
if (value.length > option.max_length) {
|
|
264
|
+
value = undefined;
|
|
265
|
+
errors.push({
|
|
266
|
+
name: i.name,
|
|
267
|
+
error: `The entered string has more than ${option.max_length} characters. The maximum required is ${option.max_length} characters.`,
|
|
268
|
+
});
|
|
269
|
+
break;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
if (option.choices?.length) {
|
|
273
|
+
if (!option.choices.some(x => x.name === value)) {
|
|
274
|
+
value = undefined;
|
|
275
|
+
errors.push({
|
|
276
|
+
name: i.name,
|
|
277
|
+
error: `The entered choice is invalid. Please choose one of the following options: ${option.choices
|
|
278
|
+
.map(x => x.name)
|
|
279
|
+
.join(', ')}.`,
|
|
280
|
+
});
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
value = option.choices.find(x => x.name === value).value;
|
|
284
|
+
}
|
|
210
285
|
}
|
|
211
286
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
287
|
+
break;
|
|
288
|
+
case v10_1.ApplicationCommandOptionType.Number:
|
|
289
|
+
case v10_1.ApplicationCommandOptionType.Integer:
|
|
290
|
+
{
|
|
291
|
+
value = Number(args[i.name]);
|
|
292
|
+
if (args[i.name] === undefined) {
|
|
293
|
+
value = undefined;
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
if (Number.isNaN(value)) {
|
|
297
|
+
value = undefined;
|
|
298
|
+
errors.push({
|
|
299
|
+
name: i.name,
|
|
300
|
+
error: 'The entered choice is an invalid number.',
|
|
301
|
+
});
|
|
302
|
+
break;
|
|
303
|
+
}
|
|
304
|
+
const option = i;
|
|
305
|
+
if (option.min_value) {
|
|
306
|
+
if (value < option.min_value) {
|
|
230
307
|
value = undefined;
|
|
231
308
|
errors.push({
|
|
232
309
|
name: i.name,
|
|
233
|
-
error: `The entered
|
|
310
|
+
error: `The entered number is less than ${option.min_value}. The minimum allowed is ${option.min_value}`,
|
|
234
311
|
});
|
|
235
312
|
break;
|
|
236
313
|
}
|
|
237
314
|
}
|
|
238
|
-
if (option.
|
|
239
|
-
if (value
|
|
315
|
+
if (option.max_value) {
|
|
316
|
+
if (value > option.max_value) {
|
|
240
317
|
value = undefined;
|
|
241
318
|
errors.push({
|
|
242
319
|
name: i.name,
|
|
243
|
-
error: `The entered
|
|
320
|
+
error: `The entered number is greater than ${option.max_value}. The maximum allowed is ${option.max_value}`,
|
|
244
321
|
});
|
|
245
322
|
break;
|
|
246
323
|
}
|
|
@@ -259,68 +336,27 @@ async function parseOptions(self, command, message, args, resolved) {
|
|
|
259
336
|
value = option.choices.find(x => x.name === value).value;
|
|
260
337
|
}
|
|
261
338
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
break;
|
|
279
|
-
}
|
|
280
|
-
const option = i;
|
|
281
|
-
if (option.min_value) {
|
|
282
|
-
if (value < option.min_value) {
|
|
283
|
-
value = undefined;
|
|
284
|
-
errors.push({
|
|
285
|
-
name: i.name,
|
|
286
|
-
error: `The entered number is less than ${option.min_value}. The minimum allowed is ${option.min_value}`,
|
|
287
|
-
});
|
|
288
|
-
break;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
if (option.max_value) {
|
|
292
|
-
if (value > option.max_value) {
|
|
293
|
-
value = undefined;
|
|
294
|
-
errors.push({
|
|
295
|
-
name: i.name,
|
|
296
|
-
error: `The entered number is greater than ${option.max_value}. The maximum allowed is ${option.max_value}`,
|
|
297
|
-
});
|
|
298
|
-
break;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
if (option.choices?.length) {
|
|
302
|
-
if (!option.choices.some(x => x.name === value)) {
|
|
303
|
-
value = undefined;
|
|
304
|
-
errors.push({
|
|
305
|
-
name: i.name,
|
|
306
|
-
error: `The entered choice is invalid. Please choose one of the following options: ${option.choices
|
|
307
|
-
.map(x => x.name)
|
|
308
|
-
.join(', ')}.`,
|
|
309
|
-
});
|
|
310
|
-
break;
|
|
311
|
-
}
|
|
312
|
-
value = option.choices.find(x => x.name === value).value;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
break;
|
|
316
|
-
default:
|
|
317
|
-
break;
|
|
339
|
+
break;
|
|
340
|
+
default:
|
|
341
|
+
break;
|
|
342
|
+
}
|
|
343
|
+
if (value !== undefined) {
|
|
344
|
+
options.push({
|
|
345
|
+
name: i.name,
|
|
346
|
+
type: i.type,
|
|
347
|
+
value,
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
else if (i.required)
|
|
351
|
+
errors.push({
|
|
352
|
+
error: 'Option is required but returned undefined',
|
|
353
|
+
name: i.name,
|
|
354
|
+
});
|
|
318
355
|
}
|
|
319
|
-
|
|
320
|
-
|
|
356
|
+
catch (e) {
|
|
357
|
+
errors.push({
|
|
358
|
+
error: e && typeof e === 'object' && 'message' in e ? e.message : `${e}`,
|
|
321
359
|
name: i.name,
|
|
322
|
-
type: i.type,
|
|
323
|
-
value,
|
|
324
360
|
});
|
|
325
361
|
}
|
|
326
362
|
}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
/// <reference types="node" />
|
|
5
|
+
/// <reference types="node" />
|
|
1
6
|
import type { Cache } from '../cache';
|
|
2
7
|
import type { GatewayDispatchPayload, When } from '../common';
|
|
3
8
|
import { Logger, type DeepPartial } from '../common';
|
|
@@ -14,13 +19,22 @@ export declare class WorkerClient<Ready extends boolean = boolean> extends BaseC
|
|
|
14
19
|
logger: Logger;
|
|
15
20
|
events: EventHandler;
|
|
16
21
|
me: When<Ready, ClientUser>;
|
|
22
|
+
promises: Map<string, {
|
|
23
|
+
resolve: (value: any) => void;
|
|
24
|
+
timeout: NodeJS.Timeout;
|
|
25
|
+
}>;
|
|
17
26
|
shards: Map<number, Shard>;
|
|
18
27
|
options: WorkerClientOptions | undefined;
|
|
19
28
|
constructor(options?: WorkerClientOptions);
|
|
20
29
|
get workerId(): number;
|
|
30
|
+
get latency(): number;
|
|
21
31
|
start(options?: Omit<DeepPartial<StartOptions>, 'httpConnection' | 'token' | 'connection'>): Promise<void>;
|
|
22
32
|
loadEvents(dir?: string): Promise<void>;
|
|
23
|
-
|
|
33
|
+
postMessage(body: any): boolean | void;
|
|
34
|
+
protected handleManagerMessages(data: ManagerMessages): Promise<any>;
|
|
35
|
+
private generateNonce;
|
|
36
|
+
private generateSendPromise;
|
|
37
|
+
tellWorker(workerId: number, func: (_: this) => {}): Promise<unknown>;
|
|
24
38
|
protected onPacket(packet: GatewayDispatchPayload, shardId: number): Promise<void>;
|
|
25
39
|
}
|
|
26
40
|
export declare function generateShardInfo(shard: Shard): WorkerShardInfo;
|