lunibee 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/dist/builders/attachment.d.ts +5 -1
- package/dist/builders/commands.d.ts +131 -45
- package/dist/builders/components.d.ts +183 -41
- package/dist/builders/embed.d.ts +12 -8
- package/dist/builders/index.d.ts +9 -4
- package/dist/builders/index.js +234 -110
- package/dist/builders/index.js.map +8 -8
- package/dist/core/events.d.ts +28 -12
- package/dist/core/index.d.ts +5 -3
- package/dist/core/index.js +414 -78
- package/dist/core/index.js.map +18 -18
- package/dist/core/permissions.d.ts +6 -2
- package/dist/index.d.ts +5 -4
- package/dist/index.js +869 -194
- package/dist/index.js.map +25 -24
- package/dist/managers/guild-resources.d.ts +22 -2
- package/dist/managers/guild.d.ts +3 -1
- package/dist/managers/index.d.ts +7 -3
- package/dist/managers/index.js +167 -33
- package/dist/managers/index.js.map +13 -13
- package/dist/managers/member.d.ts +13 -12
- package/dist/managers/message.d.ts +16 -4
- package/dist/rest/index.js +2 -2
- package/dist/rest/index.js.map +1 -1
- package/dist/sharding/index.js +3 -2
- package/dist/sharding/index.js.map +4 -4
- package/dist/structures/base.d.ts +36 -0
- package/dist/structures/index.d.ts +38 -3
- package/dist/structures/index.js +240 -34
- package/dist/structures/index.js.map +11 -11
- package/dist/structures/interactions.d.ts +110 -12
- package/dist/structures/options.d.ts +2 -0
- package/dist/structures/resources.d.ts +40 -4
- package/dist/types/gateway.d.ts +14 -0
- package/dist/types/index.d.ts +185 -10
- package/dist/types/index.js +37 -10
- package/dist/types/index.js.map +4 -4
- package/dist/utils/args.d.ts +79 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +190 -2
- package/dist/utils/index.js.map +5 -4
- package/dist/ws/index.js +2 -1
- package/dist/ws/index.js.map +4 -4
- package/package.json +14 -14
package/dist/types/index.js
CHANGED
|
@@ -126,7 +126,7 @@ var MessageFlags = {
|
|
|
126
126
|
Loading: 128,
|
|
127
127
|
IsComponentsV2: 32768
|
|
128
128
|
};
|
|
129
|
-
var
|
|
129
|
+
var ChannelEnum = {
|
|
130
130
|
GuildText: 0,
|
|
131
131
|
DM: 1,
|
|
132
132
|
GuildVoice: 2,
|
|
@@ -141,7 +141,7 @@ var ChannelType = {
|
|
|
141
141
|
GuildForum: 15,
|
|
142
142
|
GuildMedia: 16
|
|
143
143
|
};
|
|
144
|
-
var
|
|
144
|
+
var ComponentEnum = {
|
|
145
145
|
ActionRow: 1,
|
|
146
146
|
Button: 2,
|
|
147
147
|
StringSelect: 3,
|
|
@@ -159,7 +159,7 @@ var ComponentType = {
|
|
|
159
159
|
ContentInventoryEntry: 16,
|
|
160
160
|
Container: 17
|
|
161
161
|
};
|
|
162
|
-
var
|
|
162
|
+
var ButtonType = {
|
|
163
163
|
Primary: 1,
|
|
164
164
|
Secondary: 2,
|
|
165
165
|
Success: 3,
|
|
@@ -167,11 +167,11 @@ var ButtonStyle = {
|
|
|
167
167
|
Link: 5,
|
|
168
168
|
Premium: 6
|
|
169
169
|
};
|
|
170
|
-
var
|
|
170
|
+
var TextInputType = {
|
|
171
171
|
Short: 1,
|
|
172
172
|
Paragraph: 2
|
|
173
173
|
};
|
|
174
|
-
var
|
|
174
|
+
var InteractionResponseEnum = {
|
|
175
175
|
Pong: 1,
|
|
176
176
|
ChannelMessage: 4,
|
|
177
177
|
DeferredChannelMessage: 5,
|
|
@@ -180,13 +180,13 @@ var InteractionResponseType = {
|
|
|
180
180
|
Autocomplete: 8,
|
|
181
181
|
Modal: 9
|
|
182
182
|
};
|
|
183
|
-
var
|
|
183
|
+
var StickerFormatEnum = {
|
|
184
184
|
PNG: 1,
|
|
185
185
|
APNG: 2,
|
|
186
186
|
Lottie: 3,
|
|
187
187
|
GIF: 4
|
|
188
188
|
};
|
|
189
|
-
var
|
|
189
|
+
var StickerEnum = {
|
|
190
190
|
Standard: 1,
|
|
191
191
|
Guild: 2
|
|
192
192
|
};
|
|
@@ -203,7 +203,15 @@ var PremiumTier = {
|
|
|
203
203
|
Tier2: 2,
|
|
204
204
|
Tier3: 3
|
|
205
205
|
};
|
|
206
|
-
var
|
|
206
|
+
var ActivityEnum = {
|
|
207
|
+
Playing: 0,
|
|
208
|
+
Streaming: 1,
|
|
209
|
+
Listening: 2,
|
|
210
|
+
Watching: 3,
|
|
211
|
+
Custom: 4,
|
|
212
|
+
Competing: 5
|
|
213
|
+
};
|
|
214
|
+
var ApplicationCommandOptionEnum = {
|
|
207
215
|
SubCommand: 1,
|
|
208
216
|
SubCommandGroup: 2,
|
|
209
217
|
String: 3,
|
|
@@ -216,29 +224,48 @@ var ApplicationCommandOptionType = {
|
|
|
216
224
|
Number: 10,
|
|
217
225
|
Attachment: 11
|
|
218
226
|
};
|
|
219
|
-
var
|
|
227
|
+
var ApplicationCommandEnum = {
|
|
220
228
|
ChatInput: 1,
|
|
221
229
|
User: 2,
|
|
222
230
|
Message: 3
|
|
223
231
|
};
|
|
232
|
+
var ButtonStyle = ButtonType;
|
|
233
|
+
var TextInputStyle = TextInputType;
|
|
234
|
+
var ChannelType = ChannelEnum;
|
|
235
|
+
var ComponentType = ComponentEnum;
|
|
236
|
+
var InteractionResponseType = InteractionResponseEnum;
|
|
237
|
+
var ApplicationCommandType = ApplicationCommandEnum;
|
|
238
|
+
var ApplicationCommandOptionType = ApplicationCommandOptionEnum;
|
|
239
|
+
var StickerType = StickerEnum;
|
|
240
|
+
var StickerFormatType = StickerFormatEnum;
|
|
224
241
|
export {
|
|
242
|
+
ActivityEnum,
|
|
243
|
+
ApplicationCommandEnum,
|
|
244
|
+
ApplicationCommandOptionEnum,
|
|
225
245
|
ApplicationCommandOptionType,
|
|
226
246
|
ApplicationCommandType,
|
|
227
247
|
ButtonStyle,
|
|
248
|
+
ButtonType,
|
|
249
|
+
ChannelEnum,
|
|
228
250
|
ChannelType,
|
|
251
|
+
ComponentEnum,
|
|
229
252
|
ComponentType,
|
|
230
253
|
GatewayIntentBits,
|
|
231
254
|
IntentBits,
|
|
232
255
|
Intents,
|
|
233
256
|
IntentsBitField,
|
|
257
|
+
InteractionResponseEnum,
|
|
234
258
|
InteractionResponseType,
|
|
235
259
|
MessageFlags,
|
|
236
260
|
PremiumTier,
|
|
261
|
+
StickerEnum,
|
|
262
|
+
StickerFormatEnum,
|
|
237
263
|
StickerFormatType,
|
|
238
264
|
StickerType,
|
|
239
265
|
TextInputStyle,
|
|
266
|
+
TextInputType,
|
|
240
267
|
VerificationLevel,
|
|
241
268
|
resolveGatewayIntents
|
|
242
269
|
};
|
|
243
270
|
|
|
244
|
-
//# debugId=
|
|
271
|
+
//# debugId=40CBDDAEDFA8DAF664756E2164756E21
|
package/dist/types/index.js.map
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../packages/types/src/gateway.ts", "../../packages/types/src/index.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"// ─── Gateway Intents ─────────────────────────────────────────────────────────\n\n/** Gateway intent bit flags supported by Discord (PascalCase). */\nexport const GatewayIntentBits = {\n Guilds: 1 << 0,\n GuildMembers: 1 << 1,\n GuildModeration: 1 << 2,\n GuildExpressions: 1 << 3,\n GuildIntegrations: 1 << 4,\n GuildWebhooks: 1 << 5,\n GuildInvites: 1 << 6,\n GuildVoiceStates: 1 << 7,\n GuildPresences: 1 << 8,\n GuildMessages: 1 << 9,\n GuildMessageReactions: 1 << 10,\n GuildMessageTyping: 1 << 11,\n DirectMessages: 1 << 12,\n DirectMessageReactions: 1 << 13,\n DirectMessageTyping: 1 << 14,\n MessageContent: 1 << 15,\n GuildScheduledEvents: 1 << 16,\n AutoModerationConfiguration: 1 << 20,\n AutoModerationExecution: 1 << 21,\n GuildMessagePolls: 1 << 24,\n DirectMessagePolls: 1 << 25,\n} as const;\n\n/** Idiomatic camelCase Gateway intent bit flags supported by Discord. */\nexport const IntentBits = {\n guild: 1 << 0,\n guilds: 1 << 0,\n guildMembers: 1 << 1,\n guildModeration: 1 << 2,\n guildBans: 1 << 2,\n guildExpressions: 1 << 3,\n guildEmojis: 1 << 3,\n guildEmojisAndStickers: 1 << 3,\n guildIntegrations: 1 << 4,\n guildWebhooks: 1 << 5,\n guildInvites: 1 << 6,\n guildVoiceStates: 1 << 7,\n guildPresences: 1 << 8,\n guildMessages: 1 << 9,\n guildMessage: 1 << 9,\n guildMessageReactions: 1 << 10,\n guildMessageTyping: 1 << 11,\n directMessages: 1 << 12,\n directMessageReactions: 1 << 13,\n directMessageTyping: 1 << 14,\n messageContent: 1 << 15,\n guildScheduledEvents: 1 << 16,\n autoModerationConfiguration: 1 << 20,\n autoModerationExecution: 1 << 21,\n guildMessagePolls: 1 << 24,\n directMessagePolls: 1 << 25,\n} as const;\n\n/** Alias for IntentBits. */\nexport const Intents = IntentBits;\n\n/** Gateway intent resolvable value (single bitfield, enum key, or array of bitfields/strings). */\nexport type GatewayIntentResolvable =\n | number\n | keyof typeof GatewayIntentBits\n | keyof typeof IntentBits\n | (\n | number\n | keyof typeof GatewayIntentBits\n | keyof typeof IntentBits\n | string\n )[]\n | { readonly bitfield: number };\n\n/** Resolves any GatewayIntentResolvable into a raw bitfield integer. */\nexport function resolveGatewayIntents(\n intents: GatewayIntentResolvable,\n): number {\n if (typeof intents === \"number\") return intents;\n if (intents && typeof intents === \"object\" && !Array.isArray(intents))\n return intents.bitfield;\n if (Array.isArray(intents)) {\n return intents.reduce<number>((acc, intent) => {\n return acc | resolveGatewayIntents(intent as any);\n }, 0);\n }\n if (typeof intents === \"string\") {\n if (intents in GatewayIntentBits)\n return (GatewayIntentBits as Record<string, number>)[intents]!;\n if (intents in IntentBits)\n return (IntentBits as Record<string, number>)[intents]!;\n const lower = intents.charAt(0).toLowerCase() + intents.slice(1);\n if (lower in IntentBits)\n return (IntentBits as Record<string, number>)[lower]!;\n const num = Number(intents);\n if (!Number.isNaN(num)) return num;\n }\n return 0;\n}\n\n/**\n * Discord.js-familiar intent bitfield.\n * @example new IntentsBitField([IntentsBitField.Flags.Guilds, \"GuildMessages\"])\n */\nexport class IntentsBitField {\n /** Intent flag values by name. */\n public static readonly Flags = GatewayIntentBits;\n /** Raw intent bitfield. */\n public bitfield: number;\n\n public constructor(bits: GatewayIntentResolvable = 0) {\n this.bitfield = resolveGatewayIntents(bits);\n }\n\n /** Whether every given intent is set. */\n public has(bits: GatewayIntentResolvable): boolean {\n const resolved = resolveGatewayIntents(bits);\n return (this.bitfield & resolved) === resolved;\n }\n\n /** Whether any given intent is set. */\n public any(bits: GatewayIntentResolvable): boolean {\n return (this.bitfield & resolveGatewayIntents(bits)) !== 0;\n }\n\n /** Adds intents in place. @returns This bitfield. */\n public add(...bits: GatewayIntentResolvable[]): this {\n for (const bit of bits) this.bitfield |= resolveGatewayIntents(bit);\n return this;\n }\n\n /** Removes intents in place. @returns This bitfield. */\n public remove(...bits: GatewayIntentResolvable[]): this {\n for (const bit of bits) this.bitfield &= ~resolveGatewayIntents(bit);\n return this;\n }\n\n /** Names of the set intents. */\n public toArray(): (keyof typeof GatewayIntentBits)[] {\n return (\n Object.keys(GatewayIntentBits) as (keyof typeof GatewayIntentBits)[]\n ).filter((name) => this.has(GatewayIntentBits[name]));\n }\n\n /** Whether this equals another bitfield. */\n public equals(bits: GatewayIntentResolvable): boolean {\n return this.bitfield === resolveGatewayIntents(bits);\n }\n\n public valueOf(): number {\n return this.bitfield;\n }\n\n public toJSON(): number {\n return this.bitfield;\n }\n}\n\n// ─── Gateway Config ───────────────────────────────────────────────────────────\n\n/** Gateway connection properties (OS, browser, device). */\nexport interface GatewayProperties {\n os?: string;\n browser?: string;\n device?: string;\n [key: string]: unknown;\n}\n/** Gateway presence activity. */\nexport interface GatewayPresenceActivity {\n name: string;\n type?: number;\n url?: string;\n state?: string;\n}\n/** Gateway presence data. */\nexport interface GatewayPresence {\n status?: \"online\" | \"dnd\" | \"idle\" | \"invisible\" | \"offline\";\n activities?: GatewayPresenceActivity[];\n afk?: boolean;\n since?: number | null;\n}\n/** Client configuration. */\nexport interface ClientOptions {\n token: string;\n intents: GatewayIntentResolvable;\n gateway?: GatewayOptions;\n rest?: RESTOptions;\n /** Opt-in bounded per-channel message cache. Messages are not cached by default. */\n messageCache?: { maxSize?: number; ttl?: number };\n /**\n * Which resources the client keeps from Gateway events. Everything is\n * cached by default; large bots can turn off what they do not read.\n * Events are still emitted either way.\n */\n cache?: {\n users?: boolean;\n members?: boolean;\n roles?: boolean;\n emojis?: boolean;\n };\n}\n/** Gateway connection configuration. */\nexport interface GatewayOptions {\n intents?: GatewayIntentResolvable;\n reconnect?: boolean;\n maxReconnectAttempts?: number;\n reconnectBaseDelay?: number;\n reconnectMaxDelay?: number;\n shardId?: number;\n shardCount?: number;\n properties?: GatewayProperties;\n presence?: GatewayPresence;\n}\n\n/** REST request configuration. */\nexport interface RESTOptions {\n timeout?: number;\n retries?: number;\n baseURL?: string;\n}\n",
|
|
6
|
-
"/** Discord API snowflake identifier. */\nexport type Snowflake = string;\n\nexport * from \"./gateway.js\";\nexport * from \"./gateway-events.js\";\n\n// ─── Core Discord Objects ─────────────────────────────────────────────────────\n\n/** Discord user object. */\nexport interface UserData {\n id: Snowflake;\n username: string;\n discriminator?: string;\n global_name?: string | null;\n avatar?: string | null;\n bot?: boolean;\n system?: boolean;\n public_flags?: number;\n}\n/** Current authenticated bot user. */\nexport type ClientUser = UserData;\n/** Discord Gateway payload envelope. */\nexport interface GatewayPayload<T = unknown> {\n op: number;\n d: T | null;\n s: number | null;\n t: string | null;\n}\n/** Generic Discord API error payload. */\nexport interface APIError {\n code?: number;\n message?: string;\n errors?: Record<string, unknown>;\n}\n\n// ─── Discord Flags & Enums ────────────────────────────────────────────────────\n\n/** Discord message flags. */\nexport const MessageFlags = {\n Crossposted: 1,\n IsCrosspost: 2,\n SuppressEmbeds: 4,\n SourceMessageDeleted: 8,\n Urgent: 16,\n HasThread: 32,\n Ephemeral: 64,\n Loading: 128,\n IsComponentsV2: 32768,\n} as const;\n\n/** Discord channel types. */\nexport const ChannelType = {\n GuildText: 0,\n DM: 1,\n GuildVoice: 2,\n GroupDM: 3,\n GuildCategory: 4,\n GuildAnnouncement: 5,\n AnnouncementThread: 10,\n PublicThread: 11,\n PrivateThread: 12,\n GuildStageVoice: 13,\n GuildDirectory: 14,\n GuildForum: 15,\n GuildMedia: 16,\n} as const;\n\n/** Discord component types. */\nexport const ComponentType = {\n ActionRow: 1,\n Button: 2,\n StringSelect: 3,\n TextInput: 4,\n UserSelect: 5,\n RoleSelect: 6,\n MentionableSelect: 7,\n ChannelSelect: 8,\n Section: 9,\n TextDisplay: 10,\n Thumbnail: 11,\n MediaGallery: 12,\n File: 13,\n Separator: 14,\n ContentInventoryEntry: 16,\n Container: 17,\n} as const;\n\n/** Discord button style types. */\nexport const ButtonStyle = {\n Primary: 1,\n Secondary: 2,\n Success: 3,\n Danger: 4,\n Link: 5,\n Premium: 6,\n} as const;\n\n/** Discord text input style types. */\nexport const TextInputStyle = {\n Short: 1,\n Paragraph: 2,\n} as const;\n\n/** Discord interaction response types. */\nexport const InteractionResponseType = {\n Pong: 1,\n ChannelMessage: 4,\n DeferredChannelMessage: 5,\n DeferredMessageUpdate: 6,\n MessageUpdate: 7,\n Autocomplete: 8,\n Modal: 9,\n} as const;\n\n/** Discord sticker format types. */\nexport const StickerFormatType = {\n PNG: 1,\n APNG: 2,\n Lottie: 3,\n GIF: 4,\n} as const;\n\n/** Discord sticker types. */\nexport const StickerType = {\n Standard: 1,\n Guild: 2,\n} as const;\n\n/** Discord verification levels. */\nexport const VerificationLevel = {\n None: 0,\n Low: 1,\n Medium: 2,\n High: 3,\n VeryHigh: 4,\n} as const;\n\n/** Discord premium tiers. */\nexport const PremiumTier = {\n None: 0,\n Tier1: 1,\n Tier2: 2,\n Tier3: 3,\n} as const;\n\n// ─── Embeds ───────────────────────────────────────────────────────────────────\n\n/** Raw Discord embed footer object. */\nexport interface APIEmbedFooter {\n text: string;\n icon_url?: string;\n proxy_icon_url?: string;\n}\n/** Raw Discord embed image/thumbnail/video object. */\nexport interface APIEmbedMedia {\n url: string;\n proxy_url?: string;\n height?: number;\n width?: number;\n}\n/** Raw Discord embed provider object. */\nexport interface APIEmbedProvider {\n name?: string;\n url?: string;\n}\n/** Raw Discord embed author object. */\nexport interface APIEmbedAuthor {\n name: string;\n url?: string;\n icon_url?: string;\n proxy_icon_url?: string;\n}\n/** Raw Discord embed field object. */\nexport interface APIEmbedField {\n name: string;\n value: string;\n inline?: boolean;\n}\n/** Raw Discord embed object. */\nexport interface APIEmbed {\n title?: string;\n type?: string;\n description?: string;\n url?: string;\n timestamp?: string;\n color?: number;\n footer?: APIEmbedFooter;\n image?: APIEmbedMedia;\n thumbnail?: APIEmbedMedia;\n video?: APIEmbedMedia;\n provider?: APIEmbedProvider;\n author?: APIEmbedAuthor;\n fields?: APIEmbedField[];\n}\n\n// ─── Message Components ───────────────────────────────────────────────────────\n\n/** Raw Discord select menu option. */\nexport interface APISelectMenuOption {\n label: string;\n value: string;\n description?: string;\n emoji?: APIPartialEmoji;\n default?: boolean;\n}\n/** Raw Discord emoji (partial, as used in components). */\nexport interface APIPartialEmoji {\n id?: Snowflake | null;\n name?: string | null;\n animated?: boolean;\n}\n/** Raw Discord button component. */\nexport interface APIButtonComponent {\n type: 2;\n style: number;\n label?: string;\n emoji?: APIPartialEmoji;\n custom_id?: string;\n url?: string;\n sku_id?: string;\n disabled?: boolean;\n}\n/** Raw Discord select menu component. */\nexport interface APISelectMenuComponent {\n type: 3 | 5 | 6 | 7 | 8;\n custom_id: string;\n options?: APISelectMenuOption[];\n channel_types?: number[];\n placeholder?: string;\n min_values?: number;\n max_values?: number;\n disabled?: boolean;\n}\n/** Raw Discord text input component. */\nexport interface APITextInputComponent {\n type: 4;\n custom_id: string;\n style: number;\n label: string;\n min_length?: number;\n max_length?: number;\n required?: boolean;\n value?: string;\n placeholder?: string;\n}\n/** Union of all raw message component types. */\nexport type APIMessageActionRowComponent =\n APIButtonComponent | APISelectMenuComponent | APITextInputComponent;\n/** Raw Discord action row component. */\nexport interface APIActionRowComponent {\n type: 1;\n id?: number;\n components: APIMessageActionRowComponent[];\n}\n/** Union including action rows and V2 components. */\nexport type APIMessageComponent =\n APIActionRowComponent | { type: Exclude<number, 1>; [key: string]: any };\n\n// ─── Attachments ─────────────────────────────────────────────────────────────\n\n/** Raw Discord attachment object. */\nexport interface APIAttachment {\n id: Snowflake;\n filename: string;\n description?: string | null;\n content_type?: string;\n size: number;\n url: string;\n proxy_url: string;\n height?: number | null;\n width?: number | null;\n ephemeral?: boolean;\n duration_secs?: number;\n waveform?: string;\n flags?: number;\n}\n\n// ─── Stickers ────────────────────────────────────────────────────────────────\n\n/** Compact sticker item as included in messages. */\nexport interface APIStickerItem {\n id: Snowflake;\n name: string;\n format_type: number;\n}\n/** Full Discord sticker object. */\nexport interface APISticker {\n id: Snowflake;\n pack_id?: Snowflake;\n name: string;\n description?: string | null;\n tags?: string;\n type: number;\n format_type: number;\n available?: boolean;\n guild_id?: Snowflake;\n user?: UserData;\n sort_value?: number;\n}\n\n// ─── Messages ────────────────────────────────────────────────────────────────\n\n/** Raw Discord message reference. */\nexport interface APIMessageReference {\n type?: number;\n message_id?: Snowflake;\n channel_id?: Snowflake;\n guild_id?: Snowflake;\n fail_if_not_exists?: boolean;\n}\n/** Raw Discord message reaction. */\nexport interface APIMessageReaction {\n count: number;\n count_details?: Record<string, number>;\n me?: boolean;\n me_burst?: boolean;\n emoji: APIPartialEmoji;\n burst_colors?: string[];\n}\n/** Raw Discord message object. */\nexport interface APIMessage {\n id: Snowflake;\n channel_id: Snowflake;\n author: UserData;\n content: string;\n timestamp?: string;\n edited_timestamp?: string | null;\n tts?: boolean;\n mention_everyone?: boolean;\n mentions?: UserData[];\n mention_roles?: Snowflake[];\n mention_channels?: Array<Record<string, unknown>>;\n attachments?: APIAttachment[];\n embeds?: APIEmbed[];\n reactions?: APIMessageReaction[];\n nonce?: string | number | null;\n pinned?: boolean;\n webhook_id?: Snowflake;\n type?: number;\n activity?: Record<string, unknown>;\n application?: Record<string, unknown>;\n application_id?: Snowflake;\n message_reference?: APIMessageReference;\n flags?: number;\n referenced_message?: APIMessage | null;\n interaction_metadata?: Record<string, unknown>;\n thread?: Record<string, unknown>;\n components?: APIMessageComponent[];\n sticker_items?: APIStickerItem[];\n stickers?: APISticker[];\n position?: number;\n role_subscription_data?: Record<string, unknown>;\n purchase_notification?: Record<string, unknown>;\n poll?: Record<string, unknown>;\n guild_id?: Snowflake;\n}\n\n// ─── Channels ────────────────────────────────────────────────────────────────\n\n/** Raw Discord channel object. */\nexport interface APIChannel {\n id: Snowflake;\n type: number;\n guild_id?: Snowflake;\n position?: number;\n permission_overwrites?: APIOverwrite[];\n name?: string | null;\n topic?: string | null;\n nsfw?: boolean;\n last_message_id?: Snowflake | null;\n bitrate?: number;\n user_limit?: number;\n rate_limit_per_user?: number;\n recipients?: UserData[];\n icon?: string | null;\n owner_id?: Snowflake;\n application_id?: Snowflake;\n parent_id?: Snowflake | null;\n last_pin_timestamp?: string | null;\n rtc_region?: string | null;\n video_quality_mode?: number;\n message_count?: number;\n member_count?: number;\n thread_metadata?: APIThreadMetadata;\n default_auto_archive_duration?: number;\n flags?: number;\n total_message_sent?: number;\n available_tags?: APIForumTag[];\n default_reaction_emoji?: APIPartialEmoji | null;\n default_thread_rate_limit_per_user?: number;\n default_sort_order?: number | null;\n default_forum_layout?: number;\n}\n\n/** Raw Discord thread metadata. */\nexport interface APIThreadMetadata {\n archived: boolean;\n auto_archive_duration: number;\n archive_timestamp: string;\n locked: boolean;\n invitable?: boolean;\n create_timestamp?: string | null;\n}\n\n/** Raw Discord forum tag. */\nexport interface APIForumTag {\n id: Snowflake;\n name: string;\n moderated: boolean;\n emoji_id?: Snowflake | null;\n emoji_name?: string | null;\n}\n\n/** Raw Discord thread member. */\nexport interface APIThreadMember {\n id?: Snowflake;\n user_id?: Snowflake;\n join_timestamp: string;\n flags: number;\n member?: APIGuildMember;\n}\n\n// ─── Roles ────────────────────────────────────────────────────────────────────\n\n/** Raw Discord role object. */\nexport interface APIRole {\n id: Snowflake;\n name: string;\n color: number;\n hoist: boolean;\n icon?: string | null;\n unicode_emoji?: string | null;\n position: number;\n permissions: string;\n managed: boolean;\n mentionable: boolean;\n tags?: Record<string, unknown>;\n flags?: number;\n}\n\n// ─── Emoji ────────────────────────────────────────────────────────────────────\n\n/** Raw Discord emoji object. */\nexport interface APIEmoji {\n id: Snowflake | null;\n name: string | null;\n roles?: Snowflake[];\n user?: UserData;\n require_colons?: boolean;\n managed?: boolean;\n animated?: boolean;\n available?: boolean;\n}\n\n// ─── Guilds ───────────────────────────────────────────────────────────────────\n\n/** Raw Discord guild object. */\nexport interface APIGuild {\n id: Snowflake;\n name: string;\n icon?: string | null;\n icon_hash?: string | null;\n splash?: string | null;\n discovery_splash?: string | null;\n owner?: boolean;\n owner_id?: Snowflake;\n permissions?: string;\n afk_channel_id?: Snowflake | null;\n afk_timeout?: number;\n widget_enabled?: boolean;\n widget_channel_id?: Snowflake | null;\n verification_level?: number;\n default_message_notifications?: number;\n explicit_content_filter?: number;\n roles?: APIRole[];\n emojis?: APIEmoji[];\n stickers?: APISticker[];\n features?: string[];\n mfa_level?: number;\n application_id?: Snowflake | null;\n system_channel_id?: Snowflake | null;\n system_channel_flags?: number;\n rules_channel_id?: Snowflake | null;\n max_presences?: number | null;\n max_members?: number;\n vanity_url_code?: string | null;\n description?: string | null;\n banner?: string | null;\n premium_tier?: number;\n premium_subscription_count?: number;\n preferred_locale?: string;\n public_updates_channel_id?: Snowflake | null;\n max_video_channel_users?: number;\n approximate_member_count?: number;\n approximate_presence_count?: number;\n nsfw_level?: number;\n safety_alerts_channel_id?: Snowflake | null;\n member_count?: number;\n}\n\n// ─── Welcome Screen ───────────────────────────────────────────────────────────\n\nexport interface APIWelcomeScreenChannel {\n channel_id: Snowflake;\n description: string;\n emoji_id: Snowflake | null;\n emoji_name: string | null;\n}\n\nexport interface APIGuildWelcomeScreen {\n description: string | null;\n welcome_channels: APIWelcomeScreenChannel[];\n}\n\n// ─── Guild Onboarding ─────────────────────────────────────────────────────────\n\nexport interface APIOnboardingPromptOption {\n id: Snowflake;\n channel_ids: Snowflake[];\n role_ids: Snowflake[];\n emoji?: APIPartialEmoji;\n title: string;\n description: string | null;\n}\n\nexport interface APIOnboardingPrompt {\n id: Snowflake;\n type: number;\n options: APIOnboardingPromptOption[];\n title: string;\n single_select: boolean;\n required: boolean;\n in_onboarding: boolean;\n}\n\nexport interface APIGuildOnboarding {\n guild_id: Snowflake;\n prompts: APIOnboardingPrompt[];\n default_channel_ids: Snowflake[];\n enabled: boolean;\n mode: number;\n}\n\n/** Raw Discord guild member object. */\nexport interface APIGuildMember {\n user: UserData;\n nick?: string | null;\n avatar?: string | null;\n roles: Snowflake[];\n joined_at: string;\n premium_since?: string | null;\n deaf?: boolean;\n mute?: boolean;\n flags?: number;\n pending?: boolean;\n permissions?: string;\n communication_disabled_until?: string | null;\n guild_id?: Snowflake;\n}\n\n// ─── Voice ────────────────────────────────────────────────────────────────────\n\n/** Raw Discord voice state object. */\nexport interface APIVoiceState {\n guild_id?: Snowflake;\n channel_id?: Snowflake | null;\n user_id: Snowflake;\n member?: APIGuildMember;\n session_id: string;\n deaf: boolean;\n mute: boolean;\n self_deaf: boolean;\n self_mute: boolean;\n self_stream?: boolean;\n self_video: boolean;\n suppress: boolean;\n request_to_speak_timestamp?: string | null;\n}\n\n/** Raw Discord voice server update event. */\nexport interface APIVoiceServerUpdate {\n token: string;\n guild_id: Snowflake;\n endpoint?: string | null;\n}\n\n// ─── Presence ────────────────────────────────────────────────────────────────\n\n/** Raw Discord activity object. */\nexport interface APIActivity {\n name: string;\n type: number;\n url?: string | null;\n created_at: number;\n state?: string | null;\n details?: string | null;\n emoji?: APIPartialEmoji | null;\n}\n\n/** Raw Discord presence update event. */\nexport interface APIPresenceUpdate {\n user: { id: Snowflake } & Partial<UserData>;\n guild_id: Snowflake;\n status: string;\n activities: APIActivity[];\n client_status: { desktop?: string; mobile?: string; web?: string };\n}\n\n// ─── Typing ───────────────────────────────────────────────────────────────────\n\n/** Raw Discord typing start event. */\nexport interface APITypingStart {\n channel_id: Snowflake;\n guild_id?: Snowflake;\n user_id: Snowflake;\n timestamp: number;\n member?: APIGuildMember;\n}\n\n// ─── Guilds ──────────────────────────────────────────────────────────────────\n\n/** Raw Discord guild preview. */\nexport interface APIGuildPreview {\n id: Snowflake;\n name: string;\n icon: string | null;\n splash: string | null;\n discovery_splash: string | null;\n emojis: unknown[];\n features: string[];\n approximate_member_count: number;\n approximate_presence_count: number;\n description: string | null;\n stickers: unknown[];\n}\n\n// ─── Invites ─────────────────────────────────────────────────────────────────\n\n/** Raw Discord invite. */\nexport interface APIInvite {\n code: string;\n guild?: Partial<APIGuild>;\n channel: Partial<APIChannel>;\n inviter?: UserData;\n target_type?: number;\n target_user?: UserData;\n approximate_presence_count?: number;\n approximate_member_count?: number;\n}\n\n/** Raw Discord invite create event. */\nexport interface APIInviteCreate {\n channel_id: Snowflake;\n code: string;\n created_at: string;\n guild_id?: Snowflake;\n inviter?: UserData;\n max_age: number;\n max_uses: number;\n target_type?: number;\n target_user?: UserData;\n temporary: boolean;\n uses: number;\n}\n\n/** Raw Discord invite delete event. */\nexport interface APIInviteDelete {\n channel_id: Snowflake;\n guild_id?: Snowflake;\n code: string;\n}\n\n// ─── Webhooks ────────────────────────────────────────────────────────────────\n\n/** Raw Discord webhooks update event. */\nexport interface APIWebhooksUpdate {\n guild_id: Snowflake;\n channel_id: Snowflake;\n}\n\n/** Raw Discord webhook object. */\nexport interface APIWebhook {\n id: Snowflake;\n type: number;\n guild_id?: Snowflake | null;\n channel_id?: Snowflake | null;\n user?: UserData;\n name?: string | null;\n avatar?: string | null;\n token?: string;\n application_id?: Snowflake | null;\n url?: string;\n}\n\n// ─── AutoMod ─────────────────────────────────────────────────────────────────\n\n/** Raw Discord AutoMod action. */\nexport interface APIAutoModerationAction {\n type: number;\n metadata?: {\n channel_id?: Snowflake;\n duration_seconds?: number;\n custom_message?: string;\n };\n}\n\n// ─── Audit Logs ──────────────────────────────────────────────────────────────\n\n/** Raw Discord audit log change object. */\nexport interface APIAuditLogChange {\n new_value?: unknown;\n old_value?: unknown;\n key: string;\n}\n\n/** Raw Discord audit log entry options object. */\nexport interface APIAuditLogOptions {\n app_id?: Snowflake;\n auto_moderation_rule_name?: string;\n auto_moderation_rule_trigger_type?: string;\n channel_id?: Snowflake;\n count?: string;\n delete_member_days?: string;\n id?: Snowflake;\n members_removed?: string;\n message_id?: Snowflake;\n role_name?: string;\n type?: string;\n integration_type?: string;\n}\n\n/** Raw Discord audit log entry object. */\nexport interface APIAuditLogEntry {\n target_id: string | null;\n changes?: APIAuditLogChange[];\n user_id: Snowflake | null;\n id: Snowflake;\n action_type: number;\n options?: APIAuditLogOptions;\n reason?: string;\n}\n\n/** Raw Discord audit log object. */\nexport interface APIAuditLog {\n audit_log_entries: APIAuditLogEntry[];\n guild_scheduled_events: APIGuildScheduledEvent[];\n integrations: Array<Record<string, unknown>>;\n threads: APIChannel[];\n users: UserData[];\n webhooks: APIWebhook[];\n application_commands: APIApplicationCommand[];\n auto_moderation_rules: APIAutoModerationRule[];\n}\n\n/** Raw Discord AutoMod rule object. */\nexport interface APIAutoModerationRule {\n id: Snowflake;\n guild_id: Snowflake;\n name: string;\n creator_id: Snowflake;\n event_type: number;\n trigger_type: number;\n trigger_metadata: Record<string, unknown>;\n actions: APIAutoModerationAction[];\n enabled: boolean;\n exempt_roles: Snowflake[];\n exempt_channels: Snowflake[];\n}\n\n/** Raw Discord AutoMod action execution event. */\nexport interface APIAutoModerationActionExecution {\n guild_id: Snowflake;\n action: APIAutoModerationAction;\n rule_id: Snowflake;\n rule_trigger_type: number;\n user_id: Snowflake;\n channel_id?: Snowflake;\n message_id?: Snowflake;\n alert_system_message_id?: Snowflake;\n content: string;\n matched_keyword?: string | null;\n matched_content?: string | null;\n}\n\n// ─── Scheduled Events ─────────────────────────────────────────────────────────\n\n/** Raw Discord guild scheduled event entity metadata. */\nexport interface APIGuildScheduledEventEntityMetadata {\n location?: string;\n}\n\n/** Raw Discord guild scheduled event object. */\nexport interface APIGuildScheduledEvent {\n id: Snowflake;\n guild_id: Snowflake;\n channel_id?: Snowflake | null;\n creator_id?: Snowflake | null;\n name: string;\n description?: string | null;\n scheduled_start_time: string;\n scheduled_end_time?: string | null;\n privacy_level: number;\n status: number;\n entity_type: number;\n entity_id?: Snowflake | null;\n entity_metadata?: APIGuildScheduledEventEntityMetadata | null;\n creator?: UserData;\n user_count?: number;\n image?: string | null;\n}\n\n// ─── Stage Instances ─────────────────────────────────────────────────────────\n\n/** Raw Discord stage instance object. */\nexport interface APIStageInstance {\n id: Snowflake;\n guild_id: Snowflake;\n channel_id: Snowflake;\n topic: string;\n privacy_level: number;\n discoverable_disabled?: boolean;\n guild_scheduled_event_id?: Snowflake | null;\n}\n\n// ─── Application Commands ─────────────────────────────────────────────────────\n\n/** Discord application command option types. */\nexport const ApplicationCommandOptionType = {\n SubCommand: 1,\n SubCommandGroup: 2,\n String: 3,\n Integer: 4,\n Boolean: 5,\n User: 6,\n Channel: 7,\n Role: 8,\n Mentionable: 9,\n Number: 10,\n Attachment: 11,\n} as const;\n\n/** Discord application command types. */\nexport const ApplicationCommandType = {\n ChatInput: 1,\n User: 2,\n Message: 3,\n} as const;\n\n/** Raw Discord application command option. */\nexport interface APIApplicationCommandOption {\n type: number;\n name: string;\n description: string;\n required?: boolean;\n choices?: Array<{ name: string; value: string | number }>;\n options?: APIApplicationCommandOption[];\n min_value?: number;\n max_value?: number;\n min_length?: number;\n max_length?: number;\n autocomplete?: boolean;\n channel_types?: number[];\n}\n\n/** Raw Discord application command object (from API). */\nexport interface APIApplicationCommand {\n id: Snowflake;\n type?: number;\n application_id: Snowflake;\n guild_id?: Snowflake;\n name: string;\n description: string;\n options?: APIApplicationCommandOption[];\n default_member_permissions?: string | null;\n dm_permission?: boolean;\n nsfw?: boolean;\n version: Snowflake;\n}\n\n/** Data for creating/overwriting an application command. */\nexport interface ApplicationCommandData {\n name: string;\n description: string;\n type?: number;\n options?: APIApplicationCommandOption[];\n default_member_permissions?: string | null;\n dm_permission?: boolean;\n nsfw?: boolean;\n}\n\n/** A channel permission overwrite for a role (type 0) or member (type 1). */\nexport interface APIOverwrite {\n id: Snowflake;\n type: 0 | 1;\n /** Allowed permission bits as a decimal string. */\n allow: string;\n /** Denied permission bits as a decimal string. */\n deny: string;\n}\n\n// ─── Soundboard & Monetization ───────────────────────────────────────────────\n/** Raw Discord soundboard sound. */\nexport interface APISoundboardSound {\n sound_id: string;\n name: string;\n volume: number;\n emoji_id: string | null;\n emoji_name: string | null;\n guild_id?: string;\n available: boolean;\n user?: UserData;\n}\n\n/** Raw Discord SKU. */\nexport interface APISKU {\n id: string;\n type: number;\n application_id: string;\n name: string;\n slug: string;\n flags: number;\n}\n\n/** Raw Discord entitlement. */\nexport interface APIEntitlement {\n id: string;\n sku_id: string;\n application_id: string;\n user_id?: string;\n guild_id?: string;\n type: number;\n deleted: boolean;\n starts_at?: string | null;\n ends_at?: string | null;\n consumed?: boolean;\n}\n\n/** Raw Discord subscription. */\nexport interface APISubscription {\n id: string;\n user_id: string;\n sku_ids: string[];\n entitlement_ids: string[];\n current_period_start: string;\n current_period_end: string;\n status: number;\n canceled_at: string | null;\n country?: string;\n}\n"
|
|
5
|
+
"// ─── Gateway Intents ─────────────────────────────────────────────────────────\n\n/** Gateway intent bit flags supported by Discord (PascalCase). */\nexport const GatewayIntentBits = {\n Guilds: 1 << 0,\n GuildMembers: 1 << 1,\n GuildModeration: 1 << 2,\n GuildExpressions: 1 << 3,\n GuildIntegrations: 1 << 4,\n GuildWebhooks: 1 << 5,\n GuildInvites: 1 << 6,\n GuildVoiceStates: 1 << 7,\n GuildPresences: 1 << 8,\n GuildMessages: 1 << 9,\n GuildMessageReactions: 1 << 10,\n GuildMessageTyping: 1 << 11,\n DirectMessages: 1 << 12,\n DirectMessageReactions: 1 << 13,\n DirectMessageTyping: 1 << 14,\n MessageContent: 1 << 15,\n GuildScheduledEvents: 1 << 16,\n AutoModerationConfiguration: 1 << 20,\n AutoModerationExecution: 1 << 21,\n GuildMessagePolls: 1 << 24,\n DirectMessagePolls: 1 << 25,\n} as const;\n\n/** Idiomatic camelCase Gateway intent bit flags supported by Discord. */\nexport const IntentBits = {\n guild: 1 << 0,\n guilds: 1 << 0,\n guildMembers: 1 << 1,\n guildModeration: 1 << 2,\n guildBans: 1 << 2,\n guildExpressions: 1 << 3,\n guildEmojis: 1 << 3,\n guildEmojisAndStickers: 1 << 3,\n guildIntegrations: 1 << 4,\n guildWebhooks: 1 << 5,\n guildInvites: 1 << 6,\n guildVoiceStates: 1 << 7,\n guildPresences: 1 << 8,\n guildMessages: 1 << 9,\n guildMessage: 1 << 9,\n guildMessageReactions: 1 << 10,\n guildMessageTyping: 1 << 11,\n directMessages: 1 << 12,\n directMessageReactions: 1 << 13,\n directMessageTyping: 1 << 14,\n messageContent: 1 << 15,\n guildScheduledEvents: 1 << 16,\n autoModerationConfiguration: 1 << 20,\n autoModerationExecution: 1 << 21,\n guildMessagePolls: 1 << 24,\n directMessagePolls: 1 << 25,\n} as const;\n\n/** Alias for IntentBits. */\nexport const Intents = IntentBits;\n\n/** Gateway intent resolvable value (single bitfield, enum key, or array of bitfields/strings). */\nexport type GatewayIntentResolvable =\n | number\n | keyof typeof GatewayIntentBits\n | keyof typeof IntentBits\n | (\n | number\n | keyof typeof GatewayIntentBits\n | keyof typeof IntentBits\n | string\n )[]\n | { readonly bitfield: number };\n\n/** Resolves any GatewayIntentResolvable into a raw bitfield integer. */\nexport function resolveGatewayIntents(\n intents: GatewayIntentResolvable,\n): number {\n if (typeof intents === \"number\") return intents;\n if (intents && typeof intents === \"object\" && !Array.isArray(intents))\n return intents.bitfield;\n if (Array.isArray(intents)) {\n return intents.reduce<number>((acc, intent) => {\n return acc | resolveGatewayIntents(intent as any);\n }, 0);\n }\n if (typeof intents === \"string\") {\n if (intents in GatewayIntentBits)\n return (GatewayIntentBits as Record<string, number>)[intents]!;\n if (intents in IntentBits)\n return (IntentBits as Record<string, number>)[intents]!;\n const lower = intents.charAt(0).toLowerCase() + intents.slice(1);\n if (lower in IntentBits)\n return (IntentBits as Record<string, number>)[lower]!;\n const num = Number(intents);\n if (!Number.isNaN(num)) return num;\n }\n return 0;\n}\n\n/**\n * Discord.js-familiar intent bitfield.\n * @example new IntentsBitField([IntentsBitField.Flags.Guilds, \"GuildMessages\"])\n */\nexport class IntentsBitField {\n /** Intent flag values by name. */\n public static readonly Flags = GatewayIntentBits;\n /** Raw intent bitfield. */\n public bitfield: number;\n\n public constructor(bits: GatewayIntentResolvable = 0) {\n this.bitfield = resolveGatewayIntents(bits);\n }\n\n /** Whether every given intent is set. */\n public has(bits: GatewayIntentResolvable): boolean {\n const resolved = resolveGatewayIntents(bits);\n return (this.bitfield & resolved) === resolved;\n }\n\n /** Whether any given intent is set. */\n public any(bits: GatewayIntentResolvable): boolean {\n return (this.bitfield & resolveGatewayIntents(bits)) !== 0;\n }\n\n /** Adds intents in place. @returns This bitfield. */\n public add(...bits: GatewayIntentResolvable[]): this {\n for (const bit of bits) this.bitfield |= resolveGatewayIntents(bit);\n return this;\n }\n\n /** Removes intents in place. @returns This bitfield. */\n public remove(...bits: GatewayIntentResolvable[]): this {\n for (const bit of bits) this.bitfield &= ~resolveGatewayIntents(bit);\n return this;\n }\n\n /** Names of the set intents. */\n public toArray(): (keyof typeof GatewayIntentBits)[] {\n return (\n Object.keys(GatewayIntentBits) as (keyof typeof GatewayIntentBits)[]\n ).filter((name) => this.has(GatewayIntentBits[name]));\n }\n\n /** Whether this equals another bitfield. */\n public equals(bits: GatewayIntentResolvable): boolean {\n return this.bitfield === resolveGatewayIntents(bits);\n }\n\n public valueOf(): number {\n return this.bitfield;\n }\n\n public toJSON(): number {\n return this.bitfield;\n }\n}\n\n// ─── Gateway Config ───────────────────────────────────────────────────────────\n\n/** Gateway connection properties (OS, browser, device). */\nexport interface GatewayProperties {\n os?: string;\n browser?: string;\n device?: string;\n [key: string]: unknown;\n}\n/** Gateway presence activity. */\nexport interface GatewayPresenceActivity {\n name: string;\n type?: number;\n url?: string;\n state?: string;\n}\n/** Gateway presence data. */\nexport interface GatewayPresence {\n status?: \"online\" | \"dnd\" | \"idle\" | \"invisible\" | \"offline\";\n activities?: GatewayPresenceActivity[];\n afk?: boolean;\n since?: number | null;\n}\n/** Client configuration. */\nexport interface ClientOptions {\n token: string;\n intents: GatewayIntentResolvable;\n gateway?: GatewayOptions;\n rest?: RESTOptions;\n /** Opt-in bounded per-channel message cache. Messages are not cached by default. */\n messageCache?: { maxSize?: number; ttl?: number };\n /**\n * Which resources the client keeps from Gateway events. Everything is\n * cached by default; large bots can turn off what they do not read.\n * Events are still emitted either way.\n */\n cache?: {\n users?: boolean;\n members?: boolean;\n roles?: boolean;\n emojis?: boolean;\n };\n /**\n * Default `allowed_mentions` for every message the client sends (channel\n * send/edit, replies, interaction replies, edits and follow-ups), e.g.\n * `{ parse: [] }` so nothing pings unless a message says so. A message's\n * own `allowed_mentions` always wins.\n */\n allowedMentions?: AllowedMentions;\n}\n/** Discord's `allowed_mentions` object. */\nexport interface AllowedMentions {\n parse?: (\"users\" | \"roles\" | \"everyone\")[];\n users?: string[];\n roles?: string[];\n replied_user?: boolean;\n}\n/** Gateway connection configuration. */\nexport interface GatewayOptions {\n intents?: GatewayIntentResolvable;\n reconnect?: boolean;\n maxReconnectAttempts?: number;\n reconnectBaseDelay?: number;\n reconnectMaxDelay?: number;\n shardId?: number;\n shardCount?: number;\n properties?: GatewayProperties;\n presence?: GatewayPresence;\n}\n\n/** REST request configuration. */\nexport interface RESTOptions {\n timeout?: number;\n retries?: number;\n baseURL?: string;\n}\n",
|
|
6
|
+
"/** Discord API snowflake identifier. */\nexport type Snowflake = string;\n\nexport * from \"./gateway.js\";\nexport * from \"./gateway-events.js\";\n\n// ─── Core Discord Objects ─────────────────────────────────────────────────────\n\n/** Discord user object. */\nexport interface UserData {\n id: Snowflake;\n username: string;\n discriminator?: string;\n global_name?: string | null;\n avatar?: string | null;\n bot?: boolean;\n system?: boolean;\n public_flags?: number;\n}\n/** Current authenticated bot user. */\nexport type ClientUser = UserData;\n/** Discord Gateway payload envelope. */\nexport interface GatewayPayload<T = unknown> {\n op: number;\n d: T | null;\n s: number | null;\n t: string | null;\n}\n/** Generic Discord API error payload. */\nexport interface APIError {\n code?: number;\n message?: string;\n errors?: Record<string, unknown>;\n}\n\n// ─── Discord Flags & Enums ────────────────────────────────────────────────────\n\n/** Discord message flags. */\nexport const MessageFlags = {\n Crossposted: 1,\n IsCrosspost: 2,\n SuppressEmbeds: 4,\n SourceMessageDeleted: 8,\n Urgent: 16,\n HasThread: 32,\n Ephemeral: 64,\n Loading: 128,\n IsComponentsV2: 32768,\n} as const;\n/** One {@link MessageFlags} value, usable as a type. */\nexport type MessageFlags = (typeof MessageFlags)[keyof typeof MessageFlags];\n\n/** Discord channel types. */\nexport const ChannelEnum = {\n GuildText: 0,\n DM: 1,\n GuildVoice: 2,\n GroupDM: 3,\n GuildCategory: 4,\n GuildAnnouncement: 5,\n AnnouncementThread: 10,\n PublicThread: 11,\n PrivateThread: 12,\n GuildStageVoice: 13,\n GuildDirectory: 14,\n GuildForum: 15,\n GuildMedia: 16,\n} as const;\n/** One {@link ChannelEnum} value, usable as a type. */\nexport type ChannelEnum = (typeof ChannelEnum)[keyof typeof ChannelEnum];\n\n/** Discord component types. */\nexport const ComponentEnum = {\n ActionRow: 1,\n Button: 2,\n StringSelect: 3,\n TextInput: 4,\n UserSelect: 5,\n RoleSelect: 6,\n MentionableSelect: 7,\n ChannelSelect: 8,\n Section: 9,\n TextDisplay: 10,\n Thumbnail: 11,\n MediaGallery: 12,\n File: 13,\n Separator: 14,\n ContentInventoryEntry: 16,\n Container: 17,\n} as const;\n/** One {@link ComponentEnum} value, usable as a type. */\nexport type ComponentEnum = (typeof ComponentEnum)[keyof typeof ComponentEnum];\n\n/** Discord button style types. */\nexport const ButtonType = {\n Primary: 1,\n Secondary: 2,\n Success: 3,\n Danger: 4,\n Link: 5,\n Premium: 6,\n} as const;\n/** One {@link ButtonType} value, usable as a type: `style: ButtonType`. */\nexport type ButtonType = (typeof ButtonType)[keyof typeof ButtonType];\n\n/** Discord text input style types. */\nexport const TextInputType = {\n Short: 1,\n Paragraph: 2,\n} as const;\n/** One {@link TextInputType} value, usable as a type. */\nexport type TextInputType = (typeof TextInputType)[keyof typeof TextInputType];\n\n/** Discord interaction response types. */\nexport const InteractionResponseEnum = {\n Pong: 1,\n ChannelMessage: 4,\n DeferredChannelMessage: 5,\n DeferredMessageUpdate: 6,\n MessageUpdate: 7,\n Autocomplete: 8,\n Modal: 9,\n} as const;\n/** One {@link InteractionResponseEnum} value, usable as a type. */\nexport type InteractionResponseEnum =\n (typeof InteractionResponseEnum)[keyof typeof InteractionResponseEnum];\n\n/** Discord sticker format types. */\nexport const StickerFormatEnum = {\n PNG: 1,\n APNG: 2,\n Lottie: 3,\n GIF: 4,\n} as const;\n/** One {@link StickerFormatEnum} value, usable as a type. */\nexport type StickerFormatEnum =\n (typeof StickerFormatEnum)[keyof typeof StickerFormatEnum];\n\n/** Discord sticker types. */\nexport const StickerEnum = {\n Standard: 1,\n Guild: 2,\n} as const;\n/** One {@link StickerEnum} value, usable as a type. */\nexport type StickerEnum = (typeof StickerEnum)[keyof typeof StickerEnum];\n\n/** Discord verification levels. */\nexport const VerificationLevel = {\n None: 0,\n Low: 1,\n Medium: 2,\n High: 3,\n VeryHigh: 4,\n} as const;\n\n/** Discord premium tiers. */\nexport const PremiumTier = {\n None: 0,\n Tier1: 1,\n Tier2: 2,\n Tier3: 3,\n} as const;\n\n// ─── Embeds ───────────────────────────────────────────────────────────────────\n\n/** Raw Discord embed footer object. */\nexport interface APIEmbedFooter {\n text: string;\n icon_url?: string;\n proxy_icon_url?: string;\n}\n/** Raw Discord embed image/thumbnail/video object. */\nexport interface APIEmbedMedia {\n url: string;\n proxy_url?: string;\n height?: number;\n width?: number;\n}\n/** Raw Discord embed provider object. */\nexport interface APIEmbedProvider {\n name?: string;\n url?: string;\n}\n/** Raw Discord embed author object. */\nexport interface APIEmbedAuthor {\n name: string;\n url?: string;\n icon_url?: string;\n proxy_icon_url?: string;\n}\n/** Raw Discord embed field object. */\nexport interface APIEmbedField {\n name: string;\n value: string;\n inline?: boolean;\n}\n/** Raw Discord embed object. */\nexport interface APIEmbed {\n title?: string;\n type?: string;\n description?: string;\n url?: string;\n timestamp?: string;\n color?: number;\n footer?: APIEmbedFooter;\n image?: APIEmbedMedia;\n thumbnail?: APIEmbedMedia;\n video?: APIEmbedMedia;\n provider?: APIEmbedProvider;\n author?: APIEmbedAuthor;\n fields?: APIEmbedField[];\n}\n\n// ─── Message Components ───────────────────────────────────────────────────────\n\n/** Raw Discord select menu option. */\nexport interface APISelectMenuOption {\n label: string;\n value: string;\n description?: string;\n emoji?: APIPartialEmoji;\n default?: boolean;\n}\n/** Raw Discord emoji (partial, as used in components). */\nexport interface APIPartialEmoji {\n id?: Snowflake | null;\n name?: string | null;\n animated?: boolean;\n}\n/** Raw Discord button component. */\nexport interface APIButtonComponent {\n type: 2;\n style: number;\n label?: string;\n emoji?: APIPartialEmoji;\n custom_id?: string;\n url?: string;\n sku_id?: string;\n disabled?: boolean;\n}\n/** Raw Discord select menu component. */\nexport interface APISelectMenuComponent {\n type: 3 | 5 | 6 | 7 | 8;\n custom_id: string;\n options?: APISelectMenuOption[];\n channel_types?: number[];\n placeholder?: string;\n min_values?: number;\n max_values?: number;\n disabled?: boolean;\n}\n/** Raw Discord text input component. */\nexport interface APITextInputComponent {\n type: 4;\n custom_id: string;\n style: number;\n label: string;\n min_length?: number;\n max_length?: number;\n required?: boolean;\n value?: string;\n placeholder?: string;\n}\n/** Union of all raw message component types. */\nexport type APIMessageActionRowComponent =\n APIButtonComponent | APISelectMenuComponent | APITextInputComponent;\n/** Raw Discord action row component. */\nexport interface APIActionRowComponent {\n type: 1;\n id?: number;\n components: APIMessageActionRowComponent[];\n}\n/** Union including action rows and V2 components. */\nexport type APIMessageComponent =\n APIActionRowComponent | { type: Exclude<number, 1>; [key: string]: any };\n\n// ─── Attachments ─────────────────────────────────────────────────────────────\n\n/** Raw Discord attachment object. */\nexport interface APIAttachment {\n id: Snowflake;\n filename: string;\n description?: string | null;\n content_type?: string;\n size: number;\n url: string;\n proxy_url: string;\n height?: number | null;\n width?: number | null;\n ephemeral?: boolean;\n duration_secs?: number;\n waveform?: string;\n flags?: number;\n}\n\n// ─── Stickers ────────────────────────────────────────────────────────────────\n\n/** Compact sticker item as included in messages. */\nexport interface APIStickerItem {\n id: Snowflake;\n name: string;\n format_type: number;\n}\n/** Full Discord sticker object. */\nexport interface APISticker {\n id: Snowflake;\n pack_id?: Snowflake;\n name: string;\n description?: string | null;\n tags?: string;\n type: number;\n format_type: number;\n available?: boolean;\n guild_id?: Snowflake;\n user?: UserData;\n sort_value?: number;\n}\n\n// ─── Messages ────────────────────────────────────────────────────────────────\n\n/** Raw Discord message reference. */\nexport interface APIMessageReference {\n type?: number;\n message_id?: Snowflake;\n channel_id?: Snowflake;\n guild_id?: Snowflake;\n fail_if_not_exists?: boolean;\n}\n/** Raw Discord message reaction. */\nexport interface APIMessageReaction {\n count: number;\n count_details?: Record<string, number>;\n me?: boolean;\n me_burst?: boolean;\n emoji: APIPartialEmoji;\n burst_colors?: string[];\n}\n/** Raw Discord poll object. */\nexport interface APIPoll {\n question: { text?: string; emoji?: APIPartialEmoji };\n answers: Array<{\n answer_id: number;\n poll_media: { text?: string; emoji?: APIPartialEmoji };\n }>;\n expiry: string | null;\n allow_multiselect: boolean;\n layout_type: number;\n results?: {\n is_finalized: boolean;\n answer_counts: Array<{ id: number; count: number; me_voted: boolean }>;\n };\n}\n/** A forwarded message's snapshot of the original. */\nexport interface APIMessageSnapshot {\n message: Partial<\n Pick<\n APIMessage,\n | \"type\"\n | \"content\"\n | \"embeds\"\n | \"attachments\"\n | \"timestamp\"\n | \"edited_timestamp\"\n | \"flags\"\n | \"mentions\"\n | \"mention_roles\"\n | \"sticker_items\"\n | \"components\"\n >\n >;\n}\n/** Raw Discord message object. */\nexport interface APIMessage {\n id: Snowflake;\n channel_id: Snowflake;\n author: UserData;\n content: string;\n timestamp?: string;\n edited_timestamp?: string | null;\n tts?: boolean;\n mention_everyone?: boolean;\n mentions?: UserData[];\n mention_roles?: Snowflake[];\n mention_channels?: Array<Record<string, unknown>>;\n attachments?: APIAttachment[];\n embeds?: APIEmbed[];\n reactions?: APIMessageReaction[];\n nonce?: string | number | null;\n pinned?: boolean;\n webhook_id?: Snowflake;\n type?: number;\n activity?: Record<string, unknown>;\n application?: Record<string, unknown>;\n application_id?: Snowflake;\n message_reference?: APIMessageReference;\n flags?: number;\n referenced_message?: APIMessage | null;\n interaction_metadata?: Record<string, unknown>;\n thread?: Record<string, unknown>;\n components?: APIMessageComponent[];\n sticker_items?: APIStickerItem[];\n stickers?: APISticker[];\n position?: number;\n role_subscription_data?: Record<string, unknown>;\n purchase_notification?: Record<string, unknown>;\n poll?: APIPoll;\n /** Forwarded messages: a partial copy of the original (content, embeds, attachments, …). */\n message_snapshots?: APIMessageSnapshot[];\n guild_id?: Snowflake;\n /** The author's guild member, on guild messages from the Gateway (without `user`; the author is the user). */\n member?: Omit<APIGuildMember, \"user\"> & { user?: UserData };\n}\n\n// ─── Channels ────────────────────────────────────────────────────────────────\n\n/** Raw Discord channel object. */\nexport interface APIChannel {\n id: Snowflake;\n type: number;\n guild_id?: Snowflake;\n position?: number;\n permission_overwrites?: APIOverwrite[];\n name?: string | null;\n topic?: string | null;\n nsfw?: boolean;\n last_message_id?: Snowflake | null;\n bitrate?: number;\n user_limit?: number;\n rate_limit_per_user?: number;\n recipients?: UserData[];\n icon?: string | null;\n owner_id?: Snowflake;\n application_id?: Snowflake;\n parent_id?: Snowflake | null;\n last_pin_timestamp?: string | null;\n rtc_region?: string | null;\n video_quality_mode?: number;\n message_count?: number;\n member_count?: number;\n thread_metadata?: APIThreadMetadata;\n default_auto_archive_duration?: number;\n flags?: number;\n total_message_sent?: number;\n available_tags?: APIForumTag[];\n default_reaction_emoji?: APIPartialEmoji | null;\n default_thread_rate_limit_per_user?: number;\n default_sort_order?: number | null;\n default_forum_layout?: number;\n}\n\n/** Raw Discord thread metadata. */\nexport interface APIThreadMetadata {\n archived: boolean;\n auto_archive_duration: number;\n archive_timestamp: string;\n locked: boolean;\n invitable?: boolean;\n create_timestamp?: string | null;\n}\n\n/** Raw Discord forum tag. */\nexport interface APIForumTag {\n id: Snowflake;\n name: string;\n moderated: boolean;\n emoji_id?: Snowflake | null;\n emoji_name?: string | null;\n}\n\n/** Raw Discord thread member. */\nexport interface APIThreadMember {\n id?: Snowflake;\n user_id?: Snowflake;\n join_timestamp: string;\n flags: number;\n member?: APIGuildMember;\n}\n\n// ─── Roles ────────────────────────────────────────────────────────────────────\n\n/** Raw Discord role object. */\nexport interface APIRole {\n id: Snowflake;\n name: string;\n color: number;\n hoist: boolean;\n icon?: string | null;\n unicode_emoji?: string | null;\n position: number;\n permissions: string;\n managed: boolean;\n mentionable: boolean;\n tags?: Record<string, unknown>;\n flags?: number;\n}\n\n// ─── Emoji ────────────────────────────────────────────────────────────────────\n\n/** Raw Discord emoji object. */\nexport interface APIEmoji {\n id: Snowflake | null;\n name: string | null;\n roles?: Snowflake[];\n user?: UserData;\n require_colons?: boolean;\n managed?: boolean;\n animated?: boolean;\n available?: boolean;\n}\n\n// ─── Guilds ───────────────────────────────────────────────────────────────────\n\n/** Raw Discord guild object. */\nexport interface APIGuild {\n id: Snowflake;\n name: string;\n icon?: string | null;\n icon_hash?: string | null;\n splash?: string | null;\n discovery_splash?: string | null;\n owner?: boolean;\n owner_id?: Snowflake;\n permissions?: string;\n afk_channel_id?: Snowflake | null;\n afk_timeout?: number;\n widget_enabled?: boolean;\n widget_channel_id?: Snowflake | null;\n verification_level?: number;\n default_message_notifications?: number;\n explicit_content_filter?: number;\n roles?: APIRole[];\n emojis?: APIEmoji[];\n stickers?: APISticker[];\n features?: string[];\n mfa_level?: number;\n application_id?: Snowflake | null;\n system_channel_id?: Snowflake | null;\n system_channel_flags?: number;\n rules_channel_id?: Snowflake | null;\n max_presences?: number | null;\n max_members?: number;\n vanity_url_code?: string | null;\n description?: string | null;\n banner?: string | null;\n premium_tier?: number;\n premium_subscription_count?: number;\n preferred_locale?: string;\n public_updates_channel_id?: Snowflake | null;\n max_video_channel_users?: number;\n approximate_member_count?: number;\n approximate_presence_count?: number;\n nsfw_level?: number;\n safety_alerts_channel_id?: Snowflake | null;\n member_count?: number;\n}\n\n// ─── Welcome Screen ───────────────────────────────────────────────────────────\n\nexport interface APIWelcomeScreenChannel {\n channel_id: Snowflake;\n description: string;\n emoji_id: Snowflake | null;\n emoji_name: string | null;\n}\n\nexport interface APIGuildWelcomeScreen {\n description: string | null;\n welcome_channels: APIWelcomeScreenChannel[];\n}\n\n// ─── Guild Onboarding ─────────────────────────────────────────────────────────\n\nexport interface APIOnboardingPromptOption {\n id: Snowflake;\n channel_ids: Snowflake[];\n role_ids: Snowflake[];\n emoji?: APIPartialEmoji;\n title: string;\n description: string | null;\n}\n\nexport interface APIOnboardingPrompt {\n id: Snowflake;\n type: number;\n options: APIOnboardingPromptOption[];\n title: string;\n single_select: boolean;\n required: boolean;\n in_onboarding: boolean;\n}\n\nexport interface APIGuildOnboarding {\n guild_id: Snowflake;\n prompts: APIOnboardingPrompt[];\n default_channel_ids: Snowflake[];\n enabled: boolean;\n mode: number;\n}\n\n/** Raw Discord guild member object. */\nexport interface APIGuildMember {\n user: UserData;\n nick?: string | null;\n avatar?: string | null;\n roles: Snowflake[];\n joined_at: string;\n premium_since?: string | null;\n deaf?: boolean;\n mute?: boolean;\n flags?: number;\n pending?: boolean;\n permissions?: string;\n communication_disabled_until?: string | null;\n guild_id?: Snowflake;\n}\n\n// ─── Voice ────────────────────────────────────────────────────────────────────\n\n/** Raw Discord voice state object. */\nexport interface APIVoiceState {\n guild_id?: Snowflake;\n channel_id?: Snowflake | null;\n user_id: Snowflake;\n member?: APIGuildMember;\n session_id: string;\n deaf: boolean;\n mute: boolean;\n self_deaf: boolean;\n self_mute: boolean;\n self_stream?: boolean;\n self_video: boolean;\n suppress: boolean;\n request_to_speak_timestamp?: string | null;\n}\n\n/** Raw Discord voice server update event. */\nexport interface APIVoiceServerUpdate {\n token: string;\n guild_id: Snowflake;\n endpoint?: string | null;\n}\n\n// ─── Presence ────────────────────────────────────────────────────────────────\n\n/** Raw Discord activity object. */\n/** Discord activity types, for presences (`setPresence({ activities: [{ name, type: ActivityEnum.Watching }] })`). */\nexport const ActivityEnum = {\n Playing: 0,\n Streaming: 1,\n Listening: 2,\n Watching: 3,\n Custom: 4,\n Competing: 5,\n} as const;\n/** One {@link ActivityEnum} value, usable as a type. */\nexport type ActivityEnum = (typeof ActivityEnum)[keyof typeof ActivityEnum];\n\nexport interface APIActivity {\n name: string;\n type: number;\n url?: string | null;\n created_at: number;\n state?: string | null;\n details?: string | null;\n emoji?: APIPartialEmoji | null;\n}\n\n/** Raw Discord presence update event. */\nexport interface APIPresenceUpdate {\n user: { id: Snowflake } & Partial<UserData>;\n guild_id: Snowflake;\n status: string;\n activities: APIActivity[];\n client_status: { desktop?: string; mobile?: string; web?: string };\n}\n\n// ─── Typing ───────────────────────────────────────────────────────────────────\n\n/** Raw Discord typing start event. */\nexport interface APITypingStart {\n channel_id: Snowflake;\n guild_id?: Snowflake;\n user_id: Snowflake;\n timestamp: number;\n member?: APIGuildMember;\n}\n\n// ─── Guilds ──────────────────────────────────────────────────────────────────\n\n/** Raw Discord guild preview. */\nexport interface APIGuildPreview {\n id: Snowflake;\n name: string;\n icon: string | null;\n splash: string | null;\n discovery_splash: string | null;\n emojis: unknown[];\n features: string[];\n approximate_member_count: number;\n approximate_presence_count: number;\n description: string | null;\n stickers: unknown[];\n}\n\n// ─── Invites ─────────────────────────────────────────────────────────────────\n\n/** Raw Discord invite. */\nexport interface APIInvite {\n code: string;\n guild?: Partial<APIGuild>;\n channel: Partial<APIChannel>;\n inviter?: UserData;\n target_type?: number;\n target_user?: UserData;\n approximate_presence_count?: number;\n approximate_member_count?: number;\n}\n\n/** Raw Discord invite create event. */\nexport interface APIInviteCreate {\n channel_id: Snowflake;\n code: string;\n created_at: string;\n guild_id?: Snowflake;\n inviter?: UserData;\n max_age: number;\n max_uses: number;\n target_type?: number;\n target_user?: UserData;\n temporary: boolean;\n uses: number;\n}\n\n/** Raw Discord invite delete event. */\nexport interface APIInviteDelete {\n channel_id: Snowflake;\n guild_id?: Snowflake;\n code: string;\n}\n\n// ─── Webhooks ────────────────────────────────────────────────────────────────\n\n/** Raw Discord webhooks update event. */\nexport interface APIWebhooksUpdate {\n guild_id: Snowflake;\n channel_id: Snowflake;\n}\n\n/** Raw Discord webhook object. */\nexport interface APIWebhook {\n id: Snowflake;\n type: number;\n guild_id?: Snowflake | null;\n channel_id?: Snowflake | null;\n user?: UserData;\n name?: string | null;\n avatar?: string | null;\n token?: string;\n application_id?: Snowflake | null;\n url?: string;\n}\n\n// ─── AutoMod ─────────────────────────────────────────────────────────────────\n\n/** Raw Discord AutoMod action. */\nexport interface APIAutoModerationAction {\n type: number;\n metadata?: {\n channel_id?: Snowflake;\n duration_seconds?: number;\n custom_message?: string;\n };\n}\n\n// ─── Audit Logs ──────────────────────────────────────────────────────────────\n\n/** Raw Discord audit log change object. */\nexport interface APIAuditLogChange {\n new_value?: unknown;\n old_value?: unknown;\n key: string;\n}\n\n/** Raw Discord audit log entry options object. */\nexport interface APIAuditLogOptions {\n app_id?: Snowflake;\n auto_moderation_rule_name?: string;\n auto_moderation_rule_trigger_type?: string;\n channel_id?: Snowflake;\n count?: string;\n delete_member_days?: string;\n id?: Snowflake;\n members_removed?: string;\n message_id?: Snowflake;\n role_name?: string;\n type?: string;\n integration_type?: string;\n}\n\n/** Raw Discord audit log entry object. */\nexport interface APIAuditLogEntry {\n target_id: string | null;\n changes?: APIAuditLogChange[];\n user_id: Snowflake | null;\n id: Snowflake;\n action_type: number;\n options?: APIAuditLogOptions;\n reason?: string;\n}\n\n/** Raw Discord audit log object. */\nexport interface APIAuditLog {\n audit_log_entries: APIAuditLogEntry[];\n guild_scheduled_events: APIGuildScheduledEvent[];\n integrations: Array<Record<string, unknown>>;\n threads: APIChannel[];\n users: UserData[];\n webhooks: APIWebhook[];\n application_commands: APIApplicationCommand[];\n auto_moderation_rules: APIAutoModerationRule[];\n}\n\n/** Raw Discord AutoMod rule object. */\nexport interface APIAutoModerationRule {\n id: Snowflake;\n guild_id: Snowflake;\n name: string;\n creator_id: Snowflake;\n event_type: number;\n trigger_type: number;\n trigger_metadata: Record<string, unknown>;\n actions: APIAutoModerationAction[];\n enabled: boolean;\n exempt_roles: Snowflake[];\n exempt_channels: Snowflake[];\n}\n\n/** Raw Discord AutoMod action execution event. */\nexport interface APIAutoModerationActionExecution {\n guild_id: Snowflake;\n action: APIAutoModerationAction;\n rule_id: Snowflake;\n rule_trigger_type: number;\n user_id: Snowflake;\n channel_id?: Snowflake;\n message_id?: Snowflake;\n alert_system_message_id?: Snowflake;\n content: string;\n matched_keyword?: string | null;\n matched_content?: string | null;\n}\n\n// ─── Scheduled Events ─────────────────────────────────────────────────────────\n\n/** Raw Discord guild scheduled event entity metadata. */\nexport interface APIGuildScheduledEventEntityMetadata {\n location?: string;\n}\n\n/** Raw Discord guild scheduled event object. */\nexport interface APIGuildScheduledEvent {\n id: Snowflake;\n guild_id: Snowflake;\n channel_id?: Snowflake | null;\n creator_id?: Snowflake | null;\n name: string;\n description?: string | null;\n scheduled_start_time: string;\n scheduled_end_time?: string | null;\n privacy_level: number;\n status: number;\n entity_type: number;\n entity_id?: Snowflake | null;\n entity_metadata?: APIGuildScheduledEventEntityMetadata | null;\n creator?: UserData;\n user_count?: number;\n image?: string | null;\n}\n\n// ─── Stage Instances ─────────────────────────────────────────────────────────\n\n/** Raw Discord stage instance object. */\nexport interface APIStageInstance {\n id: Snowflake;\n guild_id: Snowflake;\n channel_id: Snowflake;\n topic: string;\n privacy_level: number;\n discoverable_disabled?: boolean;\n guild_scheduled_event_id?: Snowflake | null;\n}\n\n// ─── Application Commands ─────────────────────────────────────────────────────\n\n/** Discord application command option types. */\nexport const ApplicationCommandOptionEnum = {\n SubCommand: 1,\n SubCommandGroup: 2,\n String: 3,\n Integer: 4,\n Boolean: 5,\n User: 6,\n Channel: 7,\n Role: 8,\n Mentionable: 9,\n Number: 10,\n Attachment: 11,\n} as const;\n/** One {@link ApplicationCommandOptionEnum} value, usable as a type. */\nexport type ApplicationCommandOptionEnum =\n (typeof ApplicationCommandOptionEnum)[keyof typeof ApplicationCommandOptionEnum];\n\n/** Discord application command types. */\nexport const ApplicationCommandEnum = {\n ChatInput: 1,\n User: 2,\n Message: 3,\n} as const;\n/** One {@link ApplicationCommandEnum} value, usable as a type. */\nexport type ApplicationCommandEnum =\n (typeof ApplicationCommandEnum)[keyof typeof ApplicationCommandEnum];\n\n/** Raw Discord application command option. */\nexport interface APIApplicationCommandOption {\n type: number;\n name: string;\n description: string;\n required?: boolean;\n choices?: Array<{ name: string; value: string | number }>;\n options?: APIApplicationCommandOption[];\n min_value?: number;\n max_value?: number;\n min_length?: number;\n max_length?: number;\n autocomplete?: boolean;\n channel_types?: number[];\n}\n\n/** Raw Discord application command object (from API). */\nexport interface APIApplicationCommand {\n id: Snowflake;\n type?: number;\n application_id: Snowflake;\n guild_id?: Snowflake;\n name: string;\n description: string;\n options?: APIApplicationCommandOption[];\n default_member_permissions?: string | null;\n dm_permission?: boolean;\n nsfw?: boolean;\n version: Snowflake;\n}\n\n/** Data for creating/overwriting an application command. */\nexport interface ApplicationCommandData {\n name: string;\n description: string;\n type?: number;\n options?: APIApplicationCommandOption[];\n default_member_permissions?: string | null;\n dm_permission?: boolean;\n nsfw?: boolean;\n}\n\n/** A channel permission overwrite for a role (type 0) or member (type 1). */\nexport interface APIOverwrite {\n id: Snowflake;\n type: 0 | 1;\n /** Allowed permission bits as a decimal string. */\n allow: string;\n /** Denied permission bits as a decimal string. */\n deny: string;\n}\n\n// ─── Soundboard & Monetization ───────────────────────────────────────────────\n/** Raw Discord soundboard sound. */\nexport interface APISoundboardSound {\n sound_id: string;\n name: string;\n volume: number;\n emoji_id: string | null;\n emoji_name: string | null;\n guild_id?: string;\n available: boolean;\n user?: UserData;\n}\n\n/** Raw Discord SKU. */\nexport interface APISKU {\n id: string;\n type: number;\n application_id: string;\n name: string;\n slug: string;\n flags: number;\n}\n\n/** Raw Discord entitlement. */\nexport interface APIEntitlement {\n id: string;\n sku_id: string;\n application_id: string;\n user_id?: string;\n guild_id?: string;\n type: number;\n deleted: boolean;\n starts_at?: string | null;\n ends_at?: string | null;\n consumed?: boolean;\n}\n\n/** Raw Discord subscription. */\nexport interface APISubscription {\n id: string;\n user_id: string;\n sku_ids: string[];\n entitlement_ids: string[];\n current_period_start: string;\n current_period_end: string;\n status: number;\n canceled_at: string | null;\n country?: string;\n}\n\n// ─── Deprecated names (0.2.2) ────────────────────────────────────────────────\n// Kept so existing bots keep working; removed in 2.0. `…Style` became `…Type`\n// and `…Type` became `…Enum`.\n\n/** @deprecated Use {@link ButtonType}. Removed in 2.0. */\nexport const ButtonStyle = ButtonType;\n/** @deprecated Use {@link ButtonType}. Removed in 2.0. */\nexport type ButtonStyle = ButtonType;\n/** @deprecated Use {@link TextInputType}. Removed in 2.0. */\nexport const TextInputStyle = TextInputType;\n/** @deprecated Use {@link TextInputType}. Removed in 2.0. */\nexport type TextInputStyle = TextInputType;\n/** @deprecated Use {@link ChannelEnum}. Removed in 2.0. */\nexport const ChannelType = ChannelEnum;\n/** @deprecated Use {@link ChannelEnum}. Removed in 2.0. */\nexport type ChannelType = ChannelEnum;\n/** @deprecated Use {@link ComponentEnum}. Removed in 2.0. */\nexport const ComponentType = ComponentEnum;\n/** @deprecated Use {@link ComponentEnum}. Removed in 2.0. */\nexport type ComponentType = ComponentEnum;\n/** @deprecated Use {@link InteractionResponseEnum}. Removed in 2.0. */\nexport const InteractionResponseType = InteractionResponseEnum;\n/** @deprecated Use {@link InteractionResponseEnum}. Removed in 2.0. */\nexport type InteractionResponseType = InteractionResponseEnum;\n/** @deprecated Use {@link ApplicationCommandEnum}. Removed in 2.0. */\nexport const ApplicationCommandType = ApplicationCommandEnum;\n/** @deprecated Use {@link ApplicationCommandEnum}. Removed in 2.0. */\nexport type ApplicationCommandType = ApplicationCommandEnum;\n/** @deprecated Use {@link ApplicationCommandOptionEnum}. Removed in 2.0. */\nexport const ApplicationCommandOptionType = ApplicationCommandOptionEnum;\n/** @deprecated Use {@link ApplicationCommandOptionEnum}. Removed in 2.0. */\nexport type ApplicationCommandOptionType = ApplicationCommandOptionEnum;\n/** @deprecated Use {@link StickerEnum}. Removed in 2.0. */\nexport const StickerType = StickerEnum;\n/** @deprecated Use {@link StickerEnum}. Removed in 2.0. */\nexport type StickerType = StickerEnum;\n/** @deprecated Use {@link StickerFormatEnum}. Removed in 2.0. */\nexport const StickerFormatType = StickerFormatEnum;\n/** @deprecated Use {@link StickerFormatEnum}. Removed in 2.0. */\nexport type StickerFormatType = StickerFormatEnum;\n"
|
|
7
7
|
],
|
|
8
|
-
"mappings": ";;AAGO,IAAM,oBAAoB;AAAA,EAC7B,QAAQ,KAAK;AAAA,EACb,cAAc,KAAK;AAAA,EACnB,iBAAiB,KAAK;AAAA,EACtB,kBAAkB,KAAK;AAAA,EACvB,mBAAmB,KAAK;AAAA,EACxB,eAAe,KAAK;AAAA,EACpB,cAAc,KAAK;AAAA,EACnB,kBAAkB,KAAK;AAAA,EACvB,gBAAgB,KAAK;AAAA,EACrB,eAAe,KAAK;AAAA,EACpB,uBAAuB,KAAK;AAAA,EAC5B,oBAAoB,KAAK;AAAA,EACzB,gBAAgB,KAAK;AAAA,EACrB,wBAAwB,KAAK;AAAA,EAC7B,qBAAqB,KAAK;AAAA,EAC1B,gBAAgB,KAAK;AAAA,EACrB,sBAAsB,KAAK;AAAA,EAC3B,6BAA6B,KAAK;AAAA,EAClC,yBAAyB,KAAK;AAAA,EAC9B,mBAAmB,KAAK;AAAA,EACxB,oBAAoB,KA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B;AAAA,EAClC,WAAW;AAAA,EACX,MAAM;AAAA,EACN,SAAS;AACb;AAgHO,IAAM,cAAc;AAIpB,IAAM,iBAAiB;AAIvB,IAAM,cAAc;AAIpB,IAAM,gBAAgB;AAItB,IAAM,0BAA0B;AAIhC,IAAM,yBAAyB;AAI/B,IAAM,+BAA+B;AAIrC,IAAM,cAAc;AAIpB,IAAM,oBAAoB;",
|
|
9
|
+
"debugId": "40CBDDAEDFA8DAF664756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prefix-command arguments: split a message into arguments and read them as
|
|
3
|
+
* typed values, the way slash-command options are read.
|
|
4
|
+
*/
|
|
5
|
+
/** What an argument is read as. `rest` takes everything left, as one string. */
|
|
6
|
+
export type PrefixArgType = "string" | "integer" | "number" | "boolean" | "user" | "role" | "channel" | "mentionable" | "rest";
|
|
7
|
+
/** One expected argument. */
|
|
8
|
+
export interface PrefixArgSpec {
|
|
9
|
+
name: string;
|
|
10
|
+
type: PrefixArgType;
|
|
11
|
+
required?: boolean;
|
|
12
|
+
/** For `string` and `rest`: the longest accepted value. */
|
|
13
|
+
maxLength?: number;
|
|
14
|
+
/** For `integer` and `number`: the accepted range. */
|
|
15
|
+
min?: number;
|
|
16
|
+
max?: number;
|
|
17
|
+
/** Accepted values (compared case-insensitively for strings). */
|
|
18
|
+
choices?: readonly (string | number)[];
|
|
19
|
+
}
|
|
20
|
+
/** A mentionable argument: which kind of mention it was. An unmarked ID reads as a user. */
|
|
21
|
+
export interface MentionableArg {
|
|
22
|
+
id: string;
|
|
23
|
+
type: "user" | "role";
|
|
24
|
+
}
|
|
25
|
+
export type PrefixArgValue = string | number | boolean | MentionableArg;
|
|
26
|
+
export type PrefixArgsResult = {
|
|
27
|
+
ok: true;
|
|
28
|
+
values: Record<string, PrefixArgValue | undefined>;
|
|
29
|
+
} | {
|
|
30
|
+
ok: false;
|
|
31
|
+
arg: string;
|
|
32
|
+
error: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Splits text into arguments on whitespace. "Double quotes" or 'single quotes'
|
|
36
|
+
* keep spaces inside one argument; a backslash escapes the next character.
|
|
37
|
+
* @example tokenizeArgs(`ban @user "being rude"`) // ["ban", "@user", "being rude"]
|
|
38
|
+
*/
|
|
39
|
+
export declare function tokenizeArgs(input: string): string[];
|
|
40
|
+
/** The user ID in `<@id>`, `<@!id>` or a bare ID; null otherwise. */
|
|
41
|
+
export declare function parseUserMention(value: string): string | null;
|
|
42
|
+
/** The role ID in `<@&id>` or a bare ID; null otherwise. */
|
|
43
|
+
export declare function parseRoleMention(value: string): string | null;
|
|
44
|
+
/** The channel ID in `<#id>` or a bare ID; null otherwise. */
|
|
45
|
+
export declare function parseChannelMention(value: string): string | null;
|
|
46
|
+
/** A user or role mention; a bare ID reads as a user. Null otherwise. */
|
|
47
|
+
export declare function parseMentionable(value: string): MentionableArg | null;
|
|
48
|
+
/**
|
|
49
|
+
* Reads prefix-command arguments by position, as typed values. IDs come back
|
|
50
|
+
* as strings (user, role, channel); a mentionable says which it was. The first
|
|
51
|
+
* problem is reported, with the argument's name, instead of throwing.
|
|
52
|
+
* @param input The text after the command name, or already-split arguments.
|
|
53
|
+
* @param specs The expected arguments in order; a `rest` argument must be last.
|
|
54
|
+
* @example
|
|
55
|
+
* const result = parsePrefixArgs(`@user 10 spamming links`, [
|
|
56
|
+
* { name: "user", type: "user", required: true },
|
|
57
|
+
* { name: "minutes", type: "integer", min: 1, max: 40320 },
|
|
58
|
+
* { name: "reason", type: "rest" },
|
|
59
|
+
* ]);
|
|
60
|
+
* if (!result.ok) return message.reply(`\`${result.arg}\` ${result.error}.`);
|
|
61
|
+
*/
|
|
62
|
+
export declare function parsePrefixArgs(input: string | readonly string[], specs: readonly PrefixArgSpec[]): PrefixArgsResult;
|
|
63
|
+
/**
|
|
64
|
+
* Argument specs from a slash command's options, so one definition serves both
|
|
65
|
+
* `/command` and the prefix command. Subcommands and attachments are left out.
|
|
66
|
+
* @param options The command's (or subcommand's) `options` as sent to Discord.
|
|
67
|
+
* @param restLast Read the last string option as the rest of the message (handy for reasons).
|
|
68
|
+
*/
|
|
69
|
+
export declare function argsFromCommandOptions(options: readonly {
|
|
70
|
+
name: string;
|
|
71
|
+
type: number;
|
|
72
|
+
required?: boolean;
|
|
73
|
+
min_value?: number;
|
|
74
|
+
max_value?: number;
|
|
75
|
+
max_length?: number;
|
|
76
|
+
choices?: readonly {
|
|
77
|
+
value: string | number;
|
|
78
|
+
}[];
|
|
79
|
+
}[], restLast?: boolean): PrefixArgSpec[];
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -4,3 +4,4 @@ export declare function sleep(ms: number): Promise<void>;
|
|
|
4
4
|
export declare function randomInt(min: number, max: number): number;
|
|
5
5
|
/** Tests whether a value is a Discord snowflake-like ID. */
|
|
6
6
|
export declare function isSnowflake(value: string): boolean;
|
|
7
|
+
export { tokenizeArgs, parsePrefixArgs, argsFromCommandOptions, parseUserMention, parseRoleMention, parseChannelMention, parseMentionable, type PrefixArgType, type PrefixArgSpec, type PrefixArgValue, type PrefixArgsResult, type MentionableArg, } from "./args.js";
|
package/dist/utils/index.js
CHANGED
|
@@ -1,4 +1,185 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
// packages/utils/src/args.ts
|
|
3
|
+
var SNOWFLAKE = /^\d{16,22}$/;
|
|
4
|
+
var TRUE_WORDS = new Set([
|
|
5
|
+
"true",
|
|
6
|
+
"yes",
|
|
7
|
+
"y",
|
|
8
|
+
"on",
|
|
9
|
+
"1",
|
|
10
|
+
"enable",
|
|
11
|
+
"enabled"
|
|
12
|
+
]);
|
|
13
|
+
var FALSE_WORDS = new Set([
|
|
14
|
+
"false",
|
|
15
|
+
"no",
|
|
16
|
+
"n",
|
|
17
|
+
"off",
|
|
18
|
+
"0",
|
|
19
|
+
"disable",
|
|
20
|
+
"disabled"
|
|
21
|
+
]);
|
|
22
|
+
function tokenizeArgs(input) {
|
|
23
|
+
const args = [];
|
|
24
|
+
let current = "";
|
|
25
|
+
let quote = null;
|
|
26
|
+
let started = false;
|
|
27
|
+
for (let index = 0;index < input.length; index++) {
|
|
28
|
+
const character = input[index];
|
|
29
|
+
if (character === "\\" && index + 1 < input.length) {
|
|
30
|
+
current += input[++index];
|
|
31
|
+
started = true;
|
|
32
|
+
} else if (quote) {
|
|
33
|
+
if (character === quote)
|
|
34
|
+
quote = null;
|
|
35
|
+
else
|
|
36
|
+
current += character;
|
|
37
|
+
} else if (character === '"' || character === "'") {
|
|
38
|
+
if (started)
|
|
39
|
+
current += character;
|
|
40
|
+
else {
|
|
41
|
+
quote = character;
|
|
42
|
+
started = true;
|
|
43
|
+
}
|
|
44
|
+
} else if (/\s/.test(character)) {
|
|
45
|
+
if (started)
|
|
46
|
+
args.push(current);
|
|
47
|
+
current = "";
|
|
48
|
+
started = false;
|
|
49
|
+
} else {
|
|
50
|
+
current += character;
|
|
51
|
+
started = true;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (started)
|
|
55
|
+
args.push(current);
|
|
56
|
+
return args;
|
|
57
|
+
}
|
|
58
|
+
function parseUserMention(value) {
|
|
59
|
+
const id = /^<@!?(\d{16,22})>$/.exec(value)?.[1] ?? value;
|
|
60
|
+
return SNOWFLAKE.test(id) ? id : null;
|
|
61
|
+
}
|
|
62
|
+
function parseRoleMention(value) {
|
|
63
|
+
const id = /^<@&(\d{16,22})>$/.exec(value)?.[1] ?? value;
|
|
64
|
+
return SNOWFLAKE.test(id) ? id : null;
|
|
65
|
+
}
|
|
66
|
+
function parseChannelMention(value) {
|
|
67
|
+
const id = /^<#(\d{16,22})>$/.exec(value)?.[1] ?? value;
|
|
68
|
+
return SNOWFLAKE.test(id) ? id : null;
|
|
69
|
+
}
|
|
70
|
+
function parseMentionable(value) {
|
|
71
|
+
const role = /^<@&(\d{16,22})>$/.exec(value)?.[1];
|
|
72
|
+
if (role)
|
|
73
|
+
return { id: role, type: "role" };
|
|
74
|
+
const user = parseUserMention(value);
|
|
75
|
+
return user ? { id: user, type: "user" } : null;
|
|
76
|
+
}
|
|
77
|
+
function readOne(spec, raw) {
|
|
78
|
+
switch (spec.type) {
|
|
79
|
+
case "string":
|
|
80
|
+
case "rest":
|
|
81
|
+
if (spec.maxLength !== undefined && raw.length > spec.maxLength)
|
|
82
|
+
return {
|
|
83
|
+
error: `must be at most ${spec.maxLength} characters`
|
|
84
|
+
};
|
|
85
|
+
if (spec.choices && !spec.choices.some((choice) => String(choice).toLowerCase() === raw.toLowerCase()))
|
|
86
|
+
return { error: `must be one of: ${spec.choices.join(", ")}` };
|
|
87
|
+
return { value: raw };
|
|
88
|
+
case "integer":
|
|
89
|
+
case "number": {
|
|
90
|
+
const value = Number(raw);
|
|
91
|
+
if (!Number.isFinite(value) || raw.trim() === "")
|
|
92
|
+
return { error: "must be a number" };
|
|
93
|
+
if (spec.type === "integer" && !Number.isSafeInteger(value))
|
|
94
|
+
return { error: "must be a whole number" };
|
|
95
|
+
if (spec.min !== undefined && value < spec.min)
|
|
96
|
+
return { error: `must be at least ${spec.min}` };
|
|
97
|
+
if (spec.max !== undefined && value > spec.max)
|
|
98
|
+
return { error: `must be at most ${spec.max}` };
|
|
99
|
+
if (spec.choices && !spec.choices.includes(value))
|
|
100
|
+
return { error: `must be one of: ${spec.choices.join(", ")}` };
|
|
101
|
+
return { value };
|
|
102
|
+
}
|
|
103
|
+
case "boolean": {
|
|
104
|
+
const word = raw.toLowerCase();
|
|
105
|
+
if (TRUE_WORDS.has(word))
|
|
106
|
+
return { value: true };
|
|
107
|
+
if (FALSE_WORDS.has(word))
|
|
108
|
+
return { value: false };
|
|
109
|
+
return { error: "must be yes or no" };
|
|
110
|
+
}
|
|
111
|
+
case "user": {
|
|
112
|
+
const id = parseUserMention(raw);
|
|
113
|
+
return id ? { value: id } : { error: "must be a user mention or ID" };
|
|
114
|
+
}
|
|
115
|
+
case "role": {
|
|
116
|
+
const id = parseRoleMention(raw);
|
|
117
|
+
return id ? { value: id } : { error: "must be a role mention or ID" };
|
|
118
|
+
}
|
|
119
|
+
case "channel": {
|
|
120
|
+
const id = parseChannelMention(raw);
|
|
121
|
+
return id ? { value: id } : { error: "must be a channel mention or ID" };
|
|
122
|
+
}
|
|
123
|
+
case "mentionable": {
|
|
124
|
+
const value = parseMentionable(raw);
|
|
125
|
+
return value ? { value } : { error: "must be a user or role mention" };
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function parsePrefixArgs(input, specs) {
|
|
130
|
+
const args = typeof input === "string" ? tokenizeArgs(input) : [...input];
|
|
131
|
+
const values = {};
|
|
132
|
+
let position = 0;
|
|
133
|
+
for (const [index, spec] of specs.entries()) {
|
|
134
|
+
if (spec.type === "rest" && index !== specs.length - 1)
|
|
135
|
+
throw new TypeError(`The rest argument "${spec.name}" must be the last one.`);
|
|
136
|
+
const raw = spec.type === "rest" ? args.slice(position).join(" ") : args[position];
|
|
137
|
+
if (raw === undefined || raw === "") {
|
|
138
|
+
if (spec.required)
|
|
139
|
+
return { ok: false, arg: spec.name, error: "is required" };
|
|
140
|
+
values[spec.name] = undefined;
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
const read = readOne(spec, raw);
|
|
144
|
+
if ("error" in read)
|
|
145
|
+
return { ok: false, arg: spec.name, error: read.error };
|
|
146
|
+
values[spec.name] = read.value;
|
|
147
|
+
position += spec.type === "rest" ? args.length : 1;
|
|
148
|
+
}
|
|
149
|
+
return { ok: true, values };
|
|
150
|
+
}
|
|
151
|
+
var OPTION_TYPES = {
|
|
152
|
+
3: "string",
|
|
153
|
+
4: "integer",
|
|
154
|
+
5: "boolean",
|
|
155
|
+
6: "user",
|
|
156
|
+
7: "channel",
|
|
157
|
+
8: "role",
|
|
158
|
+
9: "mentionable",
|
|
159
|
+
10: "number"
|
|
160
|
+
};
|
|
161
|
+
function argsFromCommandOptions(options, restLast = false) {
|
|
162
|
+
const specs = [];
|
|
163
|
+
for (const option of options) {
|
|
164
|
+
const type = OPTION_TYPES[option.type];
|
|
165
|
+
if (!type)
|
|
166
|
+
continue;
|
|
167
|
+
specs.push({
|
|
168
|
+
name: option.name,
|
|
169
|
+
type,
|
|
170
|
+
required: option.required,
|
|
171
|
+
min: option.min_value,
|
|
172
|
+
max: option.max_value,
|
|
173
|
+
maxLength: option.max_length,
|
|
174
|
+
choices: option.choices?.map((choice) => choice.value)
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
const last = specs[specs.length - 1];
|
|
178
|
+
if (restLast && last?.type === "string")
|
|
179
|
+
last.type = "rest";
|
|
180
|
+
return specs;
|
|
181
|
+
}
|
|
182
|
+
|
|
2
183
|
// packages/utils/src/index.ts
|
|
3
184
|
function sleep(ms) {
|
|
4
185
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -10,9 +191,16 @@ function isSnowflake(value) {
|
|
|
10
191
|
return /^\d{16,22}$/.test(value);
|
|
11
192
|
}
|
|
12
193
|
export {
|
|
194
|
+
argsFromCommandOptions,
|
|
13
195
|
isSnowflake,
|
|
196
|
+
parseChannelMention,
|
|
197
|
+
parseMentionable,
|
|
198
|
+
parsePrefixArgs,
|
|
199
|
+
parseRoleMention,
|
|
200
|
+
parseUserMention,
|
|
14
201
|
randomInt,
|
|
15
|
-
sleep
|
|
202
|
+
sleep,
|
|
203
|
+
tokenizeArgs
|
|
16
204
|
};
|
|
17
205
|
|
|
18
|
-
//# debugId=
|
|
206
|
+
//# debugId=3EBA957FB9AD89B264756E2164756E21
|