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