seyfert 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. package/lib/api/Routes/applications.d.ts +2 -2
  2. package/lib/api/Routes/channels.d.ts +2 -2
  3. package/lib/api/Routes/gateway.d.ts +2 -2
  4. package/lib/api/Routes/guilds.d.ts +2 -1
  5. package/lib/api/Routes/interactions.d.ts +2 -2
  6. package/lib/api/Routes/invites.d.ts +2 -2
  7. package/lib/api/Routes/stage-instances.d.ts +2 -2
  8. package/lib/api/Routes/stickers.d.ts +2 -2
  9. package/lib/api/Routes/users.d.ts +2 -2
  10. package/lib/api/Routes/voice.d.ts +2 -2
  11. package/lib/api/Routes/webhooks.d.ts +2 -2
  12. package/lib/builders/ActionRow.d.ts +2 -1
  13. package/lib/builders/ActionRow.js +3 -3
  14. package/lib/builders/Base.d.ts +1 -1
  15. package/lib/builders/Button.d.ts +2 -1
  16. package/lib/builders/Button.js +2 -2
  17. package/lib/builders/Embed.d.ts +2 -1
  18. package/lib/builders/Modal.d.ts +9 -2
  19. package/lib/builders/Modal.js +12 -3
  20. package/lib/builders/SelectMenu.d.ts +18 -1
  21. package/lib/builders/SelectMenu.js +36 -12
  22. package/lib/builders/index.d.ts +1 -1
  23. package/lib/builders/index.js +9 -9
  24. package/lib/builders/types.d.ts +1 -1
  25. package/lib/cache/adapters/types.d.ts +23 -23
  26. package/lib/cache/index.d.ts +5 -5
  27. package/lib/cache/index.js +3 -3
  28. package/lib/cache/resources/default/base.d.ts +10 -10
  29. package/lib/cache/resources/default/guild-based.d.ts +7 -7
  30. package/lib/cache/resources/default/guild-based.js +2 -1
  31. package/lib/cache/resources/default/guild-related.d.ts +9 -9
  32. package/lib/cache/resources/default/guild-related.js +2 -1
  33. package/lib/cache/resources/presence.d.ts +1 -1
  34. package/lib/cache/resources/stage-instances.d.ts +1 -1
  35. package/lib/cache/resources/voice-states.d.ts +1 -1
  36. package/lib/client/base.d.ts +19 -12
  37. package/lib/client/base.js +45 -7
  38. package/lib/client/client.d.ts +7 -4
  39. package/lib/client/client.js +21 -9
  40. package/lib/client/httpclient.d.ts +2 -1
  41. package/lib/client/httpclient.js +3 -3
  42. package/lib/client/oninteractioncreate.js +18 -19
  43. package/lib/client/onmessagecreate.js +6 -4
  44. package/lib/client/workerclient.d.ts +11 -5
  45. package/lib/client/workerclient.js +18 -11
  46. package/lib/commands/applications/chat.d.ts +4 -4
  47. package/lib/commands/applications/chat.js +17 -9
  48. package/lib/commands/applications/chatcontext.d.ts +7 -10
  49. package/lib/commands/applications/chatcontext.js +6 -17
  50. package/lib/commands/applications/menu.d.ts +2 -1
  51. package/lib/commands/applications/menu.js +7 -5
  52. package/lib/commands/applications/menucontext.d.ts +5 -9
  53. package/lib/commands/applications/menucontext.js +8 -21
  54. package/lib/commands/applications/shared.d.ts +5 -4
  55. package/lib/commands/basecontex.d.ts +15 -0
  56. package/lib/commands/basecontex.js +34 -0
  57. package/lib/commands/decorators.d.ts +3 -2
  58. package/lib/commands/decorators.js +5 -5
  59. package/lib/commands/handler.d.ts +6 -0
  60. package/lib/commands/handler.js +10 -4
  61. package/lib/commands/optionresolver.d.ts +3 -3
  62. package/lib/commands/optionresolver.js +14 -14
  63. package/lib/common/index.d.ts +0 -1
  64. package/lib/common/index.js +0 -1
  65. package/lib/common/it/constants.d.ts +3 -1
  66. package/lib/common/it/constants.js +2 -0
  67. package/lib/common/it/utils.d.ts +1 -0
  68. package/lib/common/it/utils.js +2 -1
  69. package/lib/common/shorters/channels.d.ts +1 -1
  70. package/lib/common/shorters/channels.js +4 -4
  71. package/lib/common/shorters/guilds.d.ts +1 -1
  72. package/lib/common/shorters/guilds.js +6 -1
  73. package/lib/common/shorters/members.d.ts +6 -1
  74. package/lib/common/shorters/members.js +25 -2
  75. package/lib/common/shorters/messages.d.ts +1 -1
  76. package/lib/common/shorters/messages.js +1 -1
  77. package/lib/common/shorters/users.d.ts +0 -6
  78. package/lib/common/shorters/users.js +0 -34
  79. package/lib/common/shorters/webhook.d.ts +2 -2
  80. package/lib/common/types/resolvables.d.ts +2 -1
  81. package/lib/common/types/util.d.ts +4 -1
  82. package/lib/common/types/write.d.ts +1 -1
  83. package/lib/components/ActionRow.d.ts +4 -3
  84. package/lib/components/ActionRow.js +6 -3
  85. package/lib/components/BaseComponent.d.ts +18 -0
  86. package/lib/components/BaseComponent.js +21 -0
  87. package/lib/components/BaseSelectMenuComponent.d.ts +10 -0
  88. package/lib/components/BaseSelectMenuComponent.js +22 -0
  89. package/lib/components/ButtonComponent.d.ts +14 -14
  90. package/lib/components/ButtonComponent.js +36 -25
  91. package/lib/components/ChannelSelectMenuComponent.d.ts +4 -4
  92. package/lib/components/ChannelSelectMenuComponent.js +6 -5
  93. package/lib/components/MentionableSelectMenuComponent.d.ts +3 -2
  94. package/lib/components/MentionableSelectMenuComponent.js +4 -1
  95. package/lib/components/RoleSelectMenuComponent.d.ts +3 -2
  96. package/lib/components/RoleSelectMenuComponent.js +4 -1
  97. package/lib/components/StringSelectMenuComponent.d.ts +3 -4
  98. package/lib/components/StringSelectMenuComponent.js +3 -5
  99. package/lib/components/TextInputComponent.d.ts +10 -5
  100. package/lib/components/TextInputComponent.js +24 -7
  101. package/lib/components/UserSelectMenuComponent.d.ts +3 -2
  102. package/lib/components/UserSelectMenuComponent.js +4 -1
  103. package/lib/components/command.d.ts +6 -5
  104. package/lib/components/command.js +4 -0
  105. package/lib/components/componentcontext.d.ts +42 -0
  106. package/lib/components/componentcontext.js +79 -0
  107. package/lib/components/handler.d.ts +22 -6
  108. package/lib/components/handler.js +19 -12
  109. package/lib/components/index.d.ts +2 -2
  110. package/lib/components/index.js +9 -9
  111. package/lib/events/handler.d.ts +12 -3
  112. package/lib/events/handler.js +6 -8
  113. package/lib/events/hooks/application_command.d.ts +2 -2
  114. package/lib/events/hooks/auto_moderation.d.ts +4 -4
  115. package/lib/events/hooks/channel.d.ts +1 -1
  116. package/lib/events/hooks/dispatch.d.ts +1 -1
  117. package/lib/events/hooks/entitlement.d.ts +4 -4
  118. package/lib/events/hooks/guild.d.ts +42 -42
  119. package/lib/events/hooks/integration.d.ts +19 -19
  120. package/lib/events/hooks/interactions.d.ts +2 -2
  121. package/lib/events/hooks/invite.d.ts +5 -5
  122. package/lib/events/hooks/message.d.ts +6 -5
  123. package/lib/events/hooks/presence.d.ts +7 -7
  124. package/lib/events/hooks/stage.d.ts +4 -4
  125. package/lib/events/hooks/thread.d.ts +49 -49
  126. package/lib/events/hooks/typing.d.ts +2 -2
  127. package/lib/events/hooks/user.d.ts +1 -1
  128. package/lib/events/hooks/voice.d.ts +2 -2
  129. package/lib/events/hooks/webhook.d.ts +1 -1
  130. package/lib/index.d.ts +3 -6
  131. package/lib/index.js +6 -7
  132. package/lib/langs/handler.d.ts +10 -1
  133. package/lib/langs/handler.js +1 -0
  134. package/lib/structures/AutoModerationRule.d.ts +3 -2
  135. package/lib/structures/ClientUser.d.ts +1 -1
  136. package/lib/structures/Guild.d.ts +27 -27
  137. package/lib/structures/GuildEmoji.d.ts +2 -1
  138. package/lib/structures/GuildMember.d.ts +16 -6
  139. package/lib/structures/GuildMember.js +35 -6
  140. package/lib/structures/GuildPreview.d.ts +1 -1
  141. package/lib/structures/GuildRole.d.ts +2 -1
  142. package/lib/structures/GuildTemplate.d.ts +3 -2
  143. package/lib/structures/Interaction.d.ts +5 -5
  144. package/lib/structures/Interaction.js +34 -34
  145. package/lib/structures/Message.d.ts +6 -5
  146. package/lib/structures/Sticker.d.ts +2 -1
  147. package/lib/structures/User.d.ts +7 -3
  148. package/lib/structures/User.js +5 -0
  149. package/lib/structures/Webhook.d.ts +63 -4
  150. package/lib/structures/Webhook.js +53 -0
  151. package/lib/structures/channels.d.ts +4 -4
  152. package/lib/structures/extra/BaseGuild.d.ts +2 -1
  153. package/lib/structures/extra/BaseGuild.js +3 -3
  154. package/lib/structures/extra/BitField.d.ts +2 -2
  155. package/lib/structures/extra/BitField.js +2 -2
  156. package/lib/structures/extra/Permissions.d.ts +1 -1
  157. package/lib/structures/extra/functions.d.ts +2 -1
  158. package/lib/structures/extra/functions.js +2 -1
  159. package/lib/types/index.d.ts +1 -0
  160. package/lib/types/index.js +17 -0
  161. package/lib/websocket/SharedTypes.d.ts +2 -1
  162. package/lib/websocket/SharedTypes.js +1 -0
  163. package/lib/websocket/discord/shard.d.ts +2 -1
  164. package/lib/websocket/discord/shard.js +30 -41
  165. package/lib/websocket/discord/sharder.d.ts +3 -2
  166. package/lib/websocket/discord/sharder.js +7 -6
  167. package/lib/websocket/discord/shared.d.ts +2 -1
  168. package/lib/websocket/discord/worker.d.ts +1 -1
  169. package/lib/websocket/discord/workermanager.d.ts +3 -2
  170. package/lib/websocket/discord/workermanager.js +1 -1
  171. package/package.json +2 -2
