seyfert 4.4.1 → 4.6.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 (180) hide show
  1. package/README.md +7 -1
  2. package/lib/api/Routes/guilds.d.ts +12 -1
  3. package/lib/api/Routes/index.d.ts +3 -1
  4. package/lib/api/Routes/invites.d.ts +1 -1
  5. package/lib/api/Routes/oauth2.d.ts +11 -0
  6. package/lib/api/Routes/oauth2.js +2 -0
  7. package/lib/api/Routes/skus.d.ts +11 -4
  8. package/lib/api/Routes/users.d.ts +2 -1
  9. package/lib/api/Routes/voice.d.ts +4 -0
  10. package/lib/api/Routes/webhooks.d.ts +1 -1
  11. package/lib/api/api.d.ts +15 -5
  12. package/lib/api/api.js +243 -114
  13. package/lib/api/bucket.js +13 -7
  14. package/lib/api/shared.d.ts +3 -1
  15. package/lib/api/utils/constants.d.ts +1 -1
  16. package/lib/api/utils/constants.js +1 -1
  17. package/lib/builders/Attachment.d.ts +6 -1
  18. package/lib/builders/Attachment.js +13 -9
  19. package/lib/builders/CheckboxGroup.js +1 -1
  20. package/lib/builders/FileUpload.d.ts +8 -1
  21. package/lib/builders/FileUpload.js +9 -0
  22. package/lib/builders/RadioGroup.js +1 -1
  23. package/lib/client/base.d.ts +3 -3
  24. package/lib/client/client.d.ts +1 -1
  25. package/lib/client/client.js +5 -4
  26. package/lib/client/collectors.d.ts +10 -8
  27. package/lib/client/transformers.d.ts +5 -0
  28. package/lib/client/workerclient.d.ts +8 -1
  29. package/lib/client/workerclient.js +34 -14
  30. package/lib/commands/applications/chat.d.ts +6 -4
  31. package/lib/commands/applications/options.d.ts +6 -4
  32. package/lib/commands/applications/shared.d.ts +2 -2
  33. package/lib/commands/handle.d.ts +7 -3
  34. package/lib/commands/handle.js +36 -11
  35. package/lib/commands/handler.js +11 -0
  36. package/lib/commands/optionresolver.d.ts +6 -7
  37. package/lib/common/it/error.d.ts +13 -0
  38. package/lib/common/it/error.js +15 -1
  39. package/lib/common/it/logger.js +12 -9
  40. package/lib/common/shorters/application.d.ts +1 -1
  41. package/lib/common/shorters/application.js +1 -1
  42. package/lib/common/shorters/bans.js +1 -1
  43. package/lib/common/shorters/guilds.js +5 -1
  44. package/lib/common/shorters/interaction.js +7 -4
  45. package/lib/common/shorters/invites.d.ts +5 -0
  46. package/lib/common/shorters/members.js +2 -1
  47. package/lib/common/shorters/messages.js +2 -2
  48. package/lib/common/shorters/threads.js +1 -1
  49. package/lib/common/shorters/webhook.js +3 -3
  50. package/lib/common/types/util.d.ts +7 -0
  51. package/lib/components/componentcommand.js +2 -2
  52. package/lib/components/customId.d.ts +3 -0
  53. package/lib/components/customId.js +11 -0
  54. package/lib/components/handler.js +2 -3
  55. package/lib/components/modalcommand.js +2 -2
  56. package/lib/events/hooks/invite.d.ts +1 -0
  57. package/lib/events/hooks/presence.d.ts +1 -0
  58. package/lib/events/hooks/thread.d.ts +1 -0
  59. package/lib/index.d.ts +1 -1
  60. package/lib/index.js +2 -1
  61. package/lib/structures/AnonymousGuild.d.ts +1 -1
  62. package/lib/structures/AnonymousGuild.js +1 -1
  63. package/lib/structures/Guild.d.ts +3 -0
  64. package/lib/structures/GuildMember.d.ts +2 -2
  65. package/lib/structures/GuildMember.js +22 -4
  66. package/lib/structures/GuildPreview.d.ts +1 -1
  67. package/lib/structures/GuildPreview.js +1 -1
  68. package/lib/structures/GuildRole.d.ts +13 -0
  69. package/lib/structures/GuildRole.js +21 -0
  70. package/lib/structures/GuildTemplate.js +1 -1
  71. package/lib/structures/Interaction.d.ts +7 -7
  72. package/lib/structures/Interaction.js +35 -21
  73. package/lib/structures/Message.d.ts +2 -1
  74. package/lib/structures/channels.d.ts +29 -16
  75. package/lib/structures/channels.js +59 -19
  76. package/lib/structures/extra/BaseGuild.d.ts +4 -4
  77. package/lib/structures/extra/BaseGuild.js +4 -4
  78. package/lib/types/gateway.d.ts +243 -239
  79. package/lib/types/index.d.ts +2 -2
  80. package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/attachment.d.ts +5 -2
  81. package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/shared.d.ts +2 -2
  82. package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/shared.js +1 -1
  83. package/lib/types/payloads/_interactions/_applicationCommands/chatInput.d.ts +7 -7
  84. package/lib/types/payloads/_interactions/_applicationCommands/contextMenu.d.ts +13 -13
  85. package/lib/types/payloads/_interactions/_applicationCommands/permissions.d.ts +4 -4
  86. package/lib/types/payloads/_interactions/_applicationCommands/permissions.js +2 -2
  87. package/lib/types/payloads/_interactions/applicationCommands.d.ts +10 -10
  88. package/lib/types/payloads/_interactions/applicationCommands.js +4 -4
  89. package/lib/types/payloads/_interactions/autocomplete.d.ts +2 -2
  90. package/lib/types/payloads/_interactions/base.d.ts +13 -7
  91. package/lib/types/payloads/_interactions/modalSubmit.d.ts +4 -4
  92. package/lib/types/payloads/_interactions/responses.d.ts +10 -10
  93. package/lib/types/payloads/_interactions/responses.js +2 -2
  94. package/lib/types/payloads/application.d.ts +21 -15
  95. package/lib/types/payloads/application.js +7 -7
  96. package/lib/types/payloads/auditLog.d.ts +22 -17
  97. package/lib/types/payloads/auditLog.js +7 -2
  98. package/lib/types/payloads/autoModeration.d.ts +11 -11
  99. package/lib/types/payloads/autoModeration.js +5 -5
  100. package/lib/types/payloads/channel.d.ts +87 -78
  101. package/lib/types/payloads/channel.js +16 -11
  102. package/lib/types/payloads/components.d.ts +41 -31
  103. package/lib/types/payloads/components.js +9 -5
  104. package/lib/types/payloads/emoji.d.ts +2 -2
  105. package/lib/types/payloads/emoji.js +1 -1
  106. package/lib/types/payloads/gateway.d.ts +33 -29
  107. package/lib/types/payloads/gateway.js +5 -5
  108. package/lib/types/payloads/guild.d.ts +68 -68
  109. package/lib/types/payloads/guild.js +14 -14
  110. package/lib/types/payloads/guildScheduledEvent.d.ts +11 -11
  111. package/lib/types/payloads/guildScheduledEvent.js +3 -3
  112. package/lib/types/payloads/index.d.ts +2 -2
  113. package/lib/types/payloads/interactions.d.ts +3 -3
  114. package/lib/types/payloads/invite.d.ts +11 -11
  115. package/lib/types/payloads/invite.js +3 -3
  116. package/lib/types/payloads/monetization.d.ts +4 -4
  117. package/lib/types/payloads/monetization.js +2 -2
  118. package/lib/types/payloads/oauth2.d.ts +21 -17
  119. package/lib/types/payloads/oauth2.js +21 -17
  120. package/lib/types/payloads/permissions.d.ts +5 -5
  121. package/lib/types/payloads/permissions.js +2 -2
  122. package/lib/types/payloads/poll.d.ts +7 -7
  123. package/lib/types/payloads/poll.js +2 -2
  124. package/lib/types/payloads/soundboard.d.ts +2 -2
  125. package/lib/types/payloads/soundboard.js +1 -1
  126. package/lib/types/payloads/stageInstance.d.ts +5 -5
  127. package/lib/types/payloads/stageInstance.js +1 -1
  128. package/lib/types/payloads/sticker.d.ts +8 -8
  129. package/lib/types/payloads/sticker.js +3 -3
  130. package/lib/types/payloads/teams.d.ts +8 -8
  131. package/lib/types/payloads/teams.js +3 -3
  132. package/lib/types/payloads/template.d.ts +3 -3
  133. package/lib/types/payloads/template.js +1 -1
  134. package/lib/types/payloads/user.d.ts +24 -22
  135. package/lib/types/payloads/user.js +7 -5
  136. package/lib/types/payloads/voice.d.ts +4 -4
  137. package/lib/types/payloads/voice.js +1 -1
  138. package/lib/types/payloads/webhokEvents.d.ts +5 -5
  139. package/lib/types/payloads/webhokEvents.js +2 -2
  140. package/lib/types/payloads/webhook.d.ts +4 -4
  141. package/lib/types/payloads/webhook.js +1 -1
  142. package/lib/types/rest/application.d.ts +14 -14
  143. package/lib/types/rest/auditLog.d.ts +1 -1
  144. package/lib/types/rest/autoModeration.d.ts +7 -7
  145. package/lib/types/rest/channel.d.ts +79 -74
  146. package/lib/types/rest/channel.js +1 -1
  147. package/lib/types/rest/emoji.d.ts +8 -8
  148. package/lib/types/rest/gateway.d.ts +2 -2
  149. package/lib/types/rest/guild.d.ts +98 -98
  150. package/lib/types/rest/guild.js +5 -5
  151. package/lib/types/rest/guildScheduledEvent.d.ts +11 -11
  152. package/lib/types/rest/index.d.ts +34 -3
  153. package/lib/types/rest/index.js +33 -2
  154. package/lib/types/rest/interactions.d.ts +48 -48
  155. package/lib/types/rest/invite.d.ts +5 -5
  156. package/lib/types/rest/monetization.d.ts +9 -9
  157. package/lib/types/rest/monetization.js +1 -1
  158. package/lib/types/rest/oauth2.d.ts +22 -18
  159. package/lib/types/rest/poll.d.ts +4 -4
  160. package/lib/types/rest/soundboard.d.ts +8 -8
  161. package/lib/types/rest/stageInstance.d.ts +6 -6
  162. package/lib/types/rest/sticker.d.ts +10 -10
  163. package/lib/types/rest/template.d.ts +11 -11
  164. package/lib/types/rest/user.d.ts +18 -14
  165. package/lib/types/rest/voice.d.ts +5 -5
  166. package/lib/types/rest/webhook.d.ts +38 -38
  167. package/lib/types/utils/index.d.ts +19 -19
  168. package/lib/types/utils/index.js +19 -19
  169. package/lib/websocket/SharedTypes.d.ts +2 -2
  170. package/lib/websocket/constants/index.js +2 -2
  171. package/lib/websocket/discord/heartbeater.d.ts +1 -0
  172. package/lib/websocket/discord/heartbeater.js +8 -0
  173. package/lib/websocket/discord/shard.d.ts +19 -10
  174. package/lib/websocket/discord/shard.js +255 -122
  175. package/lib/websocket/discord/sharder.d.ts +2 -2
  176. package/lib/websocket/discord/sharder.js +2 -2
  177. package/lib/websocket/discord/shared.d.ts +7 -2
  178. package/lib/websocket/discord/workermanager.d.ts +3 -1
  179. package/lib/websocket/discord/workermanager.js +31 -24
  180. package/package.json +3 -3
