seyfert 1.4.0 → 1.5.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.
Files changed (85) hide show
  1. package/README.md +7 -7
  2. package/lib/api/Router.js +3 -1
  3. package/lib/api/Routes/guilds.d.ts +4 -1
  4. package/lib/cache/index.d.ts +6 -2
  5. package/lib/cache/index.js +18 -0
  6. package/lib/cache/resources/bans.d.ts +12 -0
  7. package/lib/cache/resources/bans.js +35 -0
  8. package/lib/cache/resources/members.js +4 -4
  9. package/lib/cache/resources/messages.js +8 -6
  10. package/lib/client/base.d.ts +7 -3
  11. package/lib/client/base.js +43 -24
  12. package/lib/client/client.d.ts +17 -5
  13. package/lib/client/client.js +39 -43
  14. package/lib/client/collectors.d.ts +36 -0
  15. package/lib/client/collectors.js +85 -0
  16. package/lib/client/httpclient.js +6 -6
  17. package/lib/client/onmessagecreate.d.ts +12 -2
  18. package/lib/client/onmessagecreate.js +32 -17
  19. package/lib/client/workerclient.d.ts +4 -1
  20. package/lib/client/workerclient.js +59 -67
  21. package/lib/collection.d.ts +2 -2
  22. package/lib/collection.js +2 -2
  23. package/lib/commands/applications/chat.d.ts +10 -9
  24. package/lib/commands/applications/chat.js +21 -7
  25. package/lib/commands/applications/menu.d.ts +8 -7
  26. package/lib/commands/applications/menu.js +3 -2
  27. package/lib/commands/applications/shared.d.ts +12 -0
  28. package/lib/commands/decorators.d.ts +11 -17
  29. package/lib/commands/decorators.js +7 -14
  30. package/lib/commands/handler.js +39 -29
  31. package/lib/common/index.d.ts +1 -0
  32. package/lib/common/index.js +3 -1
  33. package/lib/common/it/formatter.d.ts +155 -0
  34. package/lib/common/it/formatter.js +184 -0
  35. package/lib/common/it/logger.js +5 -5
  36. package/lib/common/it/utils.js +2 -4
  37. package/lib/common/shorters/bans.d.ts +43 -0
  38. package/lib/common/shorters/bans.js +78 -0
  39. package/lib/common/shorters/emojis.d.ts +1 -1
  40. package/lib/common/shorters/emojis.js +4 -3
  41. package/lib/common/shorters/interaction.js +9 -7
  42. package/lib/common/shorters/messages.js +2 -2
  43. package/lib/common/shorters/webhook.js +2 -2
  44. package/lib/components/componentcommand.d.ts +3 -2
  45. package/lib/components/componentcommand.js +2 -1
  46. package/lib/components/componentcontext.d.ts +1 -1
  47. package/lib/components/handler.d.ts +1 -1
  48. package/lib/components/handler.js +25 -28
  49. package/lib/components/modalcommand.d.ts +2 -1
  50. package/lib/components/modalcommand.js +1 -0
  51. package/lib/components/modalcontext.d.ts +1 -1
  52. package/lib/events/event.d.ts +4 -3
  53. package/lib/events/handler.d.ts +8 -5
  54. package/lib/events/handler.js +58 -13
  55. package/lib/events/hooks/guild.d.ts +18 -73
  56. package/lib/events/hooks/integration.d.ts +57 -0
  57. package/lib/events/hooks/invite.d.ts +3 -0
  58. package/lib/events/hooks/message.d.ts +11 -6
  59. package/lib/events/hooks/presence.d.ts +4 -0
  60. package/lib/events/hooks/thread.d.ts +14 -3
  61. package/lib/events/hooks/typing.d.ts +1 -0
  62. package/lib/index.d.ts +3 -3
  63. package/lib/index.js +3 -2
  64. package/lib/structures/Guild.d.ts +9 -1
  65. package/lib/structures/Guild.js +2 -0
  66. package/lib/structures/GuildBan.d.ts +25 -0
  67. package/lib/structures/GuildBan.js +36 -0
  68. package/lib/structures/GuildEmoji.d.ts +1 -1
  69. package/lib/structures/GuildMember.d.ts +7 -2
  70. package/lib/structures/GuildMember.js +4 -4
  71. package/lib/structures/Interaction.d.ts +3 -2
  72. package/lib/structures/Interaction.js +21 -9
  73. package/lib/structures/Message.d.ts +69 -8
  74. package/lib/structures/Message.js +59 -17
  75. package/lib/structures/Sticker.d.ts +3 -3
  76. package/lib/structures/User.d.ts +1 -0
  77. package/lib/structures/User.js +4 -1
  78. package/lib/structures/channels.d.ts +4 -1
  79. package/lib/structures/channels.js +36 -6
  80. package/lib/structures/extra/functions.js +1 -1
  81. package/lib/websocket/discord/basesocket.d.ts +1 -0
  82. package/lib/websocket/discord/basesocket.js +17 -0
  83. package/lib/websocket/discord/shard.d.ts +1 -0
  84. package/lib/websocket/discord/shard.js +6 -0
  85. package/package.json +8 -8
