seyfert 4.5.0 → 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 (175) hide show
  1. package/lib/api/Routes/guilds.d.ts +12 -1
  2. package/lib/api/Routes/index.d.ts +3 -1
  3. package/lib/api/Routes/invites.d.ts +1 -1
  4. package/lib/api/Routes/oauth2.d.ts +11 -0
  5. package/lib/api/Routes/oauth2.js +2 -0
  6. package/lib/api/Routes/skus.d.ts +11 -4
  7. package/lib/api/Routes/users.d.ts +2 -1
  8. package/lib/api/Routes/voice.d.ts +4 -0
  9. package/lib/api/Routes/webhooks.d.ts +1 -1
  10. package/lib/api/api.d.ts +15 -5
  11. package/lib/api/api.js +243 -114
  12. package/lib/api/bucket.js +13 -7
  13. package/lib/api/shared.d.ts +3 -1
  14. package/lib/api/utils/constants.d.ts +1 -1
  15. package/lib/api/utils/constants.js +1 -1
  16. package/lib/builders/Attachment.d.ts +6 -1
  17. package/lib/builders/Attachment.js +13 -9
  18. package/lib/builders/CheckboxGroup.js +1 -1
  19. package/lib/builders/FileUpload.d.ts +8 -1
  20. package/lib/builders/FileUpload.js +9 -0
  21. package/lib/builders/RadioGroup.js +1 -1
  22. package/lib/client/base.d.ts +3 -3
  23. package/lib/client/collectors.d.ts +10 -8
  24. package/lib/client/transformers.d.ts +5 -0
  25. package/lib/client/workerclient.d.ts +8 -1
  26. package/lib/client/workerclient.js +28 -9
  27. package/lib/commands/applications/chat.d.ts +6 -4
  28. package/lib/commands/applications/options.d.ts +6 -4
  29. package/lib/commands/applications/shared.d.ts +2 -2
  30. package/lib/commands/handle.d.ts +7 -3
  31. package/lib/commands/handle.js +36 -11
  32. package/lib/commands/handler.js +11 -0
  33. package/lib/commands/optionresolver.d.ts +6 -7
  34. package/lib/common/it/error.d.ts +13 -0
  35. package/lib/common/it/error.js +15 -1
  36. package/lib/common/it/logger.js +12 -9
  37. package/lib/common/shorters/application.d.ts +1 -1
  38. package/lib/common/shorters/application.js +1 -1
  39. package/lib/common/shorters/bans.js +1 -1
  40. package/lib/common/shorters/guilds.js +5 -1
  41. package/lib/common/shorters/interaction.js +7 -4
  42. package/lib/common/shorters/invites.d.ts +5 -0
  43. package/lib/common/shorters/members.js +2 -1
  44. package/lib/common/shorters/messages.js +2 -2
  45. package/lib/common/shorters/threads.js +1 -1
  46. package/lib/common/shorters/webhook.js +3 -3
  47. package/lib/common/types/util.d.ts +7 -0
  48. package/lib/components/componentcommand.js +2 -2
  49. package/lib/components/customId.d.ts +3 -0
  50. package/lib/components/customId.js +11 -0
  51. package/lib/components/handler.js +2 -3
  52. package/lib/components/modalcommand.js +2 -2
  53. package/lib/events/hooks/invite.d.ts +1 -0
  54. package/lib/events/hooks/presence.d.ts +1 -0
  55. package/lib/events/hooks/thread.d.ts +1 -0
  56. package/lib/structures/AnonymousGuild.d.ts +1 -1
  57. package/lib/structures/AnonymousGuild.js +1 -1
  58. package/lib/structures/Guild.d.ts +3 -0
  59. package/lib/structures/GuildMember.d.ts +2 -2
  60. package/lib/structures/GuildMember.js +22 -4
  61. package/lib/structures/GuildPreview.d.ts +1 -1
  62. package/lib/structures/GuildPreview.js +1 -1
  63. package/lib/structures/GuildRole.d.ts +13 -0
  64. package/lib/structures/GuildRole.js +21 -0
  65. package/lib/structures/GuildTemplate.js +1 -1
  66. package/lib/structures/Interaction.d.ts +7 -7
  67. package/lib/structures/Interaction.js +35 -21
  68. package/lib/structures/Message.d.ts +2 -1
  69. package/lib/structures/channels.d.ts +29 -16
  70. package/lib/structures/channels.js +59 -19
  71. package/lib/structures/extra/BaseGuild.d.ts +4 -4
  72. package/lib/structures/extra/BaseGuild.js +4 -4
  73. package/lib/types/gateway.d.ts +243 -239
  74. package/lib/types/index.d.ts +2 -2
  75. package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/attachment.d.ts +5 -2
  76. package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/shared.d.ts +2 -2
  77. package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/shared.js +1 -1
  78. package/lib/types/payloads/_interactions/_applicationCommands/chatInput.d.ts +7 -7
  79. package/lib/types/payloads/_interactions/_applicationCommands/contextMenu.d.ts +13 -13
  80. package/lib/types/payloads/_interactions/_applicationCommands/permissions.d.ts +4 -4
  81. package/lib/types/payloads/_interactions/_applicationCommands/permissions.js +2 -2
  82. package/lib/types/payloads/_interactions/applicationCommands.d.ts +10 -10
  83. package/lib/types/payloads/_interactions/applicationCommands.js +4 -4
  84. package/lib/types/payloads/_interactions/autocomplete.d.ts +2 -2
  85. package/lib/types/payloads/_interactions/base.d.ts +13 -7
  86. package/lib/types/payloads/_interactions/modalSubmit.d.ts +4 -4
  87. package/lib/types/payloads/_interactions/responses.d.ts +10 -10
  88. package/lib/types/payloads/_interactions/responses.js +2 -2
  89. package/lib/types/payloads/application.d.ts +21 -15
  90. package/lib/types/payloads/application.js +7 -7
  91. package/lib/types/payloads/auditLog.d.ts +22 -17
  92. package/lib/types/payloads/auditLog.js +7 -2
  93. package/lib/types/payloads/autoModeration.d.ts +11 -11
  94. package/lib/types/payloads/autoModeration.js +5 -5
  95. package/lib/types/payloads/channel.d.ts +87 -78
  96. package/lib/types/payloads/channel.js +16 -11
  97. package/lib/types/payloads/components.d.ts +41 -31
  98. package/lib/types/payloads/components.js +9 -5
  99. package/lib/types/payloads/emoji.d.ts +2 -2
  100. package/lib/types/payloads/emoji.js +1 -1
  101. package/lib/types/payloads/gateway.d.ts +33 -29
  102. package/lib/types/payloads/gateway.js +5 -5
  103. package/lib/types/payloads/guild.d.ts +68 -68
  104. package/lib/types/payloads/guild.js +14 -14
  105. package/lib/types/payloads/guildScheduledEvent.d.ts +11 -11
  106. package/lib/types/payloads/guildScheduledEvent.js +3 -3
  107. package/lib/types/payloads/index.d.ts +2 -2
  108. package/lib/types/payloads/interactions.d.ts +3 -3
  109. package/lib/types/payloads/invite.d.ts +11 -11
  110. package/lib/types/payloads/invite.js +3 -3
  111. package/lib/types/payloads/monetization.d.ts +4 -4
  112. package/lib/types/payloads/monetization.js +2 -2
  113. package/lib/types/payloads/oauth2.d.ts +21 -17
  114. package/lib/types/payloads/oauth2.js +21 -17
  115. package/lib/types/payloads/permissions.d.ts +5 -5
  116. package/lib/types/payloads/permissions.js +2 -2
  117. package/lib/types/payloads/poll.d.ts +7 -7
  118. package/lib/types/payloads/poll.js +2 -2
  119. package/lib/types/payloads/soundboard.d.ts +2 -2
  120. package/lib/types/payloads/soundboard.js +1 -1
  121. package/lib/types/payloads/stageInstance.d.ts +5 -5
  122. package/lib/types/payloads/stageInstance.js +1 -1
  123. package/lib/types/payloads/sticker.d.ts +8 -8
  124. package/lib/types/payloads/sticker.js +3 -3
  125. package/lib/types/payloads/teams.d.ts +8 -8
  126. package/lib/types/payloads/teams.js +3 -3
  127. package/lib/types/payloads/template.d.ts +3 -3
  128. package/lib/types/payloads/template.js +1 -1
  129. package/lib/types/payloads/user.d.ts +24 -22
  130. package/lib/types/payloads/user.js +7 -5
  131. package/lib/types/payloads/voice.d.ts +4 -4
  132. package/lib/types/payloads/voice.js +1 -1
  133. package/lib/types/payloads/webhokEvents.d.ts +5 -5
  134. package/lib/types/payloads/webhokEvents.js +2 -2
  135. package/lib/types/payloads/webhook.d.ts +4 -4
  136. package/lib/types/payloads/webhook.js +1 -1
  137. package/lib/types/rest/application.d.ts +14 -14
  138. package/lib/types/rest/auditLog.d.ts +1 -1
  139. package/lib/types/rest/autoModeration.d.ts +7 -7
  140. package/lib/types/rest/channel.d.ts +79 -74
  141. package/lib/types/rest/channel.js +1 -1
  142. package/lib/types/rest/emoji.d.ts +8 -8
  143. package/lib/types/rest/gateway.d.ts +2 -2
  144. package/lib/types/rest/guild.d.ts +98 -98
  145. package/lib/types/rest/guild.js +5 -5
  146. package/lib/types/rest/guildScheduledEvent.d.ts +11 -11
  147. package/lib/types/rest/index.d.ts +34 -3
  148. package/lib/types/rest/index.js +33 -2
  149. package/lib/types/rest/interactions.d.ts +48 -48
  150. package/lib/types/rest/invite.d.ts +5 -5
  151. package/lib/types/rest/monetization.d.ts +9 -9
  152. package/lib/types/rest/monetization.js +1 -1
  153. package/lib/types/rest/oauth2.d.ts +22 -18
  154. package/lib/types/rest/poll.d.ts +4 -4
  155. package/lib/types/rest/soundboard.d.ts +8 -8
  156. package/lib/types/rest/stageInstance.d.ts +6 -6
  157. package/lib/types/rest/sticker.d.ts +10 -10
  158. package/lib/types/rest/template.d.ts +11 -11
  159. package/lib/types/rest/user.d.ts +18 -14
  160. package/lib/types/rest/voice.d.ts +5 -5
  161. package/lib/types/rest/webhook.d.ts +38 -38
  162. package/lib/types/utils/index.d.ts +19 -19
  163. package/lib/types/utils/index.js +19 -19
  164. package/lib/websocket/SharedTypes.d.ts +2 -2
  165. package/lib/websocket/constants/index.js +2 -2
  166. package/lib/websocket/discord/heartbeater.d.ts +1 -0
  167. package/lib/websocket/discord/heartbeater.js +8 -0
  168. package/lib/websocket/discord/shard.d.ts +19 -10
  169. package/lib/websocket/discord/shard.js +254 -121
  170. package/lib/websocket/discord/sharder.d.ts +2 -2
  171. package/lib/websocket/discord/sharder.js +1 -1
  172. package/lib/websocket/discord/shared.d.ts +7 -2
  173. package/lib/websocket/discord/workermanager.d.ts +3 -1
  174. package/lib/websocket/discord/workermanager.js +31 -24
  175. package/package.json +2 -2