@@ -1,4 +1,5 @@
1
- import { type APIFileUploadComponent } from '../types';
1
+ import type { RestOrArray } from '../common';
2
+ import { type APIFileUploadComponent, type FileUploadType } from '../types';
2
3
  import { BaseComponentBuilder } from './Base';
3
4
  export declare class FileUpload extends BaseComponentBuilder<APIFileUploadComponent> {
4
5
  constructor(data?: Partial<APIFileUploadComponent>);
@@ -32,4 +33,10 @@ export declare class FileUpload extends BaseComponentBuilder<APIFileUploadCompon
32
33
  * @returns The current FileUpload instance.
33
34
  */
34
35
  setRequired(required: boolean): this;
36
+ /**
37
+ * Sets the file types accepted by the file upload.
38
+ * @param fileTypes - Media groups or dot-prefixed file extensions to accept (maximum of 10).
39
+ * @returns The current FileUpload instance.
40
+ */
41
+ setFileTypes(...fileTypes: RestOrArray<FileUploadType>): this;
35
42
  }
@@ -52,5 +52,14 @@ class FileUpload extends Base_1.BaseComponentBuilder {
52
52
  this.data.required = required;
53
53
  return this;
54
54
  }
55
+ /**
56
+ * Sets the file types accepted by the file upload.
57
+ * @param fileTypes - Media groups or dot-prefixed file extensions to accept (maximum of 10).
58
+ * @returns The current FileUpload instance.
59
+ */
60
+ setFileTypes(...fileTypes) {
61
+ this.data.file_types = fileTypes.flat();
62
+ return this;
63
+ }
55
64
  }
56
65
  exports.FileUpload = FileUpload;
@@ -53,7 +53,7 @@ class RadioGroup extends Base_1.BaseComponentBuilder {
53
53
  ...(0, common_1.createValidationMetadata)('number of options between 2 and 10', optionCount, {
54
54
  component: 'RadioGroup',
55
55
  }),
56
- detail: 'RadioGroup must have between 2 and 10 options.',
56
+ detail: `RadioGroup has an invalid options length: expected number of options between 2 and 10, received ${optionCount}.`,
57
57
  },