@@ -3,21 +3,22 @@
3
3
  /// <reference types="node" />
4
4
  /// <reference types="node" />
5
5
  /// <reference types="node" />
6
+ import { type GatewayDispatchPayload } from 'discord-api-types/v10';
7
+ import { Logger } from '..';
6
8
  import type { Cache } from '../cache';
7
- import type { GatewayDispatchPayload, When } from '../common';
8
- import { Logger, type DeepPartial } from '../common';
9
- import { EventHandler } from '../events';
9
+ import { type DeepPartial, type When } from '../common';
10
+ import { type EventHandlerLike } from '../events';
10
11
  import { ClientUser } from '../structures';
11
12
  import { Shard, type ShardManagerOptions } from '../websocket';
12
13
  import type { WorkerShardInfo } from '../websocket/discord/worker';
13
14
  import type { ManagerMessages } from '../websocket/discord/workermanager';
14
- import type { BaseClientOptions, StartOptions } from './base';
15
+ import type { BaseClientOptions, ServicesOptions, StartOptions } from './base';
15
16
  import { BaseClient } from './base';
16
17
  import type { Client } from './client';
17
18
  export declare class WorkerClient<Ready extends boolean = boolean> extends BaseClient {
18
19
  private __handleGuilds?;
19
20
  logger: Logger;
20
- events: EventHandler;
21
+ events?: EventHandlerLike;
21
22
  me: When<Ready, ClientUser>;
22
23
  promises: Map<string, {
23
24
  resolve: (value: any) => void;
@@ -28,6 +29,11 @@ export declare class WorkerClient<Ready extends boolean = boolean> extends BaseC
28
29
  constructor(options?: WorkerClientOptions);
29
30
  get workerId(): number;
30
31
  get latency(): number;
32
+ setServices({ ...rest }: ServicesOptions & {
33
+ handlers?: ServicesOptions['handlers'] & {
34
+ events?: EventHandlerLike;
35
+ };
36
+ }): void;
31
37
  start(options?: Omit<DeepPartial<StartOptions>, 'httpConnection' | 'token' | 'connection'>): Promise<void>;
32
38
  loadEvents(dir?: string): Promise<void>;
33
39
  postMessage(body: any): boolean | void;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateShardInfo = exports.WorkerClient = void 0;
4
+ const v10_1 = require("discord-api-types/v10");
4
5
  const node_crypto_1 = require("node:crypto");
5
6
  const node_worker_threads_1 = require("node:worker_threads");
6
7
  const __1 = require("..");
@@ -27,7 +28,7 @@ try {
27
28
  catch { }
28
29
  class WorkerClient extends base_1.BaseClient {
29
30
  __handleGuilds = new Set();
30
- logger = new common_1.Logger({
31
+ logger = new __1.Logger({
31
32
  name: `[Worker #${workerData.workerId}]`,
32
33
  });
33
34
  events = new events_1.EventHandler(this.logger);
@@ -51,7 +52,7 @@ class WorkerClient extends base_1.BaseClient {
51
52
  },
52
53
  });
53
54
  if (workerData.debug) {
54
- this.debugger = new common_1.Logger({
55
+ this.debugger = new __1.Logger({
55
56
  name: `[Worker #${workerData.workerId}]`,
56
57
  logLevel: common_1.LogLevels.Debug,
57
58
  });
@@ -74,6 +75,12 @@ class WorkerClient extends base_1.BaseClient {
74
75
  this.shards.forEach(s => (acc += s.latency));
75
76
  return acc / this.shards.size;
76
77
  }
78
+ setServices({ ...rest }) {
79
+ super.setServices(rest);
80
+ if (rest.handlers && 'events' in rest.handlers) {
81
+ this.events = rest.handlers.events;
82
+ }
83
+ }
77
84
  async start(options = {}) {
78
85
  await super.start(options);
79
86
  await this.loadEvents(options.eventsDir);
@@ -81,7 +88,7 @@ class WorkerClient extends base_1.BaseClient {
81
88
  }
82
89
  async loadEvents(dir) {
83
90
  dir ??= await this.getRC().then(x => x.events);
84
- if (dir) {
91
+ if (dir && this.events) {
85
92
  await this.events.load(dir);
86
93
  this.logger.info('EventHandler loaded');
87
94
  }
@@ -191,7 +198,7 @@ class WorkerClient extends base_1.BaseClient {
191
198
  }
192
199
  break;
193
200
  case 'BOT_READY':
194
- await this.events.runEvent('BOT_READY', this, this.me, -1);
201
+ await this.events?.runEvent('BOT_READY', this, this.me, -1);
195
202
  break;
196
203
  case 'API_RESPONSE':
197
204
  {
@@ -270,14 +277,14 @@ class WorkerClient extends base_1.BaseClient {
270
277
  return this.generateSendPromise(nonce);
271
278
  }
272
279
  async onPacket(packet, shardId) {
273
- await this.events.execute('RAW', packet, this, shardId);
280
+ await this.events?.execute('RAW', packet, this, shardId);
274
281
  switch (packet.t) {
275
282
  case 'GUILD_MEMBER_UPDATE':
276
- await this.events.execute(packet.t, packet, this, shardId);
283
+ await this.events?.execute(packet.t, packet, this, shardId);
277
284
  await this.cache.onPacket(packet);
278
285
  break;
279
286
  case 'PRESENCE_UPDATE':
280
- await this.events.execute(packet.t, packet, this, shardId);
287
+ await this.events?.execute(packet.t, packet, this, shardId);
281
288
  await this.cache.onPacket(packet);
282
289
  break;
283
290
  //rest of the events
@@ -292,13 +299,13 @@ class WorkerClient extends base_1.BaseClient {
292
299
  this.applicationId = packet.d.application.id;
293
300
  this.me = new structures_1.ClientUser(this, packet.d.user, packet.d.application);
294
301
  if (!this.__handleGuilds?.size ||
295
- !((workerData.intents & common_1.GatewayIntentBits.Guilds) === common_1.GatewayIntentBits.Guilds)) {
302
+ !((workerData.intents & v10_1.GatewayIntentBits.Guilds) === v10_1.GatewayIntentBits.Guilds)) {
296
303
  if ([...this.shards.values()].every(shard => shard.data.session_id)) {
297
304
  this.postMessage({
298
305
  type: 'WORKER_READY',
299
306
  workerId: this.workerId,
300
307
  });
301
- await this.events.runEvent('WORKER_READY', this, this.me, -1);
308
+ await this.events?.runEvent('WORKER_READY', this, this.me, -1);
302
309
  }
303
310
  delete this.__handleGuilds;
304
311
  }
@@ -318,7 +325,7 @@ class WorkerClient extends base_1.BaseClient {
318
325
  type: 'WORKER_READY',
319
326
  workerId: this.workerId,
320
327
  });
321
- await this.events.runEvent('WORKER_READY', this, this.me, -1);
328
+ await this.events?.runEvent('WORKER_READY', this, this.me, -1);
322
329
  }
323
330
  if (!this.__handleGuilds.size)
324
331
  delete this.__handleGuilds;
@@ -326,7 +333,7 @@ class WorkerClient extends base_1.BaseClient {
326
333
  }
327
334
  }
328
335
  }
329
- await this.events.execute(packet.t, packet, this, shardId);
336
+ await this.events?.execute(packet.t, packet, this, shardId);
330
337
  }
331
338
  break;
332
339
  }
@@ -1,7 +1,7 @@
1
- import type { SeyfertNumberOption, SeyfertStringOption } from '../..';
1
+ import { type APIApplicationCommandBasicOption, type APIApplicationCommandOption, ApplicationCommandOptionType, ApplicationCommandType, type LocaleString } from 'discord-api-types/v10';
2
+ import type { PermissionStrings, SeyfertNumberOption, SeyfertStringOption } from '../..';
2
3
  import type { Attachment } from '../../builders';
3
- import type { APIApplicationCommandBasicOption, APIApplicationCommandOption, FlatObjectKeys, LocaleString, PermissionStrings } from '../../common';
4
- import { ApplicationCommandOptionType, ApplicationCommandType } from '../../common';
4
+ import { type FlatObjectKeys } from '../../common';
5
5
  import type { AllChannels, AutocompleteInteraction, GuildRole, InteractionGuildMember, User } from '../../structures';
6
6
  import type { Groups, IntegrationTypes, InteractionContextTypes, RegisteredMiddlewares } from '../decorators';
7
7
  import type { CommandContext } from './chatcontext';
@@ -71,7 +71,7 @@ declare class BaseCommand {
71
71
  name: string | undefined;
72
72
  description: string | undefined;
73
73
  };
74
- __d?: true;
74
+ __autoload?: true;
75
75
  __tGroups?: Record<string, {
76
76
  name: string | undefined;
77
77
  description: string | undefined;
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SubCommand = exports.Command = void 0;
4
+ const v10_1 = require("discord-api-types/v10");
4
5
  const common_1 = require("../../common");
5
6
  class BaseCommand {
6
7
  middlewares = [];
7
8
  __filePath;
8
9
  __t;
9
- __d;
10
+ __autoload;
10
11
  __tGroups;
11
12
  guild_id;
12
13
  name;
@@ -76,19 +77,21 @@ class BaseCommand {
76
77
  running = false;
77
78
  return res({ pass: true });
78
79
  };
79
- const next = obj => {
80
+ function next(obj) {
80
81
  if (!running) {
81
82
  return;
82
83
  }
83
- context[global ? 'globalMetadata' : 'metadata'] ??= {};
84
- // @ts-expect-error
85
- context[global ? 'globalMetadata' : 'metadata'][middlewares[index]] = obj;
84
+ // biome-ignore lint/style/noArguments: yes
85
+ if (arguments.length) {
86
+ // @ts-expect-error
87
+ context[global ? 'globalMetadata' : 'metadata'][middlewares[index]] = obj;
88
+ }
86
89
  if (++index >= middlewares.length) {
87
90
  running = false;
88
91
  return res({});
89
92
  }
90
93
  context.client.middlewares[middlewares[index]]({ context, next, stop, pass });
91
- };
94
+ }
92
95
  const stop = err => {
93
96
  if (!running) {
94
97
  return;
@@ -126,10 +129,15 @@ class BaseCommand {
126
129
  delete require.cache[this.__filePath];
127
130
  const __tempCommand = await (0, common_1.magicImport)(this.__filePath).then(x => x.default ?? x);
128
131
  Object.setPrototypeOf(this, __tempCommand.prototype);
132
+ for (const i of this.options ?? []) {
133
+ if (i instanceof SubCommand && i.__filePath) {
134
+ await i.reload();
135
+ }
136
+ }
129
137
  }
130
138
  }
131
139
  class Command extends BaseCommand {
132
- type = common_1.ApplicationCommandType.ChatInput;
140
+ type = v10_1.ApplicationCommandType.ChatInput;
133
141
  groups;
134
142
  toJSON() {
135
143
  const options = [];
@@ -141,7 +149,7 @@ class Command extends BaseCommand {
141
149
  if (i.group) {
142
150
  if (!options.find(x => x.name === i.group)) {
143
151
  options.push({
144
- type: common_1.ApplicationCommandOptionType.SubcommandGroup,
152
+ type: v10_1.ApplicationCommandOptionType.SubcommandGroup,
145
153
  name: i.group,
146
154
  description: this.groups[i.group].defaultDescription,
147
155
  description_localizations: Object.fromEntries(this.groups?.[i.group].description ?? []),
@@ -178,7 +186,7 @@ class Command extends BaseCommand {
178
186
  }
179
187
  exports.Command = Command;
180
188
  class SubCommand extends BaseCommand {
181
- type = common_1.ApplicationCommandOptionType.Subcommand;
189
+ type = v10_1.ApplicationCommandOptionType.Subcommand;
182
190
  group;
183
191
  toJSON() {
184
192
  return {
@@ -1,14 +1,15 @@
1
- import { MenuCommandContext, User, type AllChannels, type Guild, type InferWithPrefix, type MessageCommandInteraction, type ReturnCache, type UserCommandInteraction, type WebhookMessage } from '../..';
2
- import { type If, type UnionToTuple, type When } from '../../common';
1
+ import type { AllChannels, Guild, InferWithPrefix, ReturnCache, WebhookMessage } from '../..';
2
+ import type { If, UnionToTuple, When } from '../../common';
3
3
  import type { InteractionCreateBodyRequest, InteractionMessageUpdateBodyRequest } from '../../common/types/write';
4
4
  import { Message, type ChatInputCommandInteraction, type GuildMember, type InteractionGuildMember } from '../../structures';
5
+ import { BaseContext } from '../basecontex';
5
6
  import type { RegisteredMiddlewares } from '../decorators';
6
7
  import type { OptionResolver } from '../optionresolver';
7
8
  import type { Command, ContextOptions, OptionsRecord, SubCommand } from './chat';
8
9
  import type { CommandMetadata, ExtendContext, GlobalMetadata, UsingClient } from './shared';
9
- export interface CommandContext<T extends OptionsRecord = {}, M extends keyof RegisteredMiddlewares = never> extends ExtendContext {
10
+ export interface CommandContext<T extends OptionsRecord = {}, M extends keyof RegisteredMiddlewares = never> extends BaseContext, ExtendContext {
10
11
  }
11
- export declare class CommandContext<T extends OptionsRecord = {}, M extends keyof RegisteredMiddlewares = never> {
12
+ export declare class CommandContext<T extends OptionsRecord = {}, M extends keyof RegisteredMiddlewares = never> extends BaseContext {
12
13
  readonly client: UsingClient;
13
14
  readonly resolver: OptionResolver;
14
15
  readonly shardId: number;
@@ -28,7 +29,7 @@ export declare class CommandContext<T extends OptionsRecord = {}, M extends keyo
28
29
  write<FR extends boolean = false>(body: InteractionCreateBodyRequest, fetchReply?: FR): Promise<When<FR, WebhookMessage | Message, void | WebhookMessage | Message>>;
29
30
  deferReply(ephemeral?: boolean): Promise<void | Message>;
30
31
  editResponse(body: InteractionMessageUpdateBodyRequest): Promise<Message>;
31
- deleteResponse(): Promise<void>;
32
+ deleteResponse(): Promise<void | undefined>;
32
33
  editOrReply<FR extends boolean = false>(body: InteractionCreateBodyRequest | InteractionMessageUpdateBodyRequest, fetchReply?: FR): Promise<When<FR, WebhookMessage | Message, void | WebhookMessage | Message>>;
33
34
  fetchResponse(): Promise<If<InferWithPrefix, WebhookMessage | Message | undefined, WebhookMessage | undefined>>;
34
35
  channel(mode?: 'rest' | 'flow'): Promise<If<InferWithPrefix, AllChannels | undefined, AllChannels>>;
@@ -39,10 +40,6 @@ export declare class CommandContext<T extends OptionsRecord = {}, M extends keyo
39
40
  guild(mode?: 'cache'): ReturnCache<Guild<'cached'> | undefined>;
40
41
  get guildId(): string | undefined;
41
42
  get channelId(): string;
42
- get author(): User;
43
+ get author(): import("../..").User;
43
44
  get member(): If<InferWithPrefix, GuildMember | InteractionGuildMember | undefined, InteractionGuildMember | undefined>;
44
- isChat(): this is CommandContext;
45
- isMenu(): this is MenuCommandContext<any>;
46
- isMenuUser(): this is MenuCommandContext<UserCommandInteraction>;
47
- isMenuMessage(): this is MenuCommandContext<MessageCommandInteraction>;
48
45
  }
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CommandContext = void 0;
4
- const __1 = require("../..");
5
- const common_1 = require("../../common");
4
+ const v10_1 = require("discord-api-types/v10");
6
5
  const structures_1 = require("../../structures");
7
- class CommandContext {
6
+ const basecontex_1 = require("../basecontex");
7
+ class CommandContext extends basecontex_1.BaseContext {
8
8
  client;
9
9
  resolver;
10
10
  shardId;
@@ -13,6 +13,7 @@ class CommandContext {
13
13
  interaction;
14
14
  messageResponse;
15
15
  constructor(client, data, resolver, shardId, command) {
16
+ super(client);
16
17
  this.client = client;
17
18
  this.resolver = resolver;
18
19
  this.shardId = shardId;
@@ -31,7 +32,7 @@ class CommandContext {
31
32
  return this.client.proxy;
32
33
  }
33
34
  get t() {
34
- return this.client.langs.get(this.interaction?.locale ?? this.client.langs.defaultLang ?? 'en-US');
35
+ return this.client.t(this.interaction?.locale ?? this.client.langs?.defaultLang ?? 'en-US');
35
36
  }
36
37
  get fullCommandName() {
37
38
  return this.resolver.fullCommandName;
@@ -44,7 +45,7 @@ class CommandContext {
44
45
  }
45
46
  async deferReply(ephemeral = false) {
46
47
  if (this.interaction)
47
- return this.interaction.deferReply(ephemeral ? common_1.MessageFlags.Ephemeral : undefined);
48
+ return this.interaction.deferReply(ephemeral ? v10_1.MessageFlags.Ephemeral : undefined);
48
49
  const options = this.client.options?.commands;
49
50
  return (this.messageResponse = await this.message[options?.reply?.(this) ? 'reply' : 'write'](options?.deferReplyResponse?.(this) ?? { content: 'Thinking...' }));
50
51
  }
@@ -121,17 +122,5 @@ class CommandContext {
121
122
  get member() {
122
123
  return this.interaction?.member || this.message?.member;
123
124
  }
124
- isChat() {
125
- return this instanceof CommandContext;
126
- }
127
- isMenu() {
128
- return this instanceof __1.MenuCommandContext;
129
- }
130
- isMenuUser() {
131
- return this instanceof __1.MenuCommandContext && this.target instanceof __1.User;
132
- }
133
- isMenuMessage() {
134
- return this instanceof __1.MenuCommandContext && this.target instanceof structures_1.Message;
135
- }
136
125
  }
137
126
  exports.CommandContext = CommandContext;
@@ -1,4 +1,5 @@
1
- import { type ApplicationCommandType, type LocaleString, type PermissionStrings } from '../../common';
1
+ import type { ApplicationCommandType, LocaleString } from 'discord-api-types/v10';
2
+ import { type PermissionStrings } from '../../common';
2
3
  import type { IntegrationTypes, InteractionContextTypes, RegisteredMiddlewares } from '../decorators';
3
4
  import type { MenuCommandContext } from './menucontext';
4
5
  import type { UsingClient } from './shared';
@@ -33,19 +33,21 @@ class ContextMenuCommand {
33
33
  running = false;
34
34
  return res({ pass: true });
35
35
  };
36
- const next = obj => {
36
+ function next(obj) {
37
37
  if (!running) {
38
38
  return;
39
39
  }
40
- context[global ? 'globalMetadata' : 'metadata'] ??= {};
41
- // @ts-expect-error
42
- context[global ? 'globalMetadata' : 'metadata'][middlewares[index]] = obj;
40
+ // biome-ignore lint/style/noArguments: yes
41
+ if (arguments.length) {
42
+ // @ts-expect-error
43
+ context[global ? 'globalMetadata' : 'metadata'][middlewares[index]] = obj;
44
+ }
43
45
  if (++index >= middlewares.length) {
44
46
  running = false;
45
47
  return res({});
46
48
  }
47
49
  context.client.middlewares[middlewares[index]]({ context, next, stop, pass });
48
- };
50
+ }
49
51
  const stop = err => {
50
52
  if (!running) {
51
53
  return;
@@ -1,12 +1,13 @@
1
- import { CommandContext, type ContextMenuCommand, type ReturnCache, type WebhookMessage } from '../..';
1
+ import type { ContextMenuCommand, ReturnCache, WebhookMessage } from '../..';
2
2
  import { type InteractionCreateBodyRequest, type InteractionMessageUpdateBodyRequest, type UnionToTuple, type When } from '../../common';
3
3
  import { Message, User, type AllChannels, type Guild, type GuildMember, type MessageCommandInteraction, type UserCommandInteraction } from '../../structures';
4
+ import { BaseContext } from '../basecontex';
4
5
  import type { RegisteredMiddlewares } from '../decorators';
5
6
  import type { CommandMetadata, ExtendContext, GlobalMetadata, UsingClient } from './shared';
6
7
  export type InteractionTarget<T> = T extends MessageCommandInteraction ? Message : User;
7
- export interface MenuCommandContext<T extends MessageCommandInteraction | UserCommandInteraction, M extends keyof RegisteredMiddlewares = never> extends ExtendContext {
8
+ export interface MenuCommandContext<T extends MessageCommandInteraction | UserCommandInteraction, M extends keyof RegisteredMiddlewares = never> extends BaseContext, ExtendContext {
8
9
  }
9
- export declare class MenuCommandContext<T extends MessageCommandInteraction | UserCommandInteraction, M extends keyof RegisteredMiddlewares = never> {
10
+ export declare class MenuCommandContext<T extends MessageCommandInteraction | UserCommandInteraction, M extends keyof RegisteredMiddlewares = never> extends BaseContext {
10
11
  readonly client: UsingClient;
11
12
  readonly interaction: T;
12
13
  readonly shardId: number;
@@ -14,7 +15,6 @@ export declare class MenuCommandContext<T extends MessageCommandInteraction | Us
14
15
  constructor(client: UsingClient, interaction: T, shardId: number, command: ContextMenuCommand);
15
16
  metadata: CommandMetadata<UnionToTuple<M>>;
16
17
  globalMetadata: GlobalMetadata;
17
- get proxy(): import("../..").APIRoutes;
18
18
  get target(): InteractionTarget<T>;
19
19
  get t(): import("../..").__InternalParseLocale<import("./shared").DefaultLocale> & {
20
20
  get(locale?: string | undefined): import("./shared").DefaultLocale;
@@ -24,7 +24,7 @@ export declare class MenuCommandContext<T extends MessageCommandInteraction | Us
24
24
  get modal(): ((body: import("../../common").ModalCreateBodyRequest) => Promise<void>) | ((body: import("../../common").ModalCreateBodyRequest) => Promise<void>);
25
25
  deferReply(ephemeral?: boolean): Promise<void>;
26
26
  editResponse(body: InteractionMessageUpdateBodyRequest): Promise<Message>;
27
- deleteResponse(): Promise<void>;
27
+ deleteResponse(): Promise<void | undefined>;
28
28
  editOrReply<FR extends boolean = false>(body: InteractionCreateBodyRequest | InteractionMessageUpdateBodyRequest, fetchReply?: FR): Promise<When<FR, WebhookMessage | Message, void | WebhookMessage | Message>>;
29
29
  fetchResponse(): Promise<WebhookMessage | undefined>;
30
30
  channel(mode?: 'rest' | 'flow'): Promise<AllChannels>;
@@ -37,8 +37,4 @@ export declare class MenuCommandContext<T extends MessageCommandInteraction | Us
37
37
  get channelId(): string;
38
38
  get author(): User;
39
39
  get member(): import("../..").InteractionGuildMember | undefined;
40
- isChat(): this is CommandContext;
41
- isMenu(): this is MenuCommandContext<any>;
42
- isMenuUser(): this is MenuCommandContext<UserCommandInteraction>;
43
- isMenuMessage(): this is MenuCommandContext<MessageCommandInteraction>;
44
40
  }
@@ -1,15 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MenuCommandContext = void 0;
4
- const __1 = require("../..");
4
+ const v10_1 = require("discord-api-types/v10");
5
5
  const common_1 = require("../../common");
6
6
  const structures_1 = require("../../structures");
7
- class MenuCommandContext {
7
+ const basecontex_1 = require("../basecontex");
8
+ class MenuCommandContext extends basecontex_1.BaseContext {
8
9
  client;
9
10
  interaction;
10
11
  shardId;
11
12
  command;
12
13
  constructor(client, interaction, shardId, command) {
14
+ super(client);
13
15
  this.client = client;
14
16
  this.interaction = interaction;
15
17
  this.shardId = shardId;
@@ -17,24 +19,21 @@ class MenuCommandContext {
17
19
  }
18
20
  metadata = {};
19
21
  globalMetadata = {};
20
- get proxy() {
21
- return this.client.proxy;
22
- }
23
22
  // biome-ignore lint/suspicious/useGetterReturn: default don't exist.
24
23
  get target() {
25
24
  switch (this.interaction.data.type) {
26
- case common_1.ApplicationCommandType.Message: {
25
+ case v10_1.ApplicationCommandType.Message: {
27
26
  const data = this.interaction.data.resolved.messages[this.interaction.data.targetId];
28
27
  return new structures_1.Message(this.client, (0, common_1.toSnakeCase)(data));
29
28
  }
30
- case common_1.ApplicationCommandType.User: {
29
+ case v10_1.ApplicationCommandType.User: {
31
30
  const data = this.interaction.data.resolved.users[this.interaction.data.targetId];
32
31
  return new structures_1.User(this.client, (0, common_1.toSnakeCase)(data));
33
32
  }
34
33
  }
35
34
  }
36
35
  get t() {
37
- return this.client.langs.get(this.interaction.locale);
36
+ return this.client.langs.get(this.interaction.locale ?? this.client.langs.defaultLang ?? 'en-US');
38
37
  }
39
38
  get fullCommandName() {
40
39
  return this.command.name;
@@ -46,7 +45,7 @@ class MenuCommandContext {
46
45
  return this.interaction.modal;
47
46
  }
48
47
  deferReply(ephemeral = false) {
49
- return this.interaction.deferReply(ephemeral ? common_1.MessageFlags.Ephemeral : undefined);
48
+ return this.interaction.deferReply(ephemeral ? v10_1.MessageFlags.Ephemeral : undefined);
50
49
  }
51
50
  editResponse(body) {
52
51
  return this.interaction.editResponse(body);
@@ -97,17 +96,5 @@ class MenuCommandContext {
97
96
  get member() {
98
97
  return this.interaction.member;
99
98
  }
100
- isChat() {
101
- return this instanceof __1.CommandContext;
102
- }
103
- isMenu() {
104
- return this instanceof MenuCommandContext;
105
- }
106
- isMenuUser() {
107
- return this instanceof MenuCommandContext && this.target instanceof structures_1.User;
108
- }
109
- isMenuMessage() {
110
- return this instanceof MenuCommandContext && this.target instanceof structures_1.Message;
111
- }
112
99
  }
113
100
  exports.MenuCommandContext = MenuCommandContext;
@@ -1,8 +1,9 @@
1
1
  import type { BaseClient } from '../../client/base';
2
+ import type { IsStrictlyUndefined } from '../../common';
2
3
  import type { RegisteredMiddlewares } from '../decorators';
3
4
  export type OKFunction<T> = (value: T) => void;
4
5
  export type StopFunction = (error: string) => void;
5
- export type NextFunction<T = unknown> = (data: T) => void;
6
+ export type NextFunction<T = unknown> = IsStrictlyUndefined<T> extends true ? () => void : (data: T) => void;
6
7
  export type PassFunction = () => void;
7
8
  export type InferWithPrefix = InternalOptions extends {
8
9
  withPrefix: infer P;
@@ -24,13 +25,13 @@ export type MiddlewareContext<T = any, C = any> = (context: {
24
25
  stop: StopFunction;
25
26
  pass: PassFunction;
26
27
  }) => any;
27
- export type MetadataMiddleware<T extends MiddlewareContext> = Parameters<Parameters<T>[0]['next']>[0];
28
+ export type MetadataMiddleware<T extends MiddlewareContext> = IsStrictlyUndefined<Parameters<Parameters<T>[0]['next']>[0]> extends true ? never : Parameters<Parameters<T>[0]['next']>[0];
28
29
  export type CommandMetadata<T extends readonly (keyof RegisteredMiddlewares)[]> = T extends readonly [
29
30
  infer first,
30
31
  ...infer rest
31
- ] ? first extends keyof RegisteredMiddlewares ? {
32
+ ] ? first extends keyof RegisteredMiddlewares ? (MetadataMiddleware<RegisteredMiddlewares[first]> extends never ? {} : {
32
33
  [key in first]: MetadataMiddleware<RegisteredMiddlewares[first]>;
33
- } & (rest extends readonly (keyof RegisteredMiddlewares)[] ? CommandMetadata<rest> : {}) : {} : {};
34
+ }) & (rest extends readonly (keyof RegisteredMiddlewares)[] ? CommandMetadata<rest> : {}) : {} : {};
34
35
  export type OnOptionsReturnObject = Record<string, {
35
36
  failed: false;
36
37
  value: unknown;
@@ -0,0 +1,15 @@
1
+ import type { ComponentCommandInteractionMap, ComponentContext } from '../components/componentcontext';
2
+ import { type MessageCommandInteraction, type UserCommandInteraction } from '../structures';
3
+ import type { CommandContext } from './applications/chatcontext';
4
+ import type { MenuCommandContext } from './applications/menucontext';
5
+ import type { UsingClient } from './applications/shared';
6
+ export declare class BaseContext {
7
+ readonly client: UsingClient;
8
+ constructor(client: UsingClient);
9
+ get proxy(): import("..").APIRoutes;
10
+ isChat(): this is CommandContext;
11
+ isMenu(): this is MenuCommandContext<UserCommandInteraction | MessageCommandInteraction>;
12
+ isMenuUser(): this is MenuCommandContext<UserCommandInteraction>;
13
+ isMenuMessage(): this is MenuCommandContext<MessageCommandInteraction>;
14
+ isComponent(): this is ComponentContext<keyof ComponentCommandInteractionMap>;
15
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseContext = void 0;
4
+ const v10_1 = require("discord-api-types/v10");
5
+ const structures_1 = require("../structures");
6
+ class BaseContext {
7
+ client;
8
+ constructor(client) {
9
+ this.client = client;
10
+ }
11
+ get proxy() {
12
+ return this.client.proxy;
13
+ }
14
+ isChat() {
15
+ //@ts-expect-error
16
+ return this.message || this.interaction.type === v10_1.ApplicationCommandType.ChatInput;
17
+ }
18
+ isMenu() {
19
+ return this.isMenuUser() || this.isMenuMessage();
20
+ }
21
+ isMenuUser() {
22
+ //@ts-expect-error
23
+ return this.target instanceof structures_1.User;
24
+ }
25
+ isMenuMessage() {
26
+ //@ts-expect-error
27
+ return this.target instanceof structures_1.Message;
28
+ }
29
+ isComponent() {
30
+ //@ts-expect-error
31
+ return this.interaction.type === v10_1.InteractionType.MessageComponent;
32
+ }
33
+ }
34
+ exports.BaseContext = BaseContext;
@@ -1,4 +1,5 @@
1
- import { ApplicationCommandType, type FlatObjectKeys, type LocaleString, type PermissionStrings } from '../common';
1
+ import { ApplicationCommandType, type LocaleString } from 'discord-api-types/v10';
2
+ import type { FlatObjectKeys, PermissionStrings } from '../common';
2
3
  import type { CommandOption, OptionsRecord, SubCommand } from './applications/chat';
3
4
  import type { DefaultLocale, MiddlewareContext } from './applications/shared';
4
5
  export interface RegisteredMiddlewares {
@@ -92,7 +93,7 @@ export declare function Options(options: (new () => SubCommand)[] | OptionsRecor
92
93
  } & T;
93
94
  export declare function AutoLoad(): <T extends new (...args: any[]) => {}>(target: T) => {
94
95
  new (...args: any[]): {
95
- __d: boolean;
96
+ __autoload: boolean;
96
97
  };
97
98
  } & T;
98
99
  export type ParseMiddlewares<T extends Record<string, MiddlewareContext>> = {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
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;
4
- const common_1 = require("../common");
4
+ const v10_1 = require("discord-api-types/v10");
5
5
  var IntegrationTypes;
6
6
  (function (IntegrationTypes) {
7
7
  IntegrationTypes[IntegrationTypes["GUILD_INSTALL"] = 0] = "GUILD_INSTALL";
@@ -59,7 +59,7 @@ function Options(options) {
59
59
  exports.Options = Options;
60
60
  function AutoLoad() {
61
61
  return (target) => class extends target {
62
- __d = true;
62
+ __autoload = true;
63
63
  };
64
64
  }
65
65
  exports.AutoLoad = AutoLoad;
@@ -76,13 +76,13 @@ function Declare(declare) {
76
76
  contexts = declare.contexts?.map(i => InteractionContextTypes[i]);
77
77
  integration_types = declare.integrationTypes?.map(i => IntegrationTypes[i]);
78
78
  default_member_permissions = Array.isArray(declare.defaultMemberPermissions)
79
- ? declare.defaultMemberPermissions?.reduce((acc, prev) => acc | common_1.PermissionFlagsBits[prev], BigInt(0)).toString()
79
+ ? declare.defaultMemberPermissions?.reduce((acc, prev) => acc | v10_1.PermissionFlagsBits[prev], BigInt(0)).toString()
80
80
  : declare.defaultMemberPermissions;
81
81
  botPermissions = Array.isArray(declare.botPermissions)
82
- ? declare.botPermissions?.reduce((acc, prev) => acc | common_1.PermissionFlagsBits[prev], BigInt(0))
82
+ ? declare.botPermissions?.reduce((acc, prev) => acc | v10_1.PermissionFlagsBits[prev], BigInt(0))
83
83
  : declare.botPermissions;
84
84
  description = '';
85
- type = common_1.ApplicationCommandType.ChatInput;
85
+ type = v10_1.ApplicationCommandType.ChatInput;
86
86
  guild_id;
87
87
  constructor(...args) {
88
88
  super(...args);
@@ -3,6 +3,12 @@ import { BaseHandler } from '../common';
3
3
  import { Command } from './applications/chat';
4
4
  import { ContextMenuCommand } from './applications/menu';
5
5
  import type { UsingClient } from './applications/shared';
6
+ export interface CommandHandlerLike {
7
+ values: CommandHandler['values'];
8
+ load: CommandHandler['load'];
9
+ reload: CommandHandler['reload'];
10
+ reloadAll: CommandHandler['reloadAll'];
11
+ }
6
12
  export declare class CommandHandler extends BaseHandler {
7
13
  protected logger: Logger;
8
14
  protected client: UsingClient;