@@ -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,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>;
@@ -156,14 +156,12 @@ class WorkerClient extends base_1.BaseClient {
156
156
  break;
157
157
  case 'SEND_PAYLOAD':
158
158
  {
159
- const shard = this.shards.get(data.shardId);
160
- if (!shard) {
161
- 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})`);
162
163
  return;
163
164
  }
164
- await shard.send(true, {
165
- ...data,
166
- });
167
165
  this.postMessage({
168
166
  type: 'RESULT_PAYLOAD',
169
167
  nonce: data.nonce,
@@ -289,7 +287,7 @@ class WorkerClient extends base_1.BaseClient {
289
287
  this.rest.workerPromises.delete(data.nonce);
290
288
  if (data.error)
291
289
  return promise.reject(data.error);
292
- promise.resolve(data.response);
290
+ promise.resolve(data.responseType === 'arrayBuffer' ? Uint8Array.from(data.response).buffer : data.response);
293
291
  }
294
292
  break;
295
293
  case 'EXECUTE_EVAL':
@@ -362,17 +360,38 @@ class WorkerClient extends base_1.BaseClient {
362
360
  calculateShardId(guildId) {
363
361
  return (0, common_1.calculateShardId)(guildId, this.workerData.totalShards);
364
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
+ }
365
382
  generateNonce() {
366
383
  const uuid = (0, node_crypto_1.randomUUID)();
367
384
  if (this.promises.has(uuid))
368
385
  return this.generateNonce();
369
386
  return uuid;
370
387
  }
371
- generateSendPromise(nonce, message = 'Timeout') {
388
+ generateSendPromise(nonce, operation = 'Worker request') {
372
389
  return new Promise((res, rej) => {
373
390
  const timeout = setTimeout(() => {
374
391
  this.promises.delete(nonce);
375
- 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
+ }));
376
395
  }, 60e3);
377
396
  this.promises.set(nonce, { resolve: res, timeout });
378
397
  });
@@ -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;
@@ -35,6 +35,9 @@ class SeyfertError extends Error {
35
35
  * Optional contextual data attached to the error.
36
36
  */
37
37
  metadata;
38
+ static is(error, code) {
39
+ return error instanceof SeyfertError && (code === undefined || error.code === code);
40
+ }
38
41
  /**
39
42
  * Creates a SeyfertError instance.
40
43
  *
@@ -85,6 +88,15 @@ exports.SeyfertErrorMessages = {
85
88
  INVALID_OPTIONS_LENGTH: 'Invalid options length.',
86
89
  MISSING_COMPONENT: 'Cannot convert to JSON without a component.',
87
90
  MISSING_ACCESSORY: 'Cannot convert to JSON without an accessory.',
91
+ MISSING_MEDIA: 'Cannot convert to JSON without media.',
92
+ MISSING_MODAL_CUSTOM_ID: 'Cannot convert to JSON without a custom_id.',
93
+ MISSING_MODAL_TITLE: 'Cannot convert to JSON without a title.',
94
+ MISSING_POLL_QUESTION: 'Cannot convert to JSON without a question.',
95
+ MISSING_POLL_ANSWERS: 'Cannot convert to JSON without answers.',
96
+ MISSING_RADIO_GROUP_OPTION_LABEL: 'Cannot convert to JSON without a label.',
97
+ MISSING_RADIO_GROUP_OPTION_VALUE: 'Cannot convert to JSON without a value.',
98
+ MISSING_STRING_SELECT_OPTION_LABEL: 'Cannot convert to JSON without a label.',
99
+ MISSING_STRING_SELECT_OPTION_VALUE: 'Cannot convert to JSON without a value.',
88
100
  INVALID_ATTACHMENT_TYPE: 'Invalid attachment type.',
89
101
  INVALID_ANSWER_ID: 'Invalid answer id.',
90
102
  UNDEFINED_LOCALE: 'Undefined locale.',
@@ -127,7 +139,9 @@ exports.SeyfertErrorMessages = {
127
139
  GUILD_SEARCH_INDEX_NOT_READY: 'Guild search index is not yet available.',
128
140
  };
129
141
  function resolveSeyfertErrorMessage(code) {
130
- const preset = exports.SeyfertErrorMessages[code];
142
+ const preset = Object.hasOwn(exports.SeyfertErrorMessages, code)
143
+ ? exports.SeyfertErrorMessages[code]
144
+ : undefined;
131
145
  if (preset)
132
146
  return preset;
133
147
  return code
@@ -72,15 +72,18 @@ class Logger {
72
72
  Logger.__assignFileName = cb;
73
73
  }
74
74
  static async clearLogs() {
75
- for (const i of await node_fs_1.promises.readdir((0, node_path_1.join)(process.cwd(), Logger.dirname), { withFileTypes: true })) {
76
- if (Logger.streams[i.name])
77
- await new Promise((res, rej) => Logger.streams[i.name].close(err => {
78
- if (err)
79
- return rej(err);
80
- res(err);
81
- }));
82
- await node_fs_1.promises.unlink((0, node_path_1.join)(process.cwd(), Logger.dirname, i.name)).catch(() => undefined);
83
- delete Logger.streams[i.name];
75
+ for (const [fileName, stream] of Object.entries(Logger.streams)) {
76
+ if (!stream)
77
+ continue;
78
+ await new Promise((resolve, reject) => stream.close(error => {
79
+ if (error)
80
+ return reject(error);
81
+ resolve();
82
+ }));
83
+ delete Logger.streams[fileName];
84
+ }
85
+ for (const entry of await node_fs_1.promises.readdir((0, node_path_1.join)(process.cwd(), Logger.dirname), { withFileTypes: true })) {
86
+ await node_fs_1.promises.unlink((0, node_path_1.join)(process.cwd(), Logger.dirname, entry.name)).catch(() => undefined);
84
87
  }
85
88
  }
86
89
  /**
@@ -17,7 +17,7 @@ export declare class ApplicationShorter extends BaseShorter {
17
17
  /**
18
18
  * Creates a new emoji for the application.
19
19
  * @param body.name The name of the emoji.
20
- * @param body.image The [image data string](https://discord.com/developers/docs/reference#image-data) of the emoji.
20
+ * @param body.image The [image data string](https://docs.discord.com/developers/reference#image-data) of the emoji.
21
21
  * @returns The created emoji.
22
22
  */
23
23
  createEmoji(raw: ApplicationEmojiResolvable): Promise<ApplicationEmojiStructure>;
@@ -37,7 +37,7 @@ class ApplicationShorter extends base_1.BaseShorter {
37
37
  /**
38
38
  * Creates a new emoji for the application.
39
39
  * @param body.name The name of the emoji.
40
- * @param body.image The [image data string](https://discord.com/developers/docs/reference#image-data) of the emoji.
40
+ * @param body.image The [image data string](https://docs.discord.com/developers/reference#image-data) of the emoji.
41
41
  * @returns The created emoji.
42
42
  */
43
43
  async createEmoji(raw) {
@@ -12,7 +12,7 @@ class BanShorter extends base_1.BaseShorter {
12
12
  * @param reason The reason for bulk banning members.
13
13
  */
14
14
  async bulkCreate(guildId, body, reason) {
15
- const bans = await this.client.proxy.guilds(guildId)['bulk-bans'].post({ reason, body });
15
+ const bans = await this.client.proxy.guilds(guildId)['bulk-ban'].post({ reason, body });
16
16
  await Promise.all(bans.banned_users.map(id => this.client.cache.members?.removeIfNI('GuildModeration', id, guildId)));
17
17
  return bans;
18
18
  }