lunibee 0.3.1 → 0.3.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/dist/builders/attachment.d.ts +1 -0
- package/dist/builders/clone.d.ts +10 -0
- package/dist/builders/commands.d.ts +1 -1
- package/dist/builders/components.d.ts +24 -5
- package/dist/builders/index.js +64 -17
- package/dist/builders/index.js.map +10 -9
- package/dist/collection/index.d.ts +1 -0
- package/dist/collection/index.js +297 -19
- package/dist/collection/index.js.map +5 -4
- package/dist/collection/redis.d.ts +98 -0
- package/dist/core/collector.d.ts +8 -0
- package/dist/core/events.d.ts +1 -0
- package/dist/core/index.d.ts +3 -0
- package/dist/core/index.js +6213 -4716
- package/dist/core/index.js.map +46 -39
- package/dist/core/permissions.d.ts +3 -402
- package/dist/core/redis-cache.d.ts +85 -0
- package/dist/formatters/index.d.ts +5 -1
- package/dist/formatters/index.js +7 -3
- package/dist/formatters/index.js.map +3 -3
- package/dist/handlers/index.js +11 -2
- package/dist/handlers/index.js.map +3 -3
- package/dist/index.js +8272 -6085
- package/dist/index.js.map +64 -58
- package/dist/managers/application.d.ts +10 -6
- package/dist/managers/base.d.ts +4 -1
- package/dist/managers/guild.d.ts +3 -1
- package/dist/managers/index.d.ts +6 -1
- package/dist/managers/index.js +365 -103
- package/dist/managers/index.js.map +19 -22
- package/dist/managers/member.d.ts +3 -1
- package/dist/managers/message.d.ts +13 -4
- package/dist/managers/thread.d.ts +3 -3
- package/dist/rest/decoder.d.ts +2 -0
- package/dist/rest/errors.d.ts +5 -2
- package/dist/rest/headers.d.ts +31 -0
- package/dist/rest/identity.d.ts +31 -0
- package/dist/rest/index.d.ts +97 -6
- package/dist/rest/index.js +1350 -220
- package/dist/rest/index.js.map +16 -13
- package/dist/rest/limiter.d.ts +75 -10
- package/dist/rest/redis.d.ts +103 -22
- package/dist/rest/scheduler.d.ts +13 -0
- package/dist/rest/store.d.ts +135 -12
- package/dist/rest/telemetry.d.ts +151 -0
- package/dist/rest/webhook.d.ts +18 -6
- package/dist/sharding/bus.d.ts +4 -2
- package/dist/sharding/cluster.d.ts +1 -1
- package/dist/sharding/health.d.ts +1 -1
- package/dist/sharding/host.d.ts +6 -0
- package/dist/sharding/identify.d.ts +2 -0
- package/dist/sharding/index.d.ts +6 -0
- package/dist/sharding/index.js +205 -39
- package/dist/sharding/index.js.map +14 -14
- package/dist/sharding/remote.d.ts +18 -2
- package/dist/sharding/supervisor.d.ts +1 -1
- package/dist/sharding/transport.d.ts +6 -5
- package/dist/sharding/worker.d.ts +11 -1
- package/dist/structures/base.d.ts +16 -5
- package/dist/structures/index.d.ts +1 -1
- package/dist/structures/index.js +57 -91
- package/dist/structures/index.js.map +10 -18
- package/dist/structures/options.d.ts +3 -2
- package/dist/structures/permissions.d.ts +409 -0
- package/dist/structures/resources.d.ts +4 -1
- package/dist/types/gateway.d.ts +4 -0
- package/dist/types/index.d.ts +14 -4
- package/dist/types/index.js.map +3 -3
- package/dist/utils/args.d.ts +3 -1
- package/dist/utils/index.d.ts +6 -1
- package/dist/utils/index.js +17 -10
- package/dist/utils/index.js.map +4 -4
- package/dist/voice/index.d.ts +7 -1
- package/dist/voice/index.js +33 -10
- package/dist/voice/index.js.map +3 -3
- package/dist/ws/index.d.ts +2 -0
- package/dist/ws/index.js +32 -4
- package/dist/ws/index.js.map +5 -5
- package/package.json +19 -16
package/dist/types/index.js.map
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
"sources": ["../../packages/types/src/channel-kind.ts", "../../packages/types/src/gateway.ts", "../../packages/types/src/index.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"/**\n * Channel kinds: a short name for what a channel is, in place of the numeric\n * `type` Discord sends. Threads share one kind; `type` still tells the three\n * apart.\n */\nexport const ChannelKinds = {\n text: [0],\n dm: [1],\n voice: [2],\n \"group-dm\": [3],\n category: [4],\n announcement: [5],\n thread: [10, 11, 12],\n stage: [13],\n directory: [14],\n forum: [15],\n media: [16],\n} as const;\n\n/** The name of a kind of channel, such as `\"text\"` or `\"voice\"`. */\nexport type ChannelKind = keyof typeof ChannelKinds;\n\n/** A channel type Discord has no kind for yet. */\nexport type UnknownChannelKind = \"unknown\";\n\nconst KIND_OF_TYPE = new Map<number, ChannelKind>(\n (Object.keys(ChannelKinds) as ChannelKind[]).flatMap((kind) =>\n ChannelKinds[kind].map((type): [number, ChannelKind] => [type, kind]),\n ),\n);\n\n/** The kind of a Discord channel `type`, or `\"unknown\"` for a type this version does not know. */\nexport function channelKindOf(type: number): ChannelKind | UnknownChannelKind {\n return KIND_OF_TYPE.get(type) ?? \"unknown\";\n}\n\n/** The Discord channel `type` numbers a kind covers (three for `\"thread\"`, one for the rest). */\nexport function channelTypesOf(kind: ChannelKind): readonly number[] {\n return ChannelKinds[kind];\n}\n",
|
|
6
|
-
"// ─── 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 intents: an array of intent bits or names, e.g. `[GatewayIntentBits.Guilds, \"GuildMessages\"]`. A single number, name or OR-ed bitfield is not accepted. */\nexport type GatewayIntentResolvable = readonly (\n number | keyof typeof GatewayIntentBits | keyof typeof IntentBits | string\n)[];\n\n/**\n * Resolves an array of intents into a raw bitfield integer.\n * @throws {TypeError} If `intents` is not an array (an OR-ed number, a single name or a bitfield object).\n */\nexport function resolveGatewayIntents(\n intents: GatewayIntentResolvable,\n): number {\n if (!Array.isArray(intents))\n throw new TypeError(\n \"Gateway intents must be an array, e.g. [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages].\",\n );\n return intents.reduce<number>(\n (acc, intent) => acc | resolveIntent(intent),\n 0,\n );\n}\n\n/** Resolves one intent: a bitfield, an intent name in either casing, or a numeric string. */\nfunction resolveIntent(intent: number | string): number {\n if (typeof intent === \"number\") return intent;\n const bits: Record<string, number> = {\n ...IntentBits,\n ...GatewayIntentBits,\n };\n const lower = intent.charAt(0).toLowerCase() + intent.slice(1);\n if (Object.hasOwn(bits, intent)) return bits[intent]!;\n if (Object.hasOwn(bits, lower)) return bits[lower]!;\n const num = Number(intent);\n return Number.isNaN(num) ? 0 : num;\n}\n\n/** What `IntentsBitField` methods take: one intent or an array of them. Clients and gateways take only arrays. */\ntype IntentsInput = GatewayIntentResolvable[number] | GatewayIntentResolvable;\n\nfunction resolveInput(bits: IntentsInput): number {\n return resolveGatewayIntents(Array.isArray(bits) ? bits : [bits as number]);\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: IntentsInput = []) {\n this.bitfield = resolveInput(bits);\n }\n\n /** Whether every given intent is set. */\n public has(bits: IntentsInput): boolean {\n const resolved = resolveInput(bits);\n return (this.bitfield & resolved) === resolved;\n }\n\n /** Whether any given intent is set. */\n public any(bits: IntentsInput): boolean {\n return (this.bitfield & resolveInput(bits)) !== 0;\n }\n\n /** Adds intents in place. @returns This bitfield. */\n public add(...bits: IntentsInput[]): this {\n for (const bit of bits) this.bitfield |= resolveInput(bit);\n return this;\n }\n\n /** Removes intents in place. @returns This bitfield. */\n public remove(...bits: IntentsInput[]): this {\n for (const bit of bits) this.bitfield &= ~resolveInput(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: IntentsInput): boolean {\n return this.bitfield === resolveInput(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]: string | undefined;\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 /**\n * zlib-stream transport compression for the Gateway connection, about a\n * tenth of the inbound bandwidth. Shorthand for `gateway: { compress }`,\n * which wins when both are set. Off by default.\n */\n compress?: boolean;\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 /** Keep each member's latest presence (needs the `GuildPresences` intent). Off by default: it is a lot of data. */\n presences?: 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 /** Where requests go. Must be `https:` (or `http:` on this machine) with no credentials, query or fragment. */\n baseURL?: string;\n /** Allow a cleartext `http://` `baseURL` on a network you trust, such as a REST proxy. Default false. */\n allowInsecureBaseURL?: boolean;\n}\n",
|
|
7
|
-
"/** Discord API snowflake identifier. */\nexport type Snowflake = string;\n\nexport * from \"./channel-kind.js\";\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// ─── Message payloads ────────────────────────────────────────────────────────\n\n/** A Discord payload, or a builder that serialises to one (its `toJSON()` runs when the request is sent). */\nexport type Buildable<T> = T | { toJSON(): T };\n\n/**\n * A message Lunibee sends: channel send and edit, message reply and edit,\n * interaction replies, follow-ups and updates. Embeds and components may be\n * builders or raw objects. Other Discord fields pass through unchanged.\n */\nexport interface MessagePayload {\n content?: string;\n embeds?: Buildable<APIEmbed>[];\n components?: Buildable<APIMessageComponent>[];\n allowed_mentions?: import(\"./gateway.js\").AllowedMentions;\n /** Discord message flags, e.g. `MessageFlags.SuppressEmbeds`. */\n flags?: number;\n tts?: boolean;\n /** Attachment metadata for files sent with the message. */\n attachments?: Array<{\n id: number | string;\n filename?: string;\n description?: string;\n }>;\n [key: string]: unknown;\n}\n\n/** A file to upload with a message. */\nexport interface MessageFile {\n name: string;\n data: Blob | Uint8Array | ArrayBuffer | string;\n contentType?: string;\n}\n\n/** A poll to send; Discord fills in `results` and `expiry` when it is read back. */\nexport interface MessagePoll {\n question: { text?: string; emoji?: APIPartialEmoji };\n answers: Array<{ poll_media: { text?: string; emoji?: APIPartialEmoji } }>;\n /** Hours the poll stays open (1-768). */\n duration?: number;\n allow_multiselect?: boolean;\n layout_type?: number;\n}\n\n/** What `send()` takes. */\nexport interface MessageCreateOptions extends MessagePayload {\n /** Files to upload; the message is sent as multipart. */\n files?: MessageFile[];\n /** Reply to or forward another message. */\n message_reference?: APIMessageReference;\n poll?: MessagePoll;\n sticker_ids?: Snowflake[];\n /** Returned on the Gateway event so the client can match its own message. */\n nonce?: string | number;\n enforce_nonce?: boolean;\n}\n\n/** What `edit()` takes: the fields Discord lets you change after sending. */\nexport interface MessageEditOptions extends MessagePayload {\n files?: MessageFile[];\n}\n\n/** What a reply, edit-reply, follow-up or update to an interaction takes. */\nexport interface InteractionReplyOptions extends MessagePayload {\n /** Only the person who ran the command sees it. */\n ephemeral?: boolean;\n files?: MessageFile[];\n poll?: MessagePoll;\n /** On `reply()` / `update()`: return the created message (one request, no `fetchReply()`). */\n withResponse?: boolean;\n}\n\n/** What `update()` on a component interaction takes. */\nexport type InteractionUpdateOptions = InteractionReplyOptions;\n\n/** What `followUp()` takes. */\nexport type FollowUpOptions = InteractionReplyOptions;\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/** Fields for a forum or media channel tag. */\nexport interface ForumTagInput {\n name: string;\n /** Only moderators (Manage Threads) can apply it. */\n moderated?: boolean;\n emoji_id?: Snowflake | null;\n emoji_name?: string | null;\n}\n\n/** A role's colours: a solid colour, or a gradient or holographic style. */\nexport interface APIRoleColors {\n primary_color: number;\n secondary_color: number | null;\n tertiary_color: number | 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// ─── Guild welcome screen and onboarding ──────────────────────────────────────\n\n/** A channel shown on the welcome screen. */\nexport interface APIWelcomeScreenChannel {\n channel_id: Snowflake;\n description: string;\n emoji_id: Snowflake | null;\n emoji_name: string | null;\n}\n\n/** Raw Discord welcome screen. */\nexport interface APIWelcomeScreen {\n description: string | null;\n welcome_channels: APIWelcomeScreenChannel[];\n}\n\n/** One answer to an onboarding question. */\nexport interface APIOnboardingOption {\n id: Snowflake;\n channel_ids: Snowflake[];\n role_ids: Snowflake[];\n emoji?: APIPartialEmoji;\n title: string;\n description: string | null;\n}\n\n/** A question in a guild's onboarding. */\nexport interface APIOnboardingPrompt {\n id: Snowflake;\n type: number;\n options: APIOnboardingOption[];\n title: string;\n single_select: boolean;\n required: boolean;\n in_onboarding: boolean;\n}\n\n/** Raw Discord guild onboarding. */\nexport interface APIGuildOnboarding {\n guild_id: Snowflake;\n prompts: APIOnboardingPrompt[];\n default_channel_ids: Snowflake[];\n enabled: boolean;\n mode: number;\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 /** Gradient and holographic colours; `color` stays the primary colour. */\n colors?: APIRoleColors;\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 premium_progress_bar_enabled?: boolean;\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 /** Where the command can be used: 0 guilds, 1 the bot's DMs, 2 other DMs. */\n contexts?: number[];\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 /** Where the command can be used: 0 guilds, 1 the bot's DMs, 2 other DMs. */\n contexts?: number[];\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"
|
|
6
|
+
"// ─── 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 intents: an array of intent bits or names, e.g. `[GatewayIntentBits.Guilds, \"GuildMessages\"]`. A single number, name or OR-ed bitfield is not accepted. */\nexport type GatewayIntentResolvable = readonly (\n number | keyof typeof GatewayIntentBits | keyof typeof IntentBits | string\n)[];\n\n/**\n * Resolves an array of intents into a raw bitfield integer.\n * @throws {TypeError} If `intents` is not an array (an OR-ed number, a single name or a bitfield object).\n */\nexport function resolveGatewayIntents(\n intents: GatewayIntentResolvable,\n): number {\n if (!Array.isArray(intents))\n throw new TypeError(\n \"Gateway intents must be an array, e.g. [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages].\",\n );\n return intents.reduce<number>(\n (acc, intent) => acc | resolveIntent(intent),\n 0,\n );\n}\n\n/** Resolves one intent: a bitfield, an intent name in either casing, or a numeric string. */\nfunction resolveIntent(intent: number | string): number {\n if (typeof intent === \"number\") return intent;\n const bits: Record<string, number> = {\n ...IntentBits,\n ...GatewayIntentBits,\n };\n const lower = intent.charAt(0).toLowerCase() + intent.slice(1);\n if (Object.hasOwn(bits, intent)) return bits[intent]!;\n if (Object.hasOwn(bits, lower)) return bits[lower]!;\n const num = Number(intent);\n return Number.isNaN(num) ? 0 : num;\n}\n\n/** What `IntentsBitField` methods take: one intent or an array of them. Clients and gateways take only arrays. */\ntype IntentsInput = GatewayIntentResolvable[number] | GatewayIntentResolvable;\n\nfunction resolveInput(bits: IntentsInput): number {\n return resolveGatewayIntents(Array.isArray(bits) ? bits : [bits as number]);\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: IntentsInput = []) {\n this.bitfield = resolveInput(bits);\n }\n\n /** Whether every given intent is set. */\n public has(bits: IntentsInput): boolean {\n const resolved = resolveInput(bits);\n return (this.bitfield & resolved) === resolved;\n }\n\n /** Whether any given intent is set. */\n public any(bits: IntentsInput): boolean {\n return (this.bitfield & resolveInput(bits)) !== 0;\n }\n\n /** Adds intents in place. @returns This bitfield. */\n public add(...bits: IntentsInput[]): this {\n for (const bit of bits) this.bitfield |= resolveInput(bit);\n return this;\n }\n\n /** Removes intents in place. @returns This bitfield. */\n public remove(...bits: IntentsInput[]): this {\n for (const bit of bits) this.bitfield &= ~resolveInput(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: IntentsInput): boolean {\n return this.bitfield === resolveInput(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]: string | undefined;\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 /**\n * zlib-stream transport compression for the Gateway connection, about a\n * tenth of the inbound bandwidth. Shorthand for `gateway: { compress }`,\n * which wins when both are set. Off by default.\n */\n compress?: boolean;\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 /** Keep each member's latest presence (needs the `GuildPresences` intent). Off by default: it is a lot of data. */\n presences?: boolean;\n /** Most members kept per guild (least recently used leave first). Default: unbounded, so a big guild's member list stays whole. */\n maxMembers?: number;\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 /** zlib-stream transport compression; `ClientOptions.compress` is shorthand for this. */\n compress?: boolean;\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 /** Where requests go. Must be `https:` (or `http:` on this machine) with no credentials, query or fragment. */\n baseURL?: string;\n /** Allow a cleartext `http://` `baseURL` on a network you trust, such as a REST proxy. Default false. */\n allowInsecureBaseURL?: boolean;\n}\n",
|
|
7
|
+
"/** Discord API snowflake identifier. */\nexport type Snowflake = string;\n\nexport * from \"./channel-kind.js\";\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// ─── Message payloads ────────────────────────────────────────────────────────\n\n/** A Discord payload, or a builder that serialises to one (its `toJSON()` runs when the request is sent). */\nexport type Buildable<T> = T | { toJSON(): T };\n\n/**\n * A message Lunibee sends: channel send and edit, message reply and edit,\n * interaction replies, follow-ups and updates. Embeds and components may be\n * builders or raw objects. Other Discord fields pass through unchanged.\n */\nexport interface MessagePayload {\n content?: string;\n embeds?: Buildable<APIEmbed>[];\n components?: Buildable<APIMessageComponent>[];\n allowed_mentions?: import(\"./gateway.js\").AllowedMentions;\n /** Discord message flags, e.g. `MessageFlags.SuppressEmbeds`. */\n flags?: number;\n tts?: boolean;\n /** Attachment metadata for files sent with the message. */\n attachments?: Array<{\n id: number | string;\n filename?: string;\n description?: string;\n }>;\n [key: string]: unknown;\n}\n\n/** A file to upload with a message. */\nexport interface MessageFile {\n name: string;\n data: Blob | Uint8Array | ArrayBuffer | string;\n contentType?: string;\n /** Alt text, sent as the attachment's `description`. */\n description?: string;\n}\n/** A file whose bytes are read when the message is sent, such as a `CreateAttachment`. */\nexport interface MessageFileSource {\n name: string;\n description?: string;\n toBuffer(): Promise<Uint8Array>;\n}\n\n/** A poll to send; Discord fills in `results` and `expiry` when it is read back. */\nexport interface MessagePoll {\n question: { text?: string; emoji?: APIPartialEmoji };\n answers: Array<{ poll_media: { text?: string; emoji?: APIPartialEmoji } }>;\n /** Hours the poll stays open (1-768). */\n duration?: number;\n allow_multiselect?: boolean;\n layout_type?: number;\n}\n\n/** What `send()` takes. */\nexport interface MessageCreateOptions extends MessagePayload {\n /** Files to upload; the message is sent as multipart. */\n files?: (MessageFile | MessageFileSource)[];\n /** Reply to or forward another message. */\n message_reference?: APIMessageReference;\n poll?: MessagePoll;\n sticker_ids?: Snowflake[];\n /** Returned on the Gateway event so the client can match its own message. */\n nonce?: string | number;\n enforce_nonce?: boolean;\n}\n\n/** What `edit()` takes: the fields Discord lets you change after sending. */\nexport interface MessageEditOptions extends MessagePayload {\n files?: (MessageFile | MessageFileSource)[];\n}\n\n/** What a reply, edit-reply, follow-up or update to an interaction takes. */\nexport interface InteractionReplyOptions extends MessagePayload {\n /** Only the person who ran the command sees it. */\n ephemeral?: boolean;\n files?: (MessageFile | MessageFileSource)[];\n poll?: MessagePoll;\n /** On `reply()` / `update()`: return the created message (one request, no `fetchReply()`). */\n withResponse?: boolean;\n}\n\n/** What `update()` on a component interaction takes. */\nexport type InteractionUpdateOptions = InteractionReplyOptions;\n\n/** What `followUp()` takes. */\nexport type FollowUpOptions = InteractionReplyOptions;\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/** Fields for a forum or media channel tag. */\nexport interface ForumTagInput {\n name: string;\n /** Only moderators (Manage Threads) can apply it. */\n moderated?: boolean;\n emoji_id?: Snowflake | null;\n emoji_name?: string | null;\n}\n\n/** A role's colours: a solid colour, or a gradient or holographic style. */\nexport interface APIRoleColors {\n primary_color: number;\n secondary_color: number | null;\n tertiary_color: number | 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// ─── Guild welcome screen and onboarding ──────────────────────────────────────\n\n/** A channel shown on the welcome screen. */\nexport interface APIWelcomeScreenChannel {\n channel_id: Snowflake;\n description: string;\n emoji_id: Snowflake | null;\n emoji_name: string | null;\n}\n\n/** Raw Discord welcome screen. */\nexport interface APIWelcomeScreen {\n description: string | null;\n welcome_channels: APIWelcomeScreenChannel[];\n}\n\n/** One answer to an onboarding question. */\nexport interface APIOnboardingOption {\n id: Snowflake;\n channel_ids: Snowflake[];\n role_ids: Snowflake[];\n emoji?: APIPartialEmoji;\n title: string;\n description: string | null;\n}\n\n/** A question in a guild's onboarding. */\nexport interface APIOnboardingPrompt {\n id: Snowflake;\n type: number;\n options: APIOnboardingOption[];\n title: string;\n single_select: boolean;\n required: boolean;\n in_onboarding: boolean;\n}\n\n/** Raw Discord guild onboarding. */\nexport interface APIGuildOnboarding {\n guild_id: Snowflake;\n prompts: APIOnboardingPrompt[];\n default_channel_ids: Snowflake[];\n enabled: boolean;\n mode: number;\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 /** Gradient and holographic colours; `color` stays the primary colour. */\n colors?: APIRoleColors;\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 premium_progress_bar_enabled?: boolean;\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\n/** An activity in a presence (playing, streaming, listening, a custom status…). */\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 /** Where the command can be used: 0 guilds, 1 the bot's DMs, 2 other DMs. */\n contexts?: number[];\n nsfw?: boolean;\n version: Snowflake;\n}\n\n/** Data for creating/overwriting an application command. */\nexport interface ApplicationCommandData {\n name: string;\n /** Required for slash commands; user and message context-menu commands have none. */\n description?: string;\n type?: number;\n options?: APIApplicationCommandOption[];\n default_member_permissions?: string | null;\n /** Where the command can be used: 0 guilds, 1 the bot's DMs, 2 other DMs. */\n contexts?: number[];\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"
|
|
8
8
|
],
|
|
9
|
-
"mappings": ";;AAKO,IAAM,eAAe;AAAA,EACxB,MAAM,CAAC,CAAC;AAAA,EACR,IAAI,CAAC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B,UAAU;AAAA,EACV,OAAO;AACX;AAKO,IAAM,oBAAoB;AAAA,EAC7B,MAAM;AAAA,EACN,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,UAAU;AACd;AAGO,IAAM,cAAc;AAAA,EACvB,MAAM;AAAA,EACN,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AACX;AA4nBO,IAAM,eAAe;AAAA,EACxB,SAAS;AAAA,EACT,WAAW;AAAA,EACX,WAAW;AAAA,EACX,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,WAAW;AACf;AAmPO,IAAM,+BAA+B;AAAA,EACxC,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,EACT,MAAM;AAAA,EACN,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,YAAY;AAChB;AAMO,IAAM,yBAAyB;AAAA,EAClC,WAAW;AAAA,EACX,MAAM;AAAA,EACN,SAAS;AACb;",
|
|
10
10
|
"debugId": "32ECC6A3971AFBC464756E2164756E21",
|
|
11
11
|
"names": []
|
|
12
12
|
}
|
package/dist/utils/args.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export interface PrefixArgSpec {
|
|
|
14
14
|
/** For `integer` and `number`: the accepted range. */
|
|
15
15
|
min?: number;
|
|
16
16
|
max?: number;
|
|
17
|
-
/** Accepted values
|
|
17
|
+
/** Accepted values. Strings match without regard to case and are returned as the choice itself. */
|
|
18
18
|
choices?: readonly (string | number)[];
|
|
19
19
|
}
|
|
20
20
|
/** A mentionable argument: which kind of mention it was. An unmarked ID reads as a user. */
|
|
@@ -22,7 +22,9 @@ export interface MentionableArg {
|
|
|
22
22
|
id: string;
|
|
23
23
|
type: "user" | "role";
|
|
24
24
|
}
|
|
25
|
+
/** A parsed prefix-command argument: a string, number, boolean or mention. */
|
|
25
26
|
export type PrefixArgValue = string | number | boolean | MentionableArg;
|
|
27
|
+
/** The result of `parsePrefixArgs`: the parsed values, or the argument that failed and why. */
|
|
26
28
|
export type PrefixArgsResult = {
|
|
27
29
|
ok: true;
|
|
28
30
|
values: Record<string, PrefixArgValue | undefined>;
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
export declare function sleep(ms: number): Promise<void>;
|
|
3
3
|
/** Returns an integer between the supplied inclusive bounds. */
|
|
4
4
|
export declare function randomInt(min: number, max: number): number;
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Tests whether a value looks like a Discord snowflake: 16 to 20 digits. A
|
|
7
|
+
* snowflake is an unsigned 64-bit number, so it never has more than 20 digits;
|
|
8
|
+
* the minimum keeps short numbers in text from being read as IDs. (`Routes`
|
|
9
|
+
* only validates IDs it is given, so it accepts 1 to 20 digits.)
|
|
10
|
+
*/
|
|
6
11
|
export declare function isSnowflake(value: string): boolean;
|
|
7
12
|
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,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// packages/utils/src/args.ts
|
|
3
|
-
var SNOWFLAKE = /^\d{16,
|
|
3
|
+
var SNOWFLAKE = /^\d{16,20}$/;
|
|
4
4
|
var TRUE_WORDS = new Set([
|
|
5
5
|
"true",
|
|
6
6
|
"yes",
|
|
@@ -56,19 +56,19 @@ function tokenizeArgs(input) {
|
|
|
56
56
|
return args;
|
|
57
57
|
}
|
|
58
58
|
function parseUserMention(value) {
|
|
59
|
-
const id = /^<@!?(\d{16,
|
|
59
|
+
const id = /^<@!?(\d{16,20})>$/.exec(value)?.[1] ?? value;
|
|
60
60
|
return SNOWFLAKE.test(id) ? id : null;
|
|
61
61
|
}
|
|
62
62
|
function parseRoleMention(value) {
|
|
63
|
-
const id = /^<@&(\d{16,
|
|
63
|
+
const id = /^<@&(\d{16,20})>$/.exec(value)?.[1] ?? value;
|
|
64
64
|
return SNOWFLAKE.test(id) ? id : null;
|
|
65
65
|
}
|
|
66
66
|
function parseChannelMention(value) {
|
|
67
|
-
const id = /^<#(\d{16,
|
|
67
|
+
const id = /^<#(\d{16,20})>$/.exec(value)?.[1] ?? value;
|
|
68
68
|
return SNOWFLAKE.test(id) ? id : null;
|
|
69
69
|
}
|
|
70
70
|
function parseMentionable(value) {
|
|
71
|
-
const role = /^<@&(\d{16,
|
|
71
|
+
const role = /^<@&(\d{16,20})>$/.exec(value)?.[1];
|
|
72
72
|
if (role)
|
|
73
73
|
return { id: role, type: "role" };
|
|
74
74
|
const user = parseUserMention(value);
|
|
@@ -82,8 +82,15 @@ function readOne(spec, raw) {
|
|
|
82
82
|
return {
|
|
83
83
|
error: `must be at most ${spec.maxLength} characters`
|
|
84
84
|
};
|
|
85
|
-
if (spec.choices
|
|
86
|
-
|
|
85
|
+
if (spec.choices) {
|
|
86
|
+
const lower = raw.toLowerCase();
|
|
87
|
+
const choice = spec.choices.find((c) => String(c) === raw) ?? spec.choices.find((c) => String(c).toLowerCase() === lower);
|
|
88
|
+
if (choice === undefined)
|
|
89
|
+
return {
|
|
90
|
+
error: `must be one of: ${spec.choices.join(", ")}`
|
|
91
|
+
};
|
|
92
|
+
return { value: String(choice) };
|
|
93
|
+
}
|
|
87
94
|
return { value: raw };
|
|
88
95
|
case "integer":
|
|
89
96
|
case "number": {
|
|
@@ -128,7 +135,7 @@ function readOne(spec, raw) {
|
|
|
128
135
|
}
|
|
129
136
|
function parsePrefixArgs(input, specs) {
|
|
130
137
|
const args = typeof input === "string" ? tokenizeArgs(input) : [...input];
|
|
131
|
-
const values =
|
|
138
|
+
const values = Object.create(null);
|
|
132
139
|
let position = 0;
|
|
133
140
|
for (const [index, spec] of specs.entries()) {
|
|
134
141
|
if (spec.type === "rest" && index !== specs.length - 1)
|
|
@@ -188,7 +195,7 @@ function randomInt(min, max) {
|
|
|
188
195
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
189
196
|
}
|
|
190
197
|
function isSnowflake(value) {
|
|
191
|
-
return /^\d{16,
|
|
198
|
+
return /^\d{16,20}$/.test(value);
|
|
192
199
|
}
|
|
193
200
|
export {
|
|
194
201
|
argsFromCommandOptions,
|
|
@@ -203,4 +210,4 @@ export {
|
|
|
203
210
|
tokenizeArgs
|
|
204
211
|
};
|
|
205
212
|
|
|
206
|
-
//# debugId=
|
|
213
|
+
//# debugId=3DECF24F0FD567C064756E2164756E21
|
package/dist/utils/index.js.map
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../packages/utils/src/args.ts", "../../packages/utils/src/index.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * Prefix-command arguments: split a message into arguments and read them as\n * typed values, the way slash-command options are read.\n */\n\n/** What an argument is read as. `rest` takes everything left, as one string. */\nexport type PrefixArgType =\n | \"string\"\n | \"integer\"\n | \"number\"\n | \"boolean\"\n | \"user\"\n | \"role\"\n | \"channel\"\n | \"mentionable\"\n | \"rest\";\n\n/** One expected argument. */\nexport interface PrefixArgSpec {\n name: string;\n type: PrefixArgType;\n required?: boolean;\n /** For `string` and `rest`: the longest accepted value. */\n maxLength?: number;\n /** For `integer` and `number`: the accepted range. */\n min?: number;\n max?: number;\n /** Accepted values (compared case-insensitively for strings). */\n choices?: readonly (string | number)[];\n}\n\n/** A mentionable argument: which kind of mention it was. An unmarked ID reads as a user. */\nexport interface MentionableArg {\n id: string;\n type: \"user\" | \"role\";\n}\n\nexport type PrefixArgValue = string | number | boolean | MentionableArg;\n\nexport type PrefixArgsResult =\n | { ok: true; values: Record<string, PrefixArgValue | undefined> }\n | { ok: false; arg: string; error: string };\n\nconst SNOWFLAKE = /^\\d{16,22}$/;\nconst TRUE_WORDS = new Set([\n \"true\",\n \"yes\",\n \"y\",\n \"on\",\n \"1\",\n \"enable\",\n \"enabled\",\n]);\nconst FALSE_WORDS = new Set([\n \"false\",\n \"no\",\n \"n\",\n \"off\",\n \"0\",\n \"disable\",\n \"disabled\",\n]);\n\n/**\n * Splits text into arguments on whitespace. \"Double quotes\" or 'single quotes'\n * keep spaces inside one argument; a backslash escapes the next character.\n * @example tokenizeArgs(`ban @user \"being rude\"`) // [\"ban\", \"@user\", \"being rude\"]\n */\nexport function tokenizeArgs(input: string): string[] {\n const args: string[] = [];\n let current = \"\";\n let quote: string | null = null;\n let started = false;\n for (let index = 0; index < input.length; index++) {\n const character = input[index]!;\n if (character === \"\\\\\" && index + 1 < input.length) {\n current += input[++index];\n started = true;\n } else if (quote) {\n if (character === quote) quote = null;\n else current += character;\n } else if (character === '\"' || character === \"'\") {\n // A quote opens a quoted part only at the start of an argument.\n if (started) current += character;\n else {\n quote = character;\n started = true;\n }\n } else if (/\\s/.test(character)) {\n if (started) args.push(current);\n current = \"\";\n started = false;\n } else {\n current += character;\n started = true;\n }\n }\n if (started) args.push(current);\n return args;\n}\n\n/** The user ID in `<@id>`, `<@!id>` or a bare ID; null otherwise. */\nexport function parseUserMention(value: string): string | null {\n const id = /^<@!?(\\d{16,22})>$/.exec(value)?.[1] ?? value;\n return SNOWFLAKE.test(id) ? id : null;\n}\n\n/** The role ID in `<@&id>` or a bare ID; null otherwise. */\nexport function parseRoleMention(value: string): string | null {\n const id = /^<@&(\\d{16,22})>$/.exec(value)?.[1] ?? value;\n return SNOWFLAKE.test(id) ? id : null;\n}\n\n/** The channel ID in `<#id>` or a bare ID; null otherwise. */\nexport function parseChannelMention(value: string): string | null {\n const id = /^<#(\\d{16,22})>$/.exec(value)?.[1] ?? value;\n return SNOWFLAKE.test(id) ? id : null;\n}\n\n/** A user or role mention; a bare ID reads as a user. Null otherwise. */\nexport function parseMentionable(value: string): MentionableArg | null {\n const role = /^<@&(\\d{16,22})>$/.exec(value)?.[1];\n if (role) return { id: role, type: \"role\" };\n const user = parseUserMention(value);\n return user ? { id: user, type: \"user\" } : null;\n}\n\nfunction readOne(\n spec: PrefixArgSpec,\n raw: string,\n): { value: PrefixArgValue } | { error: string } {\n switch (spec.type) {\n case \"string\":\n case \"rest\":\n if (spec.maxLength !== undefined && raw.length > spec.maxLength)\n return {\n error: `must be at most ${spec.maxLength} characters`,\n };\n if (\n spec.choices &&\n !spec.choices.some(\n (choice) =>\n String(choice).toLowerCase() === raw.toLowerCase(),\n )\n )\n return { error: `must be one of: ${spec.choices.join(\", \")}` };\n return { value: raw };\n case \"integer\":\n case \"number\": {\n const value = Number(raw);\n if (!Number.isFinite(value) || raw.trim() === \"\")\n return { error: \"must be a number\" };\n if (spec.type === \"integer\" && !Number.isSafeInteger(value))\n return { error: \"must be a whole number\" };\n if (spec.min !== undefined && value < spec.min)\n return { error: `must be at least ${spec.min}` };\n if (spec.max !== undefined && value > spec.max)\n return { error: `must be at most ${spec.max}` };\n if (spec.choices && !spec.choices.includes(value))\n return { error: `must be one of: ${spec.choices.join(\", \")}` };\n return { value };\n }\n case \"boolean\": {\n const word = raw.toLowerCase();\n if (TRUE_WORDS.has(word)) return { value: true };\n if (FALSE_WORDS.has(word)) return { value: false };\n return { error: \"must be yes or no\" };\n }\n case \"user\": {\n const id = parseUserMention(raw);\n return id\n ? { value: id }\n : { error: \"must be a user mention or ID\" };\n }\n case \"role\": {\n const id = parseRoleMention(raw);\n return id\n ? { value: id }\n : { error: \"must be a role mention or ID\" };\n }\n case \"channel\": {\n const id = parseChannelMention(raw);\n return id\n ? { value: id }\n : { error: \"must be a channel mention or ID\" };\n }\n case \"mentionable\": {\n const value = parseMentionable(raw);\n return value\n ? { value }\n : { error: \"must be a user or role mention\" };\n }\n }\n}\n\n/**\n * Reads prefix-command arguments by position, as typed values. IDs come back\n * as strings (user, role, channel); a mentionable says which it was. The first\n * problem is reported, with the argument's name, instead of throwing.\n * @param input The text after the command name, or already-split arguments.\n * @param specs The expected arguments in order; a `rest` argument must be last.\n * @example\n * const result = parsePrefixArgs(`@user 10 spamming links`, [\n * { name: \"user\", type: \"user\", required: true },\n * { name: \"minutes\", type: \"integer\", min: 1, max: 40320 },\n * { name: \"reason\", type: \"rest\" },\n * ]);\n * if (!result.ok) return message.reply(`\\`${result.arg}\\` ${result.error}.`);\n */\nexport function parsePrefixArgs(\n input: string | readonly string[],\n specs: readonly PrefixArgSpec[],\n): PrefixArgsResult {\n const args = typeof input === \"string\" ? tokenizeArgs(input) : [...input];\n const values: Record<string, PrefixArgValue | undefined> = {};\n let position = 0;\n for (const [index, spec] of specs.entries()) {\n if (spec.type === \"rest\" && index !== specs.length - 1)\n throw new TypeError(\n `The rest argument \"${spec.name}\" must be the last one.`,\n );\n const raw =\n spec.type === \"rest\"\n ? args.slice(position).join(\" \")\n : args[position];\n if (raw === undefined || raw === \"\") {\n if (spec.required)\n return { ok: false, arg: spec.name, error: \"is required\" };\n values[spec.name] = undefined;\n continue;\n }\n const read = readOne(spec, raw);\n if (\"error\" in read)\n return { ok: false, arg: spec.name, error: read.error };\n values[spec.name] = read.value;\n position += spec.type === \"rest\" ? args.length : 1;\n }\n return { ok: true, values };\n}\n\n/** Discord application-command option types, as numbers (this package has no dependencies). */\nconst OPTION_TYPES: Readonly<Record<number, PrefixArgType>> = {\n 3: \"string\",\n 4: \"integer\",\n 5: \"boolean\",\n 6: \"user\",\n 7: \"channel\",\n 8: \"role\",\n 9: \"mentionable\",\n 10: \"number\",\n};\n\n/**\n * Argument specs from a slash command's options, so one definition serves both\n * `/command` and the prefix command. Subcommands and attachments are left out.\n * @param options The command's (or subcommand's) `options` as sent to Discord.\n * @param restLast Read the last string option as the rest of the message (handy for reasons).\n */\nexport function argsFromCommandOptions(\n options: readonly {\n name: string;\n type: number;\n required?: boolean;\n min_value?: number;\n max_value?: number;\n max_length?: number;\n choices?: readonly { value: string | number }[];\n }[],\n restLast = false,\n): PrefixArgSpec[] {\n const specs: PrefixArgSpec[] = [];\n for (const option of options) {\n const type = OPTION_TYPES[option.type];\n if (!type) continue;\n specs.push({\n name: option.name,\n type,\n required: option.required,\n min: option.min_value,\n max: option.max_value,\n maxLength: option.max_length,\n choices: option.choices?.map((choice) => choice.value),\n });\n }\n const last = specs[specs.length - 1];\n if (restLast && last?.type === \"string\") last.type = \"rest\";\n return specs;\n}\n",
|
|
6
|
-
"/** Returns a promise that resolves after the specified duration. */\nexport function sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/** Returns an integer between the supplied inclusive bounds. */\nexport function randomInt(min: number, max: number): number {\n return Math.floor(Math.random() * (max - min + 1)) + min;\n}\n\n
|
|
5
|
+
"/**\n * Prefix-command arguments: split a message into arguments and read them as\n * typed values, the way slash-command options are read.\n */\n\n/** What an argument is read as. `rest` takes everything left, as one string. */\nexport type PrefixArgType =\n | \"string\"\n | \"integer\"\n | \"number\"\n | \"boolean\"\n | \"user\"\n | \"role\"\n | \"channel\"\n | \"mentionable\"\n | \"rest\";\n\n/** One expected argument. */\nexport interface PrefixArgSpec {\n name: string;\n type: PrefixArgType;\n required?: boolean;\n /** For `string` and `rest`: the longest accepted value. */\n maxLength?: number;\n /** For `integer` and `number`: the accepted range. */\n min?: number;\n max?: number;\n /** Accepted values. Strings match without regard to case and are returned as the choice itself. */\n choices?: readonly (string | number)[];\n}\n\n/** A mentionable argument: which kind of mention it was. An unmarked ID reads as a user. */\nexport interface MentionableArg {\n id: string;\n type: \"user\" | \"role\";\n}\n\n/** A parsed prefix-command argument: a string, number, boolean or mention. */\nexport type PrefixArgValue = string | number | boolean | MentionableArg;\n\n/** The result of `parsePrefixArgs`: the parsed values, or the argument that failed and why. */\nexport type PrefixArgsResult =\n | { ok: true; values: Record<string, PrefixArgValue | undefined> }\n | { ok: false; arg: string; error: string };\n\nconst SNOWFLAKE = /^\\d{16,20}$/;\nconst TRUE_WORDS = new Set([\n \"true\",\n \"yes\",\n \"y\",\n \"on\",\n \"1\",\n \"enable\",\n \"enabled\",\n]);\nconst FALSE_WORDS = new Set([\n \"false\",\n \"no\",\n \"n\",\n \"off\",\n \"0\",\n \"disable\",\n \"disabled\",\n]);\n\n/**\n * Splits text into arguments on whitespace. \"Double quotes\" or 'single quotes'\n * keep spaces inside one argument; a backslash escapes the next character.\n * @example tokenizeArgs(`ban @user \"being rude\"`) // [\"ban\", \"@user\", \"being rude\"]\n */\nexport function tokenizeArgs(input: string): string[] {\n const args: string[] = [];\n let current = \"\";\n let quote: string | null = null;\n let started = false;\n for (let index = 0; index < input.length; index++) {\n const character = input[index]!;\n if (character === \"\\\\\" && index + 1 < input.length) {\n current += input[++index];\n started = true;\n } else if (quote) {\n if (character === quote) quote = null;\n else current += character;\n } else if (character === '\"' || character === \"'\") {\n // A quote opens a quoted part only at the start of an argument.\n if (started) current += character;\n else {\n quote = character;\n started = true;\n }\n } else if (/\\s/.test(character)) {\n if (started) args.push(current);\n current = \"\";\n started = false;\n } else {\n current += character;\n started = true;\n }\n }\n if (started) args.push(current);\n return args;\n}\n\n/** The user ID in `<@id>`, `<@!id>` or a bare ID; null otherwise. */\nexport function parseUserMention(value: string): string | null {\n const id = /^<@!?(\\d{16,20})>$/.exec(value)?.[1] ?? value;\n return SNOWFLAKE.test(id) ? id : null;\n}\n\n/** The role ID in `<@&id>` or a bare ID; null otherwise. */\nexport function parseRoleMention(value: string): string | null {\n const id = /^<@&(\\d{16,20})>$/.exec(value)?.[1] ?? value;\n return SNOWFLAKE.test(id) ? id : null;\n}\n\n/** The channel ID in `<#id>` or a bare ID; null otherwise. */\nexport function parseChannelMention(value: string): string | null {\n const id = /^<#(\\d{16,20})>$/.exec(value)?.[1] ?? value;\n return SNOWFLAKE.test(id) ? id : null;\n}\n\n/** A user or role mention; a bare ID reads as a user. Null otherwise. */\nexport function parseMentionable(value: string): MentionableArg | null {\n const role = /^<@&(\\d{16,20})>$/.exec(value)?.[1];\n if (role) return { id: role, type: \"role\" };\n const user = parseUserMention(value);\n return user ? { id: user, type: \"user\" } : null;\n}\n\nfunction readOne(\n spec: PrefixArgSpec,\n raw: string,\n): { value: PrefixArgValue } | { error: string } {\n switch (spec.type) {\n case \"string\":\n case \"rest\":\n if (spec.maxLength !== undefined && raw.length > spec.maxLength)\n return {\n error: `must be at most ${spec.maxLength} characters`,\n };\n if (spec.choices) {\n // Matched without regard to case, but the handler gets the\n // choice itself: code that compares it exactly (as its type\n // says it may) must not see \"ALL\" where it expects \"all\".\n const lower = raw.toLowerCase();\n const choice =\n spec.choices.find((c) => String(c) === raw) ??\n spec.choices.find((c) => String(c).toLowerCase() === lower);\n if (choice === undefined)\n return {\n error: `must be one of: ${spec.choices.join(\", \")}`,\n };\n return { value: String(choice) };\n }\n return { value: raw };\n case \"integer\":\n case \"number\": {\n const value = Number(raw);\n if (!Number.isFinite(value) || raw.trim() === \"\")\n return { error: \"must be a number\" };\n if (spec.type === \"integer\" && !Number.isSafeInteger(value))\n return { error: \"must be a whole number\" };\n if (spec.min !== undefined && value < spec.min)\n return { error: `must be at least ${spec.min}` };\n if (spec.max !== undefined && value > spec.max)\n return { error: `must be at most ${spec.max}` };\n if (spec.choices && !spec.choices.includes(value))\n return { error: `must be one of: ${spec.choices.join(\", \")}` };\n return { value };\n }\n case \"boolean\": {\n const word = raw.toLowerCase();\n if (TRUE_WORDS.has(word)) return { value: true };\n if (FALSE_WORDS.has(word)) return { value: false };\n return { error: \"must be yes or no\" };\n }\n case \"user\": {\n const id = parseUserMention(raw);\n return id\n ? { value: id }\n : { error: \"must be a user mention or ID\" };\n }\n case \"role\": {\n const id = parseRoleMention(raw);\n return id\n ? { value: id }\n : { error: \"must be a role mention or ID\" };\n }\n case \"channel\": {\n const id = parseChannelMention(raw);\n return id\n ? { value: id }\n : { error: \"must be a channel mention or ID\" };\n }\n case \"mentionable\": {\n const value = parseMentionable(raw);\n return value\n ? { value }\n : { error: \"must be a user or role mention\" };\n }\n }\n}\n\n/**\n * Reads prefix-command arguments by position, as typed values. IDs come back\n * as strings (user, role, channel); a mentionable says which it was. The first\n * problem is reported, with the argument's name, instead of throwing.\n * @param input The text after the command name, or already-split arguments.\n * @param specs The expected arguments in order; a `rest` argument must be last.\n * @example\n * const result = parsePrefixArgs(`@user 10 spamming links`, [\n * { name: \"user\", type: \"user\", required: true },\n * { name: \"minutes\", type: \"integer\", min: 1, max: 40320 },\n * { name: \"reason\", type: \"rest\" },\n * ]);\n * if (!result.ok) return message.reply(`\\`${result.arg}\\` ${result.error}.`);\n */\nexport function parsePrefixArgs(\n input: string | readonly string[],\n specs: readonly PrefixArgSpec[],\n): PrefixArgsResult {\n const args = typeof input === \"string\" ? tokenizeArgs(input) : [...input];\n const values: Record<string, PrefixArgValue | undefined> =\n Object.create(null);\n let position = 0;\n for (const [index, spec] of specs.entries()) {\n if (spec.type === \"rest\" && index !== specs.length - 1)\n throw new TypeError(\n `The rest argument \"${spec.name}\" must be the last one.`,\n );\n const raw =\n spec.type === \"rest\"\n ? args.slice(position).join(\" \")\n : args[position];\n if (raw === undefined || raw === \"\") {\n if (spec.required)\n return { ok: false, arg: spec.name, error: \"is required\" };\n values[spec.name] = undefined;\n continue;\n }\n const read = readOne(spec, raw);\n if (\"error\" in read)\n return { ok: false, arg: spec.name, error: read.error };\n values[spec.name] = read.value;\n position += spec.type === \"rest\" ? args.length : 1;\n }\n return { ok: true, values };\n}\n\n/** Discord application-command option types, as numbers (this package has no dependencies). */\nconst OPTION_TYPES: Readonly<Record<number, PrefixArgType>> = {\n 3: \"string\",\n 4: \"integer\",\n 5: \"boolean\",\n 6: \"user\",\n 7: \"channel\",\n 8: \"role\",\n 9: \"mentionable\",\n 10: \"number\",\n};\n\n/**\n * Argument specs from a slash command's options, so one definition serves both\n * `/command` and the prefix command. Subcommands and attachments are left out.\n * @param options The command's (or subcommand's) `options` as sent to Discord.\n * @param restLast Read the last string option as the rest of the message (handy for reasons).\n */\nexport function argsFromCommandOptions(\n options: readonly {\n name: string;\n type: number;\n required?: boolean;\n min_value?: number;\n max_value?: number;\n max_length?: number;\n choices?: readonly { value: string | number }[];\n }[],\n restLast = false,\n): PrefixArgSpec[] {\n const specs: PrefixArgSpec[] = [];\n for (const option of options) {\n const type = OPTION_TYPES[option.type];\n if (!type) continue;\n specs.push({\n name: option.name,\n type,\n required: option.required,\n min: option.min_value,\n max: option.max_value,\n maxLength: option.max_length,\n choices: option.choices?.map((choice) => choice.value),\n });\n }\n const last = specs[specs.length - 1];\n if (restLast && last?.type === \"string\") last.type = \"rest\";\n return specs;\n}\n",
|
|
6
|
+
"/** Returns a promise that resolves after the specified duration. */\nexport function sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/** Returns an integer between the supplied inclusive bounds. */\nexport function randomInt(min: number, max: number): number {\n return Math.floor(Math.random() * (max - min + 1)) + min;\n}\n\n/**\n * Tests whether a value looks like a Discord snowflake: 16 to 20 digits. A\n * snowflake is an unsigned 64-bit number, so it never has more than 20 digits;\n * the minimum keeps short numbers in text from being read as IDs. (`Routes`\n * only validates IDs it is given, so it accepts 1 to 20 digits.)\n */\nexport function isSnowflake(value: string): boolean {\n return /^\\d{16,20}$/.test(value);\n}\n\nexport {\n tokenizeArgs,\n parsePrefixArgs,\n argsFromCommandOptions,\n parseUserMention,\n parseRoleMention,\n parseChannelMention,\n parseMentionable,\n type PrefixArgType,\n type PrefixArgSpec,\n type PrefixArgValue,\n type PrefixArgsResult,\n type MentionableArg,\n} from \"./args.js\";\n"
|
|
7
7
|
],
|
|
8
|
-
"mappings": ";;
|
|
9
|
-
"debugId": "
|
|
8
|
+
"mappings": ";;AA6CA,IAAM,YAAY;AAClB,IAAM,aAAa,IAAI,IAAI;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ,CAAC;AACD,IAAM,cAAc,IAAI,IAAI;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ,CAAC;AAOM,SAAS,YAAY,C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A,MACZ,KAAK,OAAO;AAAA,MACZ,WAAW,OAAO;AAAA,MAClB,SAAS,OAAO,SAAS,IAAI,CAAC,WAAW,OAAO,KAAK;AAAA,IACzD,CAAC;AAAA,EACL;AAAA,EACA,MAAM,OAAO,MAAM,MAAM,SAAS;AAAA,EAClC,IAAI,YAAY,MAAM,SAAS;AAAA,IAAU,KAAK,OAAO;AAAA,EACrD,OAAO;AAAA;;;ACtSJ,SAAS,KAAK,CAAC,IAA2B;AAAA,EAC7C,OAAO,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,EAAE,CAAC;AAAA;AAIpD,SAAS,SAAS,CAAC,KAAa,KAAqB;AAAA,EACxD,OAAO,KAAK,MAAM,KAAK,OAAO,KAAK,MAAM,MAAM,EAAE,IAAI;AAAA;AASlD,SAAS,WAAW,CAAC,OAAwB;AAAA,EAChD,OAAO,cAAc,KAAK,KAAK;AAAA;",
|
|
9
|
+
"debugId": "3DECF24F0FD567C064756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
package/dist/voice/index.d.ts
CHANGED
|
@@ -100,7 +100,11 @@ export declare class VoiceConnection {
|
|
|
100
100
|
selfDeaf?: boolean;
|
|
101
101
|
}): void;
|
|
102
102
|
/** Publishes a speaking state through the attached voice gateway. @param flags Speaking flags. @returns Nothing. @throws {VoiceError} If the connection is destroyed or has no gateway transport. */
|
|
103
|
-
|
|
103
|
+
/**
|
|
104
|
+
* Sends a speaking update (voice op 5). Pass the `ssrc` your voice gateway
|
|
105
|
+
* assigned in READY; Discord uses it to match the audio to this user.
|
|
106
|
+
*/
|
|
107
|
+
setSpeaking(flags?: number, ssrc?: number): void;
|
|
104
108
|
/** Ensures the connection is still usable. @returns Nothing. @throws {VoiceError} If destroyed. */
|
|
105
109
|
private assertUsable;
|
|
106
110
|
}
|
|
@@ -199,6 +203,8 @@ export { VoiceConnectionState as VoiceConnectionStatus };
|
|
|
199
203
|
* Joins (or moves to) a voice channel, reusing the guild's tracked connection.
|
|
200
204
|
* Mirrors `@discordjs/voice`'s `joinVoiceChannel`; transports are still attached
|
|
201
205
|
* with {@link VoiceConnection.attachTransports}.
|
|
206
|
+
* The connection stays tracked after `disconnect()` (a later join reuses it) and
|
|
207
|
+
* leaves the registry only on `destroy()`.
|
|
202
208
|
* @param options Guild, channel and self mute/deaf flags.
|
|
203
209
|
* @returns The guild's voice connection.
|
|
204
210
|
* @throws {TypeError} If the guild or channel ID is empty.
|