58
58
  });
59
59
  }
@@ -5,7 +5,7 @@ import type { Command, CommandContext, ContextMenuCommand, ExtendedRC, ExtendedR
5
5
  import { type InferWithPrefix, type MiddlewareContext } from '../commands/applications/shared';
6
6
  import { HandleCommand } from '../commands/handle';
7
7
  import { CommandHandler } from '../commands/handler';
8
- import { ApplicationShorter, ChannelShorter, EmojiShorter, GuildShorter, InteractionShorter, InvitesShorter, Logger, type MakeRequired, MemberShorter, MessageShorter, ReactionShorter, RoleShorter, TemplateShorter, ThreadShorter, UsersShorter, WebhookShorter } from '../common';
8
+ import { ApplicationShorter, ChannelShorter, EmojiShorter, GuildShorter, InteractionShorter, InvitesShorter, Logger, type MakePresent, type MakeRequired, MemberShorter, MessageShorter, ReactionShorter, RoleShorter, TemplateShorter, ThreadShorter, UsersShorter, WebhookShorter } from '../common';
9
9
  import { BanShorter } from '../common/shorters/bans';
10
10
  import { SoundboardShorter } from '../common/shorters/soundboard';
11
11
  import { VoiceStateShorter } from '../common/shorters/voiceStates';
@@ -154,13 +154,13 @@ interface RC extends ExtendedRC {
154
154
  port?: number;
155
155
  publicKey?: string;
156
156
  }
157
- export type InternalRuntimeConfigHTTP = Omit<MakeRequired<RC, 'publicKey' | 'port' | 'applicationId'>, 'intents' | 'locations'> & {
157
+ export type InternalRuntimeConfigHTTP = Omit<MakePresent<RC, 'publicKey' | 'port' | 'applicationId'>, 'intents' | 'locations'> & {
158
158
  locations: Omit<RC['locations'], 'events'>;
159
159
  };
160
160
  export type RuntimeConfigHTTP = Omit<MakeRequired<RC, 'publicKey' | 'applicationId'>, 'intents' | 'locations'> & {
161
161
  locations: Omit<RC['locations'], 'events'>;
162
162
  };
163
- export type InternalRuntimeConfig = MakeRequired<RC, 'intents'>;
163
+ export type InternalRuntimeConfig = MakePresent<RC, 'intents'>;
164
164
  export type RuntimeConfig = OmitInsert<InternalRuntimeConfig, 'intents', {
165
165
  intents?: IntentStrings | number[] | number;
166
166
  }>;
@@ -1,7 +1,7 @@
1
1
  import type { CommandContext, Message } from '..';
2
2
  import { type Awaitable, type DeepPartial, type PickPartial, type When } from '../common';
3
3
  import { EventHandler } from '../events';
4
- import type { GatewayDispatchPayload, GatewayPresenceUpdateData } from '../types';
4
+ import { type GatewayDispatchPayload, type GatewayPresenceUpdateData } from '../types';
5
5
  import { ShardManager, type ShardManagerOptions } from '../websocket';
6
6
  import { MemberUpdateHandler } from '../websocket/discord/events/memberUpdate';
7
7
  import { PresenceUpdateHandler } from '../websocket/discord/events/presenceUpdate';
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Client = void 0;
4
4
  const common_1 = require("../common");
5
5
  const events_1 = require("../events");
6
+ const types_1 = require("../types");
6
7
  const websocket_1 = require("../websocket");
7
8
  const memberUpdate_1 = require("../websocket/discord/events/memberUpdate");
8
9
  const presenceUpdate_1 = require("../websocket/discord/events/presenceUpdate");
@@ -156,19 +157,19 @@ class Client extends base_1.BaseClient {
156
157
  //rest of the events
157
158
  default: {
158
159
  switch (packet.t) {
159
- case 'INTERACTION_CREATE':
160
+ case types_1.GatewayDispatchEvents.InteractionCreate:
160
161
  {
161
162
  await this.events.execute(packet, this, shardId);
162
163
  await this.handleCommand.interaction(packet.d, shardId);
163
164
  }
164
165
  break;
165
- case 'MESSAGE_CREATE':
166
+ case types_1.GatewayDispatchEvents.MessageCreate:
166
167
  {
167
168
  await this.events.execute(packet, this, shardId);
168
169
  await this.handleCommand.message(packet.d, shardId);
169
170
  }
170
171
  break;
171
- case 'READY': {
172
+ case types_1.GatewayDispatchEvents.Ready: {
172
173
  this.botId = packet.d.user.id;
173
174
  this.applicationId = packet.d.application.id;
174
175
  this.me = transformers_1.Transformers.ClientUser(this, packet.d.user, packet.d.application);
@@ -176,7 +177,7 @@ class Client extends base_1.BaseClient {
176
177
  await this.events.execute(packet, this, shardId);
177
178
  break;
178
179
  }
179
- case 'GUILDS_READY':
180
+ case types_1.GatewayDispatchEvents.GuildsReady:
180
181
  {
181
182
  await this.events.execute(packet, this, shardId);
182
183
  if ([...this.gateway.values()].every(shard => shard.isReady)) {
@@ -1,8 +1,10 @@
1
1
  import type { Awaitable, CamelCase } from '../common';
2
- import type { CallbackEventHandler, CustomEventsKeys, GatewayEvents } from '../events';
2
+ import type { CallbackEventHandler, CustomEventsKeys, GatewayEvents, ResolveEventRunParams } from '../events';
3
3
  export type AllClientEvents = CustomEventsKeys | GatewayEvents;
4
4
  export type ParseClientEventName<T extends AllClientEvents> = T extends CustomEventsKeys ? T : CamelCase<T>;
5
- export type CollectorRunPameters<T extends AllClientEvents> = Awaited<Parameters<CallbackEventHandler[ParseClientEventName<T>]>[0]>;
5
+ export type CollectorRunParameters<T extends AllClientEvents> = T extends CustomEventsKeys ? ResolveEventRunParams<T> : Awaited<Parameters<CallbackEventHandler[ParseClientEventName<T>]>[0]>;
6
+ /** @deprecated Use {@link CollectorRunParameters}. */
7
+ export type CollectorRunPameters<T extends AllClientEvents> = CollectorRunParameters<T>;
6
8
  type RunData<T extends AllClientEvents> = {
7
9
  options: {
8
10
  event: T;
@@ -10,9 +12,9 @@ type RunData<T extends AllClientEvents> = {
10
12
  timeout?: number;
11
13
  onStop?: (reason: string) => unknown;
12
14
  onStopError?: (reason: string, error: unknown) => unknown;
13
- filter: (arg: CollectorRunPameters<T>) => Awaitable<boolean>;
14
- run: (arg: CollectorRunPameters<T>, stop: (reason?: string) => void) => unknown;
15
- onRunError?: (arg: CollectorRunPameters<T>, error: unknown, stop: (reason?: string) => void) => unknown;
15
+ filter: (arg: CollectorRunParameters<T>) => Awaitable<boolean>;
16
+ run: (arg: CollectorRunParameters<T>, stop: (reason?: string) => void) => unknown;
17
+ onRunError?: (arg: CollectorRunParameters<T>, error: unknown, stop: (reason?: string) => void) => unknown;
16
18
  };
17
19
  idle?: NodeJS.Timeout;
18
20
  timeout?: NodeJS.Timeout;
@@ -27,9 +29,9 @@ export declare class Collectors {
27
29
  timeout?: number;
28
30
  onStop?: (reason: string) => unknown;
29
31
  onStopError?: (reason: string, error: unknown) => unknown;
30
- filter: (arg: Awaited<Parameters<CallbackEventHandler[ParseClientEventName<T>]>[0]>) => Awaitable<boolean>;
31
- run: (arg: Awaited<Parameters<CallbackEventHandler[ParseClientEventName<T>]>[0]>, stop: (reason?: string) => void) => unknown;
32
- onRunError?: ((arg: Awaited<Parameters<CallbackEventHandler[ParseClientEventName<T>]>[0]>, error: unknown, stop: (reason?: string) => void) => unknown) | undefined;
32
+ filter: (arg: CollectorRunParameters<T>) => Awaitable<boolean>;
33
+ run: (arg: CollectorRunParameters<T>, stop: (reason?: string) => void) => unknown;
34
+ onRunError?: ((arg: CollectorRunParameters<T>, error: unknown, stop: (reason?: string) => void) => unknown) | undefined;
33
35
  };
34
36
  private delete;
35
37
  }
@@ -13,6 +13,11 @@ export type BaseChannelStructure = InferCustomStructure<BaseChannel<ChannelType>
13
13
  export type BaseGuildChannelStructure = InferCustomStructure<BaseGuildChannel, 'BaseGuildChannel'>;
14
14
  export type TextGuildChannelStructure = InferCustomStructure<TextGuildChannel, 'TextGuildChannel'>;
15
15
  export type DMChannelStructure = InferCustomStructure<DMChannel, 'DMChannel'>;
16
+ export type GroupDMChannelStructure = Omit<DMChannelStructure, 'isDM' | 'name' | 'type'> & {
17
+ isDM(): this is GroupDMChannelStructure;
18
+ name: string | null;
19
+ type: ChannelType.GroupDM;
20
+ };
16
21
  export type VoiceChannelStructure = InferCustomStructure<VoiceChannel, 'VoiceChannel'>;
17
22
  export type StageChannelStructure = InferCustomStructure<StageChannel, 'StageChannel'>;
18
23
  export type MediaChannelStructure = InferCustomStructure<MediaChannel, 'MediaChannel'>;
@@ -1,6 +1,6 @@
1
1
  import { type Awaitable, type DeepPartial, type MakeRequired, type When } from '../common';
2
2
  import { EventHandler } from '../events';
3
- import type { GatewayDispatchPayload } from '../types';
3
+ import { type GatewayDispatchPayload, type GatewaySendPayload } from '../types';
4
4
  import { Shard, type ShardManagerOptions, type WorkerData } from '../websocket';
5
5
  import { MemberUpdateHandler } from '../websocket/discord/events/memberUpdate';
6
6
  import { PresenceUpdateHandler } from '../websocket/discord/events/presenceUpdate';
@@ -41,6 +41,13 @@ export declare class WorkerClient<Ready extends boolean = boolean> extends BaseC
41
41
  postMessage(body: WorkerMessages | ClientHeartbeaterMessages): unknown;
42
42
  handleManagerMessages(data: ManagerMessages | WorkerHeartbeaterMessages): Promise<any>;
43
43
  calculateShardId(guildId: string): number;
44
+ /**
45
+ * Sends a Gateway payload through the worker client's shard rate limiter.
46
+ *
47
+ * @returns `true` after the payload is sent.
48
+ */
49
+ sendGatewayPayload<T extends GatewaySendPayload>(shardId: number, payload: T): Promise<boolean>;
50
+ private sendGatewayPayloadOnShard;
44
51
  private generateNonce;
45
52
  private generateSendPromise;
46
53
  tellWorker<R, V extends Record<string, unknown>>(workerId: number, func: (_: this, vars: V) => R, vars: V): Promise<R>;
@@ -7,6 +7,7 @@ const __1 = require("..");
7
7
  const cache_1 = require("../cache");
8
8
  const common_1 = require("../common");
9
9
  const events_1 = require("../events");
10
+ const types_1 = require("../types");
10
11
  const websocket_1 = require("../websocket");
11
12
  const memberUpdate_1 = require("../websocket/discord/events/memberUpdate");
12
13
  const presenceUpdate_1 = require("../websocket/discord/events/presenceUpdate");
@@ -155,14 +156,12 @@ class WorkerClient extends base_1.BaseClient {
155
156
  break;
156
157
  case 'SEND_PAYLOAD':
157
158
  {
158
- const shard = this.shards.get(data.shardId);
159
- if (!shard) {
160
- this.logger.fatal('Worker trying send payload by non-existent shard');
159
+ const { nonce: _nonce, shardId: _shardId, type: _type, ...payload } = data;
160
+ const result = await this.sendGatewayPayloadOnShard(data.shardId, payload, true);
161
+ if (result === 'missing') {
162
+ this.logger.fatal(`Worker trying to send payload by non-existent shard (#${data.shardId})`);
161
163
  return;
162
164
  }
163
- await shard.send(true, {
164
- ...data,
165
- });
166
165
  this.postMessage({
167
166
  type: 'RESULT_PAYLOAD',
168
167
  nonce: data.nonce,
@@ -215,7 +214,7 @@ class WorkerClient extends base_1.BaseClient {
215
214
  ...this.options.gateway?.properties,
216
215
  },
217
216
  handlePayload(_, payload) {
218
- if (payload.t !== 'GUILDS_READY')
217
+ if (payload.t !== types_1.GatewayDispatchEvents.GuildsReady)
219
218
  return;
220
219
  if (++shardsConnected === workerData.shards.length) {
221
220
  self.postMessage({
@@ -288,7 +287,7 @@ class WorkerClient extends base_1.BaseClient {
288
287
  this.rest.workerPromises.delete(data.nonce);
289
288
  if (data.error)
290
289
  return promise.reject(data.error);
291
- promise.resolve(data.response);
290
+ promise.resolve(data.responseType === 'arrayBuffer' ? Uint8Array.from(data.response).buffer : data.response);
292
291
  }
293
292
  break;
294
293
  case 'EXECUTE_EVAL':
@@ -361,17 +360,38 @@ class WorkerClient extends base_1.BaseClient {
361
360
  calculateShardId(guildId) {
362
361
  return (0, common_1.calculateShardId)(guildId, this.workerData.totalShards);
363
362
  }
363
+ /**
364
+ * Sends a Gateway payload through the worker client's shard rate limiter.
365
+ *
366
+ * @returns `true` after the payload is sent.
367
+ */
368
+ async sendGatewayPayload(shardId, payload) {
369
+ const result = await this.sendGatewayPayloadOnShard(shardId, payload, false);
370
+ if (result === 'missing') {
371
+ throw new common_1.SeyfertError('INTERNAL_ERROR', { metadata: { detail: `Shard #${shardId} doesn't exist` } });
372
+ }
373
+ return true;
374
+ }
375
+ async sendGatewayPayloadOnShard(shardId, payload, force) {
376
+ const shard = this.shards.get(shardId);
377
+ if (!shard)
378
+ return 'missing';
379
+ await shard.send(force, payload);
380
+ return 'sent';
381
+ }
364
382
  generateNonce() {
365
383
  const uuid = (0, node_crypto_1.randomUUID)();
366
384
  if (this.promises.has(uuid))
367
385
  return this.generateNonce();
368
386
  return uuid;
369
387
  }
370
- generateSendPromise(nonce, message = 'Timeout') {
388
+ generateSendPromise(nonce, operation = 'Worker request') {
371
389
  return new Promise((res, rej) => {
372
390
  const timeout = setTimeout(() => {
373
391
  this.promises.delete(nonce);
374
- rej(new common_1.SeyfertError('WORKER_TIMEOUT', { metadata: { ...{ nonce }, detail: message } }));
392
+ rej(new common_1.SeyfertError('WORKER_TIMEOUT', {
393
+ metadata: { nonce, operation, detail: `${operation} timed out (nonce: ${nonce}).` },
394
+ }));
375
395
  }, 60e3);
376
396
  this.promises.set(nonce, { resolve: res, timeout });
377
397
  });
@@ -470,19 +490,19 @@ class WorkerClient extends base_1.BaseClient {
470
490
  break;
471
491
  default: {
472
492
  switch (packet.t) {
473
- case 'INTERACTION_CREATE':
493
+ case types_1.GatewayDispatchEvents.InteractionCreate:
474
494
  {
475
495
  await this.events.execute(packet, this, shardId);
476
496
  await this.handleCommand.interaction(packet.d, shardId);
477
497
  }
478
498
  break;
479
- case 'MESSAGE_CREATE':
499
+ case types_1.GatewayDispatchEvents.MessageCreate:
480
500
  {
481
501
  await this.events.execute(packet, this, shardId);
482
502
  await this.handleCommand.message(packet.d, shardId);
483
503
  }
484
504
  break;
485
- case 'READY': {
505
+ case types_1.GatewayDispatchEvents.Ready: {
486
506
  this.botId = packet.d.user.id;
487
507
  this.applicationId = packet.d.application.id;
488
508
  this.me = transformers_1.Transformers.ClientUser(this, packet.d.user, packet.d.application);
@@ -497,7 +517,7 @@ class WorkerClient extends base_1.BaseClient {
497
517
  this.debugger?.debug(`#${shardId}[${packet.d.user.username}](${this.botId}) is online...`);
498
518
  break;
499
519
  }
500
- case 'GUILDS_READY':
520
+ case types_1.GatewayDispatchEvents.GuildsReady:
501
521
  {
502
522
  if ([...this.shards.values()].every(shard => shard.isReady)) {
503
523
  this.postMessage({
@@ -1,12 +1,14 @@
1
1
  import type { PermissionStrings, SeyfertBaseChoiceableOption, SeyfertBasicOption, SeyfertChoice } from '../..';
2
2
  import type { Attachment } from '../../builders';
3
3
  import type { GuildMemberStructure, GuildRoleStructure, InteractionGuildMemberStructure, UserStructure } from '../../client/transformers';
4
- import type { AllChannels, AutocompleteInteraction } from '../../structures';
4
+ import { type If } from '../../common';
5
+ import type { AutocompleteInteraction, MaybeResolvedChannel, ResolvedChannel } from '../../structures';
5
6
  import { type APIApplicationCommandBasicOption, type APIApplicationCommandOption, ApplicationCommandOptionType, ApplicationCommandType, type ApplicationIntegrationType, type InteractionContextType, type LocaleString } from '../../types';
6
7
  import type { Groups, RegisteredMiddlewares } from '../decorators';
7
8
  import type { CommandOptionWithType } from '../handle';
8
9
  import type { CommandContext } from './chatcontext';
9
- import type { ExtraProps, IgnoreCommand, OnOptionsReturnObject, SeyfertChannelMap, UsingClient } from './shared';
10
+ import type { ExtraProps, IgnoreCommand, InferWithPrefix, OnOptionsReturnObject, SeyfertChannelMap, UsingClient } from './shared';
11
+ export type CommandOptionChannel<C extends keyof SeyfertChannelMap = keyof SeyfertChannelMap> = If<InferWithPrefix, MaybeResolvedChannel<SeyfertChannelMap[C]>, ResolvedChannel<SeyfertChannelMap[C]>>;
10
12
  export interface ReturnOptionsTypes {
11
13
  1: never;
12
14
  2: never;
@@ -14,7 +16,7 @@ export interface ReturnOptionsTypes {
14
16
  4: number;
15
17
  5: boolean;
16
18
  6: InteractionGuildMemberStructure | UserStructure;
17
- 7: AllChannels;
19
+ 7: CommandOptionChannel;
18
20
  8: GuildRoleStructure;
19
21
  9: GuildRoleStructure | InteractionGuildMemberStructure | GuildMemberStructure | UserStructure;
20
22
  10: number;
@@ -44,7 +46,7 @@ type ContextOptionsAuxInternal<T extends CommandBaseOption & {
44
46
  type: ApplicationCommandOptionType;
45
47
  }> = T['value'] extends (...args: any) => any ? Parameters<Parameters<T['value']>[1]>[0] : NonNullable<T['value']> extends (...args: any) => any ? Parameters<Parameters<NonNullable<T['value']>>[1]>[0] extends never ? T extends {
46
48
  channel_types?: infer C;
47
- } ? C extends any[] ? C[number] extends keyof SeyfertChannelMap ? SeyfertChannelMap[C[number]] : never : never : T extends {
49
+ } ? C extends any[] ? C[number] extends keyof SeyfertChannelMap ? CommandOptionChannel<C[number]> : never : never : T extends {
48
50
  choices?: infer C;
49
51
  } ? C extends SeyfertChoice<string | number>[] ? C[number]['value'] : never : never : Parameters<Parameters<NonNullable<T['value']>>[1]>[0] : ReturnOptionsTypes[T['type']];
50
52
  type ContextOptionsAux<T extends OptionsRecord> = {
@@ -2,9 +2,9 @@ import type { Awaitable, FlatObjectKeys } from '../../common';
2
2
  import type { ModalContext } from '../../components';
3
3
  import type { ComponentContext } from '../../components/componentcontext';
4
4
  import type { MessageCommandInteraction, UserCommandInteraction } from '../../structures';
5
- import { type APIApplicationCommandBasicOption, type APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from '../../types';
5
+ import { type APIApplicationCommandBasicOption, type APIApplicationCommandOptionChoice, ApplicationCommandOptionType, type FileUploadType } from '../../types';
6
6
  import type { LocalizationMap } from '../../types/payloads';
7
- import type { AutocompleteCallback, EntryPointContext, MenuCommandContext, OnAutocompleteErrorCallback, ReturnOptionsTypes } from '..';
7
+ import type { AutocompleteCallback, CommandOptionChannel, EntryPointContext, MenuCommandContext, OnAutocompleteErrorCallback, ReturnOptionsTypes } from '..';
8
8
  import type { CommandContext } from './chatcontext';
9
9
  import type { DefaultLocale, MiddlewareContext, OKFunction, SeyfertChannelMap, StopFunction } from './shared';
10
10
  export interface SeyfertBasicOption<T extends keyof ReturnOptionsTypes, R = true | false> {
@@ -49,7 +49,7 @@ export interface ChoiceableValues {
49
49
  }
50
50
  export type ValueCallback<T extends keyof ReturnOptionsTypes, C = T extends ChoiceableTypes ? SeyfertChoice<ChoiceableValues[T]>[] : keyof SeyfertChannelMap, I = any> = (data: {
51
51
  context: CommandContext;
52
- value: T extends ChoiceableTypes ? C extends SeyfertChoice<ChoiceableValues[T]>[] ? C[number]['value'] extends ReturnOptionsTypes[T] ? C[number]['value'] : never : never : C extends keyof SeyfertChannelMap ? SeyfertChannelMap[C] : never;
52
+ value: T extends ChoiceableTypes ? C extends SeyfertChoice<ChoiceableValues[T]>[] ? C[number]['value'] extends ReturnOptionsTypes[T] ? C[number]['value'] : never : never : C extends keyof SeyfertChannelMap ? CommandOptionChannel<C> : never;
53
53
  }, ok: OKFunction<I>, fail: StopFunction) => Awaitable<void>;
54
54
  export type SeyfertStringOption<T = SeyfertChoice<string>[], R = boolean, VC = never> = SeyfertBaseChoiceableOption<ApplicationCommandOptionType.String, T, R, VC> & {
55
55
  autocomplete?: AutocompleteCallback;
@@ -85,7 +85,9 @@ export type SeyfertChannelOption<C = keyof SeyfertChannelMap, R = true | false,
85
85
  };
86
86
  export type SeyfertRoleOption<R = boolean> = SeyfertBasicOption<ApplicationCommandOptionType.Role, R>;
87
87
  export type SeyfertMentionableOption<R = boolean> = SeyfertBasicOption<ApplicationCommandOptionType.Mentionable, R>;
88
- export type SeyfertAttachmentOption<R = boolean> = SeyfertBasicOption<ApplicationCommandOptionType.Attachment, R>;
88
+ export type SeyfertAttachmentOption<R = boolean> = SeyfertBasicOption<ApplicationCommandOptionType.Attachment, R> & {
89
+ file_types?: readonly FileUploadType[];
90
+ };
89
91
  export declare function createStringOption<R extends boolean, C extends SeyfertChoice<string>[] = SeyfertChoice<string>[], VC = never>(data: SeyfertStringOption<C, R, VC>): {
90
92
  readonly type: ApplicationCommandOptionType.String;
91
93
  readonly required?: R | undefined;
@@ -1,4 +1,4 @@
1
- import type { CategoryChannelStructure, DirectoryChannelStructure, DMChannelStructure, ForumChannelStructure, MediaChannelStructure, NewsChannelStructure, StageChannelStructure, TextGuildChannelStructure, ThreadChannelStructure, VoiceChannelStructure } from '../../client';
1
+ import type { CategoryChannelStructure, DirectoryChannelStructure, DMChannelStructure, ForumChannelStructure, GroupDMChannelStructure, MediaChannelStructure, NewsChannelStructure, StageChannelStructure, TextGuildChannelStructure, ThreadChannelStructure, VoiceChannelStructure } from '../../client';
2
2
  import type { BaseClient } from '../../client/base';
3
3
  import type { IsStrictlyUndefined } from '../../common';
4
4
  import type { ChannelType } from '../../types';
@@ -73,7 +73,7 @@ export interface SeyfertChannelMap {
73
73
  [ChannelType.GuildText]: TextGuildChannelStructure;
74
74
  [ChannelType.DM]: DMChannelStructure;
75
75
  [ChannelType.GuildVoice]: VoiceChannelStructure;
76
- [ChannelType.GroupDM]: DMChannelStructure;
76
+ [ChannelType.GroupDM]: GroupDMChannelStructure;
77
77
  [ChannelType.GuildCategory]: CategoryChannelStructure;
78
78
  [ChannelType.GuildAnnouncement]: NewsChannelStructure;
79
79
  [ChannelType.AnnouncementThread]: ThreadChannelStructure;
@@ -1,8 +1,8 @@
1
1
  import { type MessageStructure, type OptionResolverStructure, Transformers } from '../client/transformers';
2
- import type { MakeRequired } from '../common';
2
+ import { type Awaitable, type MakeRequired, type PermissionStrings } from '../common';
3
3
  import { type __InternalReplyFunction, AutocompleteInteraction, type ChatInputCommandInteraction, type ComponentInteraction, type EntryPointInteraction, type MessageCommandInteraction, type ModalSubmitInteraction, type UserCommandInteraction } from '../structures';
4
4
  import type { PermissionsBitField } from '../structures/extra/Permissions';
5
- import { type APIApplicationCommandInteraction, type APIApplicationCommandInteractionDataOption, type APIInteraction, ApplicationCommandOptionType, type GatewayMessageCreateDispatchData } from '../types';
5
+ import { type APIApplicationCommandInteraction, type APIApplicationCommandInteractionDataOption, type APIGuildMember, type APIInteraction, ApplicationCommandOptionType, type GatewayMessageCreateDispatchData } from '../types';
6
6
  import { Command, type CommandAutocompleteOption, CommandContext, type CommandOption, type ContextMenuCommand, type ContextOptionsResolved, type EntryPointCommand, EntryPointContext, MenuCommandContext, type MessageCommandOptionErrors, SubCommand, type UsingClient } from '.';
7
7
  export type CommandOptionWithType = CommandOption & {
8
8
  type: ApplicationCommandOptionType;
@@ -36,10 +36,14 @@ export declare class HandleCommand {
36
36
  guild_id?: string;
37
37
  name: string;
38
38
  }): T | undefined;
39
+ /** Checks the member permissions required by a command. */
40
+ checkMemberPermissions(command: Command | SubCommand, _context: CommandContext, permissions: PermissionsBitField): Awaitable<PermissionStrings | undefined>;
41
+ /** Checks the bot permissions required by a command. */
42
+ checkBotPermissions(command: Command | SubCommand | ContextMenuCommand | EntryPointCommand, _context: CommandContext | MenuCommandContext<any> | EntryPointContext, permissions: PermissionsBitField): Awaitable<PermissionStrings | undefined>;
39
43
  checkPermissions(app: PermissionsBitField, bot: bigint): ("CreateInstantInvite" | "KickMembers" | "BanMembers" | "Administrator" | "ManageChannels" | "ManageGuild" | "AddReactions" | "ViewAuditLog" | "PrioritySpeaker" | "Stream" | "ViewChannel" | "SendMessages" | "SendTTSMessages" | "ManageMessages" | "EmbedLinks" | "AttachFiles" | "ReadMessageHistory" | "MentionEveryone" | "UseExternalEmojis" | "ViewGuildInsights" | "Connect" | "Speak" | "MuteMembers" | "DeafenMembers" | "MoveMembers" | "UseVAD" | "ChangeNickname" | "ManageNicknames" | "ManageRoles" | "ManageWebhooks" | "ManageGuildExpressions" | "UseApplicationCommands" | "RequestToSpeak" | "ManageEvents" | "ManageThreads" | "CreatePublicThreads" | "CreatePrivateThreads" | "UseExternalStickers" | "SendMessagesInThreads" | "UseEmbeddedActivities" | "ModerateMembers" | "ViewCreatorMonetizationAnalytics" | "UseSoundboard" | "CreateGuildExpressions" | "CreateEvents" | "UseExternalSounds" | "SendVoiceMessages" | "SetVoiceChannelStatus" | "SendPolls" | "UseExternalApps" | "PinMessages" | "BypassSlowmode")[] | undefined;
40
44
  fetchChannel(_option: CommandOptionWithType, query: string): Promise<import("../types").APIChannel> | null;
41
45
  fetchUser(_option: CommandOptionWithType, query: string): Promise<import("../types").APIUser> | null;
42
- fetchMember(_option: CommandOptionWithType, query: string, guildId: string): Promise<import("../types").APIGuildMember> | null;
46
+ fetchMember(_option: CommandOptionWithType, query: string, guildId: string): Promise<APIGuildMember | null>;
43
47
  fetchRole(_option: CommandOptionWithType, query: string, guildId?: string): Promise<import("../types").APIRole> | null;
44
48
  runGlobalMiddlewares(command: Command | ContextMenuCommand | SubCommand | EntryPointCommand, context: CommandContext<{}, never> | MenuCommandContext<any> | EntryPointContext): Promise<false | {
45
49
  error?: string;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HandleCommand = void 0;
4
4
  const transformers_1 = require("../client/transformers");
5
+ const common_1 = require("../common");
5
6
  const constants_1 = require("../common/it/constants");
6
7
  const components_1 = require("../components");
7
8
  const structures_1 = require("../structures");
@@ -39,7 +40,7 @@ class HandleCommand {
39
40
  async contextMenu(command, interaction, context) {
40
41
  try {
41
42
  if (context.guildId && command.botPermissions) {
42
- const permissions = this.checkPermissions(interaction.appPermissions, command.botPermissions);
43
+ const permissions = await this.checkBotPermissions(command, context, interaction.appPermissions);
43
44
  if (permissions)
44
45
  return await command.onBotPermissionsFail?.(context, permissions);
45
46
  }
@@ -77,7 +78,7 @@ class HandleCommand {
77
78
  async entryPoint(command, interaction, context) {
78
79
  try {
79
80
  if (context.guildId && command.botPermissions) {
80
- const permissions = this.checkPermissions(interaction.appPermissions, command.botPermissions);
81
+ const permissions = await this.checkBotPermissions(command, context, interaction.appPermissions);
81
82
  if (permissions)
82
83
  return await command.onBotPermissionsFail(context, permissions);
83
84
  }
@@ -110,12 +111,12 @@ class HandleCommand {
110
111
  try {
111
112
  if (context.guildId) {
112
113
  if (command.botPermissions) {
113
- const permissions = this.checkPermissions(interaction.appPermissions, command.botPermissions);
114
+ const permissions = await this.checkBotPermissions(command, context, interaction.appPermissions);
114
115
  if (permissions)
115
116
  return await command.onBotPermissionsFail?.(context, permissions);
116
117
  }
117
118
  if (command.defaultMemberPermissions) {
118
- const permissions = this.checkPermissions(interaction.member.permissions, command.defaultMemberPermissions);
119
+ const permissions = await this.checkMemberPermissions(command, context, interaction.member.permissions);
119
120
  if (permissions)
120
121
  return await command.onPermissionsFail?.(context, permissions);
121
122
  }
@@ -288,15 +289,15 @@ class HandleCommand {
288
289
  if (rawMessage.guild_id) {
289
290
  if (command.defaultMemberPermissions) {
290
291
  const memberPermissions = await self.members.permissions(rawMessage.guild_id, rawMessage.author.id);
291
- const permissions = this.checkPermissions(memberPermissions, command.defaultMemberPermissions);
292
+ const permissions = await this.checkMemberPermissions(command, context, memberPermissions);
292
293
  const guild = await this.client.guilds.raw(rawMessage.guild_id);
293
294
  if (permissions && guild.owner_id !== rawMessage.author.id) {
294
- return await command.onPermissionsFail?.(context, memberPermissions.keys(permissions));
295
+ return await command.onPermissionsFail?.(context, permissions);
295
296
  }
296
297
  }
297
298
  if (command.botPermissions) {
298
299
  const appPermissions = await self.members.permissions(rawMessage.guild_id, self.botId);
299
- const permissions = this.checkPermissions(appPermissions, command.botPermissions);
300
+ const permissions = await this.checkBotPermissions(command, context, appPermissions);
300
301
  if (permissions) {
301
302
  return await command.onBotPermissionsFail?.(context, permissions);
302
303
  }
@@ -402,6 +403,18 @@ class HandleCommand {
402
403
  return command.name === data.name;
403
404
  });
404
405
  }
406
+ /** Checks the member permissions required by a command. */
407
+ checkMemberPermissions(command, _context, permissions) {
408
+ if (!command.defaultMemberPermissions)
409
+ return;
410
+ return this.checkPermissions(permissions, command.defaultMemberPermissions);
411
+ }
412
+ /** Checks the bot permissions required by a command. */
413
+ checkBotPermissions(command, _context, permissions) {
414
+ if (!command.botPermissions)
415
+ return;
416
+ return this.checkPermissions(permissions, command.botPermissions);
417
+ }
405
418
  checkPermissions(app, bot) {
406
419
  if (app.has(['Administrator']))
407
420
  return;
@@ -423,11 +436,23 @@ class HandleCommand {
423
436
  return this.client.users.raw(id);
424
437
  return null;
425
438
  }
426
- fetchMember(_option, query, guildId) {
439
+ async fetchMember(_option, query, guildId) {
427
440
  const id = query.match(/[0-9]{17,19}/g)?.[0];
428
- if (id)
429
- return this.client.members.raw(guildId, id);
430
- return null;
441
+ if (!id)
442
+ return null;
443
+ try {
444
+ return await this.client.members.raw(guildId, id);
445
+ }
446
+ catch (error) {
447
+ const response = common_1.SeyfertError.is(error) ? error.metadata?.response : undefined;
448
+ if (typeof response === 'object' &&
449
+ response !== null &&
450
+ 'code' in response &&
451
+ [types_1.RESTJSONErrorCodes.UnknownMember, types_1.RESTJSONErrorCodes.UnknownUser].includes(response.code)) {
452
+ return null;
453
+ }
454
+ throw error;
455
+ }
431
456
  }
432
457
  fetchRole(_option, query, guildId) {
433
458
  const id = query.match(/[0-9]{17,19}/g)?.[0];
@@ -136,6 +136,17 @@ class CommandHandler extends common_1.BaseHandler {
136
136
  !!option.autocomplete !== !!cached.autocomplete ||
137
137
  this.shoudUploadChoices(option, cached));
138
138
  case types_1.ApplicationCommandOptionType.Attachment:
139
+ {
140
+ const cachedAttachment = cached;
141
+ if (option.file_types?.length !== cachedAttachment.file_types?.length)
142
+ return true;
143
+ if (option.file_types && cachedAttachment.file_types) {
144
+ const fileTypes = [...option.file_types].sort();
145
+ const cachedFileTypes = [...cachedAttachment.file_types].sort();
146
+ return fileTypes.some((fileType, index) => fileType !== cachedFileTypes[index]);
147
+ }
148
+ }
149
+ break;
139
150
  case types_1.ApplicationCommandOptionType.Boolean:
140
151
  case types_1.ApplicationCommandOptionType.Mentionable:
141
152
  case types_1.ApplicationCommandOptionType.Role:
@@ -1,9 +1,8 @@
1
1
  import { Attachment } from '../builders';
2
2
  import { type GuildMemberStructure, type GuildRoleStructure, type InteractionGuildMemberStructure, type UserStructure } from '../client/transformers';
3
- import { type MakeRequired } from '../common';
4
- import { type AllChannels } from '../structures';
3
+ import { type MakePresent } from '../common';
5
4
  import { type APIApplicationCommandInteractionDataOption, type APIAttachment, type APIGuildMember, type APIInteractionDataResolvedChannel, type APIInteractionGuildMember, type APIRole, type APIUser, ApplicationCommandOptionType } from '../types';
6
- import type { Command, CommandAutocompleteOption, SubCommand } from './applications/chat';
5
+ import type { Command, CommandAutocompleteOption, CommandOptionChannel, SubCommand } from './applications/chat';
7
6
  import type { UsingClient } from './applications/shared';
8
7
  export type ContextOptionsResolved = {
9
8
  members?: Record<string, APIGuildMember | Omit<APIGuildMember, 'user'> | APIInteractionGuildMember>;
@@ -31,9 +30,9 @@ export declare class OptionResolver {
31
30
  getGroup(): string | undefined;
32
31
  get(name: string): OptionResolved | undefined;
33
32
  getHoisted(name: string): OptionResolved | undefined;
34
- getValue(name: string): AllChannels | Attachment | boolean | number | string | UserStructure | GuildMemberStructure | InteractionGuildMemberStructure | GuildRoleStructure | undefined;
33
+ getValue(name: string): CommandOptionChannel | Attachment | boolean | number | string | UserStructure | GuildMemberStructure | InteractionGuildMemberStructure | GuildRoleStructure | undefined;
35
34
  private getTypedOption;
36
- getChannel(name: string, required?: true): AllChannels;
35
+ getChannel(name: string, required?: true): CommandOptionChannel;
37
36
  getString(name: string, required?: true): string;
38
37
  transformOption(option: APIApplicationCommandInteractionDataOption, resolved?: ContextOptionsResolved): OptionResolved;
39
38
  }
@@ -45,11 +44,11 @@ export interface OptionResolved {
45
44
  user?: UserStructure;
46
45
  member?: GuildMemberStructure | InteractionGuildMemberStructure;
47
46
  attachment?: Attachment;
48
- channel?: AllChannels;
47
+ channel?: CommandOptionChannel;
49
48
  role?: GuildRoleStructure;
50
49
  focused?: boolean;
51
50
  }
52
- export type OptionResolvedWithValue = MakeRequired<Pick<OptionResolved, 'name' | 'value' | 'focused'>, 'value'> & {
51
+ export type OptionResolvedWithValue = MakePresent<Pick<OptionResolved, 'name' | 'value' | 'focused'>, 'value'> & {
53
52
  type: ApplicationCommandOptionType.Boolean | ApplicationCommandOptionType.Integer | ApplicationCommandOptionType.Number | ApplicationCommandOptionType.String;
54
53
  };
55
54
  export type OptionResolvedWithProp = Exclude<OptionResolved, {
@@ -31,6 +31,10 @@ export declare class SeyfertError extends Error {
31
31
  * Optional contextual data attached to the error.
32
32
  */
33
33
  metadata?: Record<string, unknown>;
34
+ static is(error: unknown): error is SeyfertError;
35
+ static is<C extends SeyfertErrorCode>(error: unknown, code: C): error is SeyfertError & {
36
+ code: C;
37
+ };
34
38
  /**
35
39
  * Creates a SeyfertError instance.
36
40
  *
@@ -72,6 +76,15 @@ export declare const SeyfertErrorMessages: {
72
76
  INVALID_OPTIONS_LENGTH: string;
73
77
  MISSING_COMPONENT: string;
74
78
  MISSING_ACCESSORY: string;
79
+ MISSING_MEDIA: string;
80
+ MISSING_MODAL_CUSTOM_ID: string;
81
+ MISSING_MODAL_TITLE: string;
82
+ MISSING_POLL_QUESTION: string;
83
+ MISSING_POLL_ANSWERS: string;
84
+ MISSING_RADIO_GROUP_OPTION_LABEL: string;
85
+ MISSING_RADIO_GROUP_OPTION_VALUE: string;
86
+ MISSING_STRING_SELECT_OPTION_LABEL: string;
87
+ MISSING_STRING_SELECT_OPTION_VALUE: string;
75
88
  INVALID_ATTACHMENT_TYPE: string;
76
89
  INVALID_ANSWER_ID: string;
77
90
  UNDEFINED_LOCALE: string;