@@ -12,6 +12,7 @@ const websocket_1 = require("../websocket");
12
12
  const base_1 = require("./base");
13
13
  const oninteractioncreate_1 = require("./oninteractioncreate");
14
14
  const onmessagecreate_1 = require("./onmessagecreate");
15
+ const collectors_1 = require("./collectors");
15
16
  let workerData;
16
17
  let manager;
17
18
  try {
@@ -31,12 +32,19 @@ class WorkerClient extends base_1.BaseClient {
31
32
  logger = new __1.Logger({
32
33
  name: `[Worker #${workerData.workerId}]`,
33
34
  });
34
- events = new events_1.EventHandler(this.logger);
35
+ collectors = new collectors_1.Collectors();
36
+ events = new events_1.EventHandler(this);
35
37
  me;
36
38
  promises = new Map();
37
39
  shards = new Map();
38
40
  constructor(options) {
39
41
  super(options);
42
+ this.options = (0, common_1.MergeOptions)({
43
+ commands: {
44
+ argsParser: onmessagecreate_1.defaultArgsParser,
45
+ optionsParser: onmessagecreate_1.defaultOptionsParser,
46
+ },
47
+ }, this.options);
40
48
  if (!process.env.SEYFERT_SPAWNING) {
41
49
  throw new Error('WorkerClient cannot spawn without manager');
42
50
  }
@@ -86,7 +94,7 @@ class WorkerClient extends base_1.BaseClient {
86
94
  this.events = undefined;
87
95
  }
88
96
  else if (typeof rest.handlers.events === 'function') {
89
- this.events = new events_1.EventHandler(this.logger);
97
+ this.events = new events_1.EventHandler(this);
90
98
  this.events.setHandlers({
91
99
  callback: rest.handlers.events,
92
100
  });
@@ -165,9 +173,12 @@ class WorkerClient extends base_1.BaseClient {
165
173
  info: data.info,
166
174
  compress: data.compress,
167
175
  debugger: this.debugger,
176
+ properties: {
177
+ ...websocket_1.properties,
178
+ ...this.options.gateway?.properties,
179
+ },
168
180
  async handlePayload(shardId, payload) {
169
181
  await handlePayload?.(shardId, payload);
170
- await self.cache.onPacket(payload);
171
182
  await onPacket?.(payload, shardId);
172
183
  self.postMessage({
173
184
  workerId: workerData.workerId,
@@ -231,8 +242,8 @@ class WorkerClient extends base_1.BaseClient {
231
242
  let result;
232
243
  try {
233
244
  // biome-ignore lint/security/noGlobalEval: yes
234
- result = await eval(`
235
- (${data.func})(this)
245
+ result = await eval(`
246
+ (${data.func})(this)
236
247
  `);
237
248
  }
238
249
  catch (e) {
@@ -288,74 +299,55 @@ class WorkerClient extends base_1.BaseClient {
288
299
  async onPacket(packet, shardId) {
289
300
  await this.events?.execute('RAW', packet, this, shardId);
290
301
  switch (packet.t) {
291
- case 'GUILD_MEMBER_UPDATE':
292
- case 'PRESENCE_UPDATE':
293
- case 'MESSAGE_UPDATE':
294
- case 'MESSAGE_DELETE_BULK':
295
- case 'MESSAGE_DELETE':
296
- case 'GUILD_DELETE':
297
- case 'CHANNEL_UPDATE':
298
- case 'GUILD_EMOJIS_UPDATE':
299
- case 'GUILD_UPDATE':
300
- case 'GUILD_ROLE_UPDATE':
301
- case 'GUILD_ROLE_DELETE':
302
- case 'THREAD_UPDATE':
303
- case 'USER_UPDATE':
304
- case 'VOICE_STATE_UPDATE':
305
- case 'STAGE_INSTANCE_UPDATE':
306
- case 'GUILD_STICKERS_UPDATE':
302
+ case 'GUILD_CREATE': {
303
+ if (this.__handleGuilds?.has(packet.d.id)) {
304
+ this.__handleGuilds.delete(packet.d.id);
305
+ if (!this.__handleGuilds.size && [...this.shards.values()].every(shard => shard.data.session_id)) {
306
+ this.postMessage({
307
+ type: 'WORKER_READY',
308
+ workerId: this.workerId,
309
+ });
310
+ await this.events?.runEvent('WORKER_READY', this, this.me, -1);
311
+ }
312
+ if (!this.__handleGuilds.size)
313
+ delete this.__handleGuilds;
314
+ return this.cache.onPacket(packet);
315
+ }
307
316
  await this.events?.execute(packet.t, packet, this, shardId);
308
- await this.cache.onPacket(packet);
309
317
  break;
310
- //rest of the events
311
- default:
312
- {
313
- switch (packet.t) {
314
- case 'READY':
315
- for (const g of packet.d.guilds) {
316
- this.__handleGuilds?.add(g.id);
317
- }
318
- this.botId = packet.d.user.id;
319
- this.applicationId = packet.d.application.id;
320
- this.me = new structures_1.ClientUser(this, packet.d.user, packet.d.application);
321
- if (!this.__handleGuilds?.size ||
322
- !((workerData.intents & v10_1.GatewayIntentBits.Guilds) === v10_1.GatewayIntentBits.Guilds)) {
323
- if ([...this.shards.values()].every(shard => shard.data.session_id)) {
324
- this.postMessage({
325
- type: 'WORKER_READY',
326
- workerId: this.workerId,
327
- });
328
- await this.events?.runEvent('WORKER_READY', this, this.me, -1);
329
- }
330
- delete this.__handleGuilds;
331
- }
332
- this.debugger?.debug(`#${shardId} [${packet.d.user.username}](${this.botId}) is online...`);
333
- break;
334
- case 'INTERACTION_CREATE':
335
- await (0, oninteractioncreate_1.onInteractionCreate)(this, packet.d, shardId);
336
- break;
337
- case 'MESSAGE_CREATE':
338
- await (0, onmessagecreate_1.onMessageCreate)(this, packet.d, shardId);
339
- break;
340
- case 'GUILD_CREATE': {
341
- if (this.__handleGuilds?.has(packet.d.id)) {
342
- this.__handleGuilds.delete(packet.d.id);
343
- if (!this.__handleGuilds.size && [...this.shards.values()].every(shard => shard.data.session_id)) {
344
- this.postMessage({
345
- type: 'WORKER_READY',
346
- workerId: this.workerId,
347
- });
348
- await this.events?.runEvent('WORKER_READY', this, this.me, -1);
349
- }
350
- if (!this.__handleGuilds.size)
351
- delete this.__handleGuilds;
352
- return;
318
+ }
319
+ default: {
320
+ await this.events?.execute(packet.t, packet, this, shardId);
321
+ switch (packet.t) {
322
+ case 'READY':
323
+ for (const g of packet.d.guilds) {
324
+ this.__handleGuilds?.add(g.id);
325
+ }
326
+ this.botId = packet.d.user.id;
327
+ this.applicationId = packet.d.application.id;
328
+ this.me = new structures_1.ClientUser(this, packet.d.user, packet.d.application);
329
+ if (!(this.__handleGuilds?.size &&
330
+ (workerData.intents & v10_1.GatewayIntentBits.Guilds) === v10_1.GatewayIntentBits.Guilds)) {
331
+ if ([...this.shards.values()].every(shard => shard.data.session_id)) {
332
+ this.postMessage({
333
+ type: 'WORKER_READY',
334
+ workerId: this.workerId,
335
+ });
336
+ await this.events?.runEvent('WORKER_READY', this, this.me, -1);
353
337
  }
338
+ delete this.__handleGuilds;
354
339
  }
355
- }
356
- await this.events?.execute(packet.t, packet, this, shardId);
340
+ this.debugger?.debug(`#${shardId} [${packet.d.user.username}](${this.botId}) is online...`);
341
+ break;
342
+ case 'INTERACTION_CREATE':
343
+ await (0, oninteractioncreate_1.onInteractionCreate)(this, packet.d, shardId);
344
+ break;
345
+ case 'MESSAGE_CREATE':
346
+ await (0, onmessagecreate_1.onMessageCreate)(this, packet.d, shardId);
347
+ break;
357
348
  }
358
349
  break;
350
+ }
359
351
  }
360
352
  }
361
353
  }
@@ -229,8 +229,8 @@ export declare class LimitedCollection<K, V> {
229
229
  private resetTimeout;
230
230
  private stopTimeout;
231
231
  private startTimeout;
232
- keys(): () => IterableIterator<K>;
233
- values(): () => IterableIterator<LimitedCollectionData<V>>;
232
+ keys(): IterableIterator<K>;
233
+ values(): IterableIterator<LimitedCollectionData<V>>;
234
234
  entries(): IterableIterator<[K, LimitedCollectionData<V>]>;
235
235
  clear(): void;
236
236
  private clearExpired;
package/lib/collection.js CHANGED
@@ -365,10 +365,10 @@ class LimitedCollection {
365
365
  }, expireOn - Date.now());
366
366
  }
367
367
  keys() {
368
- return this.data.keys;
368
+ return this.data.keys();
369
369
  }
370
370
  values() {
371
- return this.data.values;
371
+ return this.data.values();
372
372
  }
373
373
  entries() {
374
374
  return this.data.entries();
@@ -1,11 +1,11 @@
1
- import { ApplicationCommandOptionType, ApplicationCommandType, type APIApplicationCommandBasicOption, type APIApplicationCommandOption, type LocaleString } from 'discord-api-types/v10';
1
+ import { ApplicationCommandOptionType, ApplicationCommandType, type ApplicationIntegrationType, type InteractionContextType, type APIApplicationCommandBasicOption, type APIApplicationCommandOption, type LocaleString } from 'discord-api-types/v10';
2
2
  import type { PermissionStrings, SeyfertNumberOption, SeyfertStringOption } from '../..';
3
3
  import type { Attachment } from '../../builders';
4
4
  import { type FlatObjectKeys } from '../../common';
5
5
  import type { AllChannels, AutocompleteInteraction, GuildRole, InteractionGuildMember, User } from '../../structures';
6
- import type { Groups, IntegrationTypes, InteractionContextTypes, RegisteredMiddlewares } from '../decorators';
6
+ import type { Groups, RegisteredMiddlewares } from '../decorators';
7
7
  import type { CommandContext } from './chatcontext';
8
- import type { DefaultLocale, IgnoreCommand, OKFunction, OnOptionsReturnObject, StopFunction, UsingClient } from './shared';
8
+ import type { DefaultLocale, ExtraProps, IgnoreCommand, OKFunction, OnOptionsReturnObject, StopFunction, UsingClient } from './shared';
9
9
  export interface ReturnOptionsTypes {
10
10
  1: never;
11
11
  2: never;
@@ -78,14 +78,15 @@ export declare class BaseCommand {
78
78
  nsfw?: boolean;
79
79
  description: string;
80
80
  defaultMemberPermissions?: bigint;
81
- integrationTypes?: IntegrationTypes[];
82
- contexts?: InteractionContextTypes[];
81
+ integrationTypes: ApplicationIntegrationType[];
82
+ contexts: InteractionContextType[];
83
83
  botPermissions?: bigint;
84
84
  name_localizations?: Partial<Record<LocaleString, string>>;
85
85
  description_localizations?: Partial<Record<LocaleString, string>>;
86
86
  options?: CommandOption[] | SubCommand[];
87
87
  ignore?: IgnoreCommand;
88
88
  aliases?: string[];
89
+ props: ExtraProps;
89
90
  toJSON(): {
90
91
  name: BaseCommand['name'];
91
92
  type: BaseCommand['type'];
@@ -127,8 +128,8 @@ export declare class Command extends BaseCommand {
127
128
  description_localizations: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>> | undefined;
128
129
  guild_id: string[] | undefined;
129
130
  default_member_permissions: string;
130
- contexts: InteractionContextTypes[] | undefined;
131
- integration_types: IntegrationTypes[] | undefined;
131
+ contexts: InteractionContextType[];
132
+ integration_types: ApplicationIntegrationType[];
132
133
  };
133
134
  }
134
135
  export declare abstract class SubCommand extends BaseCommand {
@@ -145,8 +146,8 @@ export declare abstract class SubCommand extends BaseCommand {
145
146
  description_localizations: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>> | undefined;
146
147
  guild_id: string[] | undefined;
147
148
  default_member_permissions: string;
148
- contexts: InteractionContextTypes[] | undefined;
149
- integration_types: IntegrationTypes[] | undefined;
149
+ contexts: InteractionContextType[];
150
+ integration_types: ApplicationIntegrationType[];
150
151
  };
151
152
  abstract run(context: CommandContext<any>): any;
152
153
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SubCommand = exports.Command = exports.BaseCommand = void 0;
4
4
  const v10_1 = require("discord-api-types/v10");
5
5
  const common_1 = require("../../common");
6
+ const node_util_1 = require("node:util");
6
7
  class BaseCommand {
7
8
  middlewares = [];
8
9
  __filePath;
@@ -14,14 +15,15 @@ class BaseCommand {
14
15
  nsfw;
15
16
  description;
16
17
  defaultMemberPermissions;
17
- integrationTypes;
18
- contexts;
18
+ integrationTypes = [];
19
+ contexts = [];
19
20
  botPermissions;
20
21
  name_localizations;
21
22
  description_localizations;
22
23
  options;
23
24
  ignore;
24
25
  aliases;
26
+ props = {};
25
27
  /** @internal */
26
28
  async __runOptions(ctx, resolver) {
27
29
  if (!this?.options?.length) {
@@ -33,8 +35,17 @@ class BaseCommand {
33
35
  try {
34
36
  const option = this.options.find(x => x.name === i.name);
35
37
  const value = resolver.getHoisted(i.name)?.value !== undefined
36
- ? await new Promise((res, rej) => option.value?.({ context: ctx, value: resolver.getValue(i.name) }, res, rej) ||
37
- res(resolver.getValue(i.name)))
38
+ ? await new Promise(
39
+ // biome-ignore lint/suspicious/noAsyncPromiseExecutor: yes
40
+ async (res, rej) => {
41
+ try {
42
+ (await option.value?.({ context: ctx, value: resolver.getValue(i.name) }, res, rej)) ||
43
+ res(resolver.getValue(i.name));
44
+ }
45
+ catch (e) {
46
+ rej(e);
47
+ }
48
+ })
38
49
  : undefined;
39
50
  if (value === undefined) {
40
51
  if (option.required) {
@@ -42,6 +53,7 @@ class BaseCommand {
42
53
  data[i.name] = {
43
54
  failed: true,
44
55
  value: `${i.name} is required but returned no value`,
56
+ parseError: undefined,
45
57
  };
46
58
  continue;
47
59
  }
@@ -57,7 +69,8 @@ class BaseCommand {
57
69
  errored = true;
58
70
  data[i.name] = {
59
71
  failed: true,
60
- value: e instanceof Error ? e.message : `${e}`,
72
+ value: e instanceof Error ? e.message : typeof e === 'string' ? e : (0, node_util_1.inspect)(e),
73
+ parseError: undefined,
61
74
  };
62
75
  }
63
76
  }
@@ -83,6 +96,7 @@ class BaseCommand {
83
96
  return;
84
97
  }
85
98
  // biome-ignore lint/style/noArguments: yes
99
+ // biome-ignore lint/correctness/noUndeclaredVariables: xd
86
100
  if (arguments.length) {
87
101
  // @ts-expect-error
88
102
  context[global ? 'globalMetadata' : 'metadata'][middlewares[index]] = obj;
@@ -115,7 +129,7 @@ class BaseCommand {
115
129
  const data = {
116
130
  name: this.name,
117
131
  type: this.type,
118
- nsfw: this.nsfw || false,
132
+ nsfw: !!this.nsfw,
119
133
  description: this.description,
120
134
  name_localizations: this.name_localizations,
121
135
  description_localizations: this.description_localizations,
@@ -180,7 +194,7 @@ class SubCommand extends BaseCommand {
180
194
  toJSON() {
181
195
  return {
182
196
  ...super.toJSON(),
183
- options: (this.options ?? []).map(x => ({ ...x, autocomplete: 'autocomplete' in x })),
197
+ options: this.options?.map(x => ({ ...x, autocomplete: 'autocomplete' in x })) ?? [],
184
198
  };
185
199
  }
186
200
  }
@@ -1,8 +1,8 @@
1
- import type { ApplicationCommandType, LocaleString } from 'discord-api-types/v10';
1
+ import type { ApplicationCommandType, ApplicationIntegrationType, InteractionContextType, LocaleString } from 'discord-api-types/v10';
2
2
  import { type PermissionStrings } from '../../common';
3
- import type { IntegrationTypes, InteractionContextTypes, RegisteredMiddlewares } from '../decorators';
3
+ import type { RegisteredMiddlewares } from '../decorators';
4
4
  import type { MenuCommandContext } from './menucontext';
5
- import type { UsingClient } from './shared';
5
+ import type { ExtraProps, UsingClient } from './shared';
6
6
  export declare abstract class ContextMenuCommand {
7
7
  middlewares: (keyof RegisteredMiddlewares)[];
8
8
  __filePath?: string;
@@ -14,14 +14,15 @@ export declare abstract class ContextMenuCommand {
14
14
  name: string;
15
15
  type: ApplicationCommandType.User | ApplicationCommandType.Message;
16
16
  nsfw?: boolean;
17
- integrationTypes?: IntegrationTypes[];
18
- contexts?: InteractionContextTypes[];
17
+ integrationTypes: ApplicationIntegrationType[];
18
+ contexts: InteractionContextType[];
19
19
  description: string;
20
20
  defaultMemberPermissions?: bigint;
21
21
  botPermissions?: bigint;
22
22
  dm?: boolean;
23
23
  name_localizations?: Partial<Record<LocaleString, string>>;
24
24
  description_localizations?: Partial<Record<LocaleString, string>>;
25
+ props: ExtraProps;
25
26
  toJSON(): {
26
27
  name: string;
27
28
  type: ApplicationCommandType.User | ApplicationCommandType.Message;
@@ -32,8 +33,8 @@ export declare abstract class ContextMenuCommand {
32
33
  guild_id: string[] | undefined;
33
34
  dm_permission: boolean | undefined;
34
35
  default_member_permissions: string | undefined;
35
- contexts: InteractionContextTypes[] | undefined;
36
- integration_types: IntegrationTypes[] | undefined;
36
+ contexts: InteractionContextType[];
37
+ integration_types: ApplicationIntegrationType[];
37
38
  };
38
39
  reload(): Promise<void>;
39
40
  abstract run?(context: MenuCommandContext<any>): any;
@@ -10,14 +10,15 @@ class ContextMenuCommand {
10
10
  name;
11
11
  type;
12
12
  nsfw;
13
- integrationTypes;
14
- contexts;
13
+ integrationTypes = [];
14
+ contexts = [];
15
15
  description;
16
16
  defaultMemberPermissions;
17
17
  botPermissions;
18
18
  dm;
19
19
  name_localizations;
20
20
  description_localizations;
21
+ props = {};
21
22
  toJSON() {
22
23
  return {
23
24
  name: this.name,
@@ -1,3 +1,4 @@
1
+ import type { ChannelType } from 'discord-api-types/v10';
1
2
  import type { BaseClient } from '../../client/base';
2
3
  import type { IsStrictlyUndefined } from '../../common';
3
4
  import type { RegisteredMiddlewares } from '../decorators';
@@ -14,6 +15,8 @@ export interface DefaultLocale {
14
15
  }
15
16
  export interface ExtendContext {
16
17
  }
18
+ export interface ExtraProps {
19
+ }
17
20
  export interface UsingClient extends BaseClient {
18
21
  }
19
22
  export type ParseClient<T extends BaseClient> = T;
@@ -32,12 +35,21 @@ export type CommandMetadata<T extends readonly (keyof RegisteredMiddlewares)[]>
32
35
  ] ? first extends keyof RegisteredMiddlewares ? (MetadataMiddleware<RegisteredMiddlewares[first]> extends never ? {} : {
33
36
  [key in first]: MetadataMiddleware<RegisteredMiddlewares[first]>;
34
37
  }) & (rest extends readonly (keyof RegisteredMiddlewares)[] ? CommandMetadata<rest> : {}) : {} : {};
38
+ export type MessageCommandOptionErrors = ['CHANNEL_TYPES', type: ChannelType[]] | ['STRING_MIN_LENGTH', min: number] | ['STRING_MAX_LENGTH', max: number] | ['STRING_INVALID_CHOICE', choices: readonly {
39
+ name: string;
40
+ value: string;
41
+ }[]] | ['NUMBER_NAN', value: string | undefined] | ['NUMBER_MIN_VALUE', min: number] | ['NUMBER_MAX_VALUE', max: number] | ['NUMBER_INVALID_CHOICE', choices: readonly {
42
+ name: string;
43
+ value: number;
44
+ }[]] | ['OPTION_REQUIRED'] | ['UNKNOWN', error: unknown];
35
45
  export type OnOptionsReturnObject = Record<string, {
36
46
  failed: false;
37
47
  value: unknown;
38
48
  } | {
39
49
  failed: true;
40
50
  value: string;
51
+ parseError: //only for text command
52
+ MessageCommandOptionErrors | undefined;
41
53
  }>;
42
54
  export declare enum IgnoreCommand {
43
55
  Slash = 0,
@@ -1,18 +1,9 @@
1
- import { ApplicationCommandType, type LocaleString } from 'discord-api-types/v10';
1
+ import { ApplicationCommandType, ApplicationIntegrationType, InteractionContextType, type LocaleString } from 'discord-api-types/v10';
2
2
  import type { FlatObjectKeys, PermissionStrings } from '../common';
3
3
  import type { CommandOption, OptionsRecord, SubCommand } from './applications/chat';
4
- import type { DefaultLocale, IgnoreCommand, MiddlewareContext } from './applications/shared';
4
+ import type { DefaultLocale, ExtraProps, IgnoreCommand, MiddlewareContext } from './applications/shared';
5
5
  export interface RegisteredMiddlewares {
6
6
  }
7
- export declare enum IntegrationTypes {
8
- GUILD_INSTALL = 0,
9
- USER_INSTALL = 1
10
- }
11
- export declare enum InteractionContextTypes {
12
- GUILD = 0,
13
- BOT_DM = 1,
14
- PRIVATE_CHANNEL = 2
15
- }
16
7
  type DeclareOptions = {
17
8
  name: string;
18
9
  description: string;
@@ -20,10 +11,11 @@ type DeclareOptions = {
20
11
  defaultMemberPermissions?: PermissionStrings | bigint;
21
12
  guildId?: string[];
22
13
  nsfw?: boolean;
23
- integrationTypes?: (keyof typeof IntegrationTypes)[];
24
- contexts?: (keyof typeof InteractionContextTypes)[];
14
+ integrationTypes?: (keyof typeof ApplicationIntegrationType)[];
15
+ contexts?: (keyof typeof InteractionContextType)[];
25
16
  ignore?: IgnoreCommand;
26
17
  aliases?: string[];
18
+ props?: ExtraProps;
27
19
  } | (Omit<{
28
20
  name: string;
29
21
  description: string;
@@ -31,8 +23,9 @@ type DeclareOptions = {
31
23
  defaultMemberPermissions?: PermissionStrings | bigint;
32
24
  guildId?: string[];
33
25
  nsfw?: boolean;
34
- integrationTypes?: (keyof typeof IntegrationTypes)[];
35
- contexts?: (keyof typeof InteractionContextTypes)[];
26
+ integrationTypes?: (keyof typeof ApplicationIntegrationType)[];
27
+ contexts?: (keyof typeof InteractionContextType)[];
28
+ props?: ExtraProps;
36
29
  }, 'type' | 'description'> & {
37
30
  type: ApplicationCommandType.User | ApplicationCommandType.Message;
38
31
  });
@@ -116,8 +109,9 @@ export declare function Declare(declare: DeclareOptions): <T extends new (...arg
116
109
  new (...args: any[]): {
117
110
  name: string;
118
111
  nsfw: boolean | undefined;
119
- contexts: InteractionContextTypes[] | undefined;
120
- integrationTypes: IntegrationTypes[] | undefined;
112
+ props: ExtraProps | undefined;
113
+ contexts: (string | InteractionContextType)[];
114
+ integrationTypes: ApplicationIntegrationType[];
121
115
  defaultMemberPermissions: bigint | undefined;
122
116
  botPermissions: bigint | undefined;
123
117
  description: string;
@@ -1,18 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Declare = exports.Middlewares = exports.AutoLoad = exports.Options = exports.Group = exports.Groups = exports.GroupsT = exports.LocalesT = exports.Locales = exports.InteractionContextTypes = exports.IntegrationTypes = void 0;
3
+ exports.Declare = exports.Middlewares = exports.AutoLoad = exports.Options = exports.Group = exports.Groups = exports.GroupsT = exports.LocalesT = exports.Locales = void 0;
4
4
  const v10_1 = require("discord-api-types/v10");
5
- var IntegrationTypes;
6
- (function (IntegrationTypes) {
7
- IntegrationTypes[IntegrationTypes["GUILD_INSTALL"] = 0] = "GUILD_INSTALL";
8
- IntegrationTypes[IntegrationTypes["USER_INSTALL"] = 1] = "USER_INSTALL";
9
- })(IntegrationTypes || (exports.IntegrationTypes = IntegrationTypes = {}));
10
- var InteractionContextTypes;
11
- (function (InteractionContextTypes) {
12
- InteractionContextTypes[InteractionContextTypes["GUILD"] = 0] = "GUILD";
13
- InteractionContextTypes[InteractionContextTypes["BOT_DM"] = 1] = "BOT_DM";
14
- InteractionContextTypes[InteractionContextTypes["PRIVATE_CHANNEL"] = 2] = "PRIVATE_CHANNEL";
15
- })(InteractionContextTypes || (exports.InteractionContextTypes = InteractionContextTypes = {}));
16
5
  function Locales({ name: names, description: descriptions, }) {
17
6
  return (target) => class extends target {
18
7
  name_localizations = names ? Object.fromEntries(names) : undefined;
@@ -91,8 +80,12 @@ function Declare(declare) {
91
80
  return (target) => class extends target {
92
81
  name = declare.name;
93
82
  nsfw = declare.nsfw;
94
- contexts = declare.contexts?.map(i => InteractionContextTypes[i]);
95
- integrationTypes = declare.integrationTypes?.map(i => IntegrationTypes[i]);
83
+ props = declare.props;
84
+ contexts = declare.contexts?.map(i => v10_1.InteractionContextType[i]) ??
85
+ Object.values(v10_1.InteractionContextType).filter(x => typeof x === 'number');
86
+ integrationTypes = declare.integrationTypes?.map(i => v10_1.ApplicationIntegrationType[i]) ?? [
87
+ v10_1.ApplicationIntegrationType.GuildInstall,
88
+ ];
96
89
  defaultMemberPermissions = Array.isArray(declare.defaultMemberPermissions)
97
90
  ? declare.defaultMemberPermissions?.reduce((acc, prev) => acc | v10_1.PermissionFlagsBits[prev], BigInt(0))
98
91
  : declare.defaultMemberPermissions;