lunibee 0.3.3 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/README.md +1 -1
  2. package/dist/builders/commands.d.ts +1 -1
  3. package/dist/builders/components.d.ts +9 -11
  4. package/dist/builders/embed.d.ts +1 -1
  5. package/dist/builders/index.d.ts +1 -1
  6. package/dist/builders/index.js +87 -1298
  7. package/dist/builders/index.js.map +3 -11
  8. package/dist/chunks/index-0wn81eng.js +2492 -0
  9. package/dist/chunks/index-0wn81eng.js.map +17 -0
  10. package/dist/chunks/index-2en489j6.js +40 -0
  11. package/dist/chunks/index-2en489j6.js.map +10 -0
  12. package/dist/chunks/index-3hyps48a.js +203 -0
  13. package/dist/chunks/index-3hyps48a.js.map +11 -0
  14. package/dist/chunks/index-57c5n3ms.js +2274 -0
  15. package/dist/chunks/index-57c5n3ms.js.map +19 -0
  16. package/dist/chunks/index-5yx92e36.js +1170 -0
  17. package/dist/chunks/index-5yx92e36.js.map +14 -0
  18. package/dist/chunks/index-690bp093.js +95 -0
  19. package/dist/chunks/index-690bp093.js.map +10 -0
  20. package/dist/chunks/index-7fp2hvmg.js +2155 -0
  21. package/dist/chunks/index-7fp2hvmg.js.map +24 -0
  22. package/dist/chunks/index-cnmsajvk.js +1119 -0
  23. package/dist/chunks/index-cnmsajvk.js.map +12 -0
  24. package/dist/chunks/index-fdvgk2sw.js +1310 -0
  25. package/dist/chunks/index-fdvgk2sw.js.map +21 -0
  26. package/dist/chunks/index-gyvps8b9.js +214 -0
  27. package/dist/chunks/index-gyvps8b9.js.map +12 -0
  28. package/dist/chunks/index-jzg4bh99.js +1533 -0
  29. package/dist/chunks/index-jzg4bh99.js.map +21 -0
  30. package/dist/chunks/index-mgw2yvrm.js +3547 -0
  31. package/dist/chunks/index-mgw2yvrm.js.map +25 -0
  32. package/dist/chunks/index-yh76b55h.js +3449 -0
  33. package/dist/chunks/index-yh76b55h.js.map +29 -0
  34. package/dist/collection/index.js +9 -1118
  35. package/dist/collection/index.js.map +3 -6
  36. package/dist/core/api.d.ts +3 -3
  37. package/dist/core/channel-create.d.ts +2 -2
  38. package/dist/core/commands.d.ts +3 -3
  39. package/dist/core/events.d.ts +4 -4
  40. package/dist/core/handles.d.ts +4 -4
  41. package/dist/core/index.d.ts +25 -20
  42. package/dist/core/index.js +68 -10130
  43. package/dist/core/index.js.map +3 -65
  44. package/dist/core/permissions.d.ts +1 -1
  45. package/dist/core/redis-cache.d.ts +1 -1
  46. package/dist/formatters/index.js +41 -110
  47. package/dist/formatters/index.js.map +3 -4
  48. package/dist/handlers/index.js +5 -37
  49. package/dist/handlers/index.js.map +3 -4
  50. package/dist/index.d.ts +21 -21
  51. package/dist/index.js +641 -16325
  52. package/dist/index.js.map +3 -92
  53. package/dist/managers/advanced.d.ts +3 -3
  54. package/dist/managers/application.d.ts +2 -2
  55. package/dist/managers/base.d.ts +1 -1
  56. package/dist/managers/emoji.d.ts +2 -2
  57. package/dist/managers/guild-resources.d.ts +6 -6
  58. package/dist/managers/guild.d.ts +3 -3
  59. package/dist/managers/index.d.ts +4 -8
  60. package/dist/managers/index.js +51 -4060
  61. package/dist/managers/index.js.map +3 -29
  62. package/dist/managers/member.d.ts +2 -2
  63. package/dist/managers/message.d.ts +14 -6
  64. package/dist/managers/role.d.ts +2 -2
  65. package/dist/managers/thread.d.ts +3 -3
  66. package/dist/managers/user.d.ts +7 -4
  67. package/dist/rest/index.d.ts +10 -35
  68. package/dist/rest/index.js +57 -2184
  69. package/dist/rest/index.js.map +3 -18
  70. package/dist/rest/limiter.d.ts +9 -1
  71. package/dist/rest/webhook.d.ts +2 -8
  72. package/dist/sharding/bus.d.ts +2 -2
  73. package/dist/sharding/cluster.d.ts +45 -5
  74. package/dist/sharding/context.d.ts +45 -3
  75. package/dist/sharding/gateway-bot.d.ts +2 -1
  76. package/dist/sharding/health.d.ts +1 -1
  77. package/dist/sharding/identify.d.ts +12 -0
  78. package/dist/sharding/index.d.ts +44 -11
  79. package/dist/sharding/index.js +60 -4620
  80. package/dist/sharding/index.js.map +3 -33
  81. package/dist/sharding/supervisor.d.ts +4 -2
  82. package/dist/structures/audit-log.d.ts +1 -1
  83. package/dist/structures/base.d.ts +6 -6
  84. package/dist/structures/channels.d.ts +1 -1
  85. package/dist/structures/embed.d.ts +1 -1
  86. package/dist/structures/index.d.ts +14 -14
  87. package/dist/structures/index.js +109 -2382
  88. package/dist/structures/index.js.map +3 -16
  89. package/dist/structures/interactions.d.ts +13 -9
  90. package/dist/structures/options.d.ts +1 -1
  91. package/dist/structures/permissions.d.ts +2 -2
  92. package/dist/structures/resources.d.ts +10 -10
  93. package/dist/structures/sticker.d.ts +1 -1
  94. package/dist/types/gateway.d.ts +2 -79
  95. package/dist/types/index.d.ts +0 -6
  96. package/dist/types/index.js +41 -272
  97. package/dist/types/index.js.map +3 -6
  98. package/dist/utils/index.js +23 -209
  99. package/dist/utils/index.js.map +3 -5
  100. package/dist/voice/connection.d.ts +200 -0
  101. package/dist/voice/crypto.d.ts +50 -0
  102. package/dist/voice/dave.d.ts +85 -0
  103. package/dist/voice/effects.d.ts +31 -0
  104. package/dist/voice/emitter.d.ts +14 -0
  105. package/dist/voice/gateway.d.ts +59 -0
  106. package/dist/voice/index.d.ts +25 -228
  107. package/dist/voice/index.js +111 -442
  108. package/dist/voice/index.js.map +3 -4
  109. package/dist/voice/libopus.d.ts +88 -0
  110. package/dist/voice/networking.d.ts +80 -0
  111. package/dist/voice/ogg.d.ts +24 -0
  112. package/dist/voice/opus.d.ts +18 -0
  113. package/dist/voice/player.d.ts +79 -0
  114. package/dist/voice/protocol.d.ts +76 -0
  115. package/dist/voice/receiver.d.ts +59 -0
  116. package/dist/voice/resource.d.ts +102 -0
  117. package/dist/voice/udp.d.ts +40 -0
  118. package/dist/ws/close-codes.d.ts +1 -1
  119. package/dist/ws/index.d.ts +25 -4
  120. package/dist/ws/index.js +47 -1336
  121. package/dist/ws/index.js.map +3 -17
  122. package/dist/ws/protocol.d.ts +1 -1
  123. package/dist/ws/send-budget.d.ts +0 -2
  124. package/dist/ws/state.d.ts +0 -10
  125. package/package.json +19 -16
@@ -0,0 +1,14 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../packages/builders/src/clone.ts", "../packages/builders/src/embed.ts", "../packages/builders/src/components.ts", "../packages/builders/src/commands.ts", "../packages/builders/src/attachment.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * A deep copy of builder data, for `toJSON()`.\n *\n * Builder payloads are plain JSON: objects, arrays and primitives. Copying\n * those directly is several times faster than `structuredClone` on the small\n * payloads builders hold. Anything else (a Date, a Map, a class instance) and\n * anything nested deeper than 64 levels (a cycle) goes to `structuredClone`,\n * so the result is what `structuredClone` would give.\n */\nexport function cloneData<T>(value: T, depth = 0): T {\n if (value === null || typeof value !== \"object\") return value;\n if (depth > 64) return structuredClone(value);\n if (Array.isArray(value)) {\n const out = new Array(value.length);\n for (let i = 0; i < value.length; i++)\n out[i] = cloneData(value[i], depth + 1);\n return out as T;\n }\n const proto = Object.getPrototypeOf(value);\n if (proto !== Object.prototype && proto !== null)\n return structuredClone(value);\n const from = value as Record<string, unknown>;\n const out: Record<string, unknown> = {};\n for (const key of Object.keys(from))\n out[key] = cloneData(from[key], depth + 1);\n return out as T;\n}\n",
6
+ "import { cloneData } from \"./clone.js\";\n/** Discord API embed field payload. */\nexport interface EmbedField {\n /** Field name. */\n name: string;\n /** Field value. */\n value: string;\n /** Whether the field is displayed inline. */\n inline?: boolean;\n}\n/** Discord API embed footer payload. */\nexport interface EmbedFooter {\n /** Footer text. */\n text: string;\n /** Footer icon URL. */\n icon_url?: string;\n}\n/** Discord API embed author payload. */\nexport interface EmbedAuthor {\n /** Author display name. */\n name: string;\n /** Author URL. */\n url?: string;\n /** Author icon URL. */\n icon_url?: string;\n}\n/** Strict Discord API embed payload. */\nexport interface APIEmbed {\n /** Embed title. */\n title?: string;\n /** Embed description. */\n description?: string;\n /** Embed URL. */\n url?: string;\n /** Embed color. */\n color?: number;\n /** ISO-8601 timestamp. */\n timestamp?: string;\n /** Embed footer. */\n footer?: EmbedFooter;\n /** Embed author. */\n author?: EmbedAuthor;\n /** Thumbnail payload. */\n thumbnail?: { /** Thumbnail URL. */ url: string };\n /** Image payload. */\n image?: { /** Image URL. */ url: string };\n /** Embed fields. */\n fields?: EmbedField[];\n}\n\n/** Builds compile-time-safe rich embed payloads for Discord API requests. */\nexport class CreateEmbed {\n readonly #data: APIEmbed = {};\n /** Sets the embed title. @param value Title text, or null to clear. @returns This builder. @throws {RangeError} If title exceeds Discord's limit. */\n public setTitle(value: string | null): this {\n if (value === null) delete this.#data.title;\n else this.#data.title = validate(value, 256, \"Embed title\");\n return this;\n }\n /** Sets the embed description. @param value Description text, or null to clear. @returns This builder. @throws {RangeError} If description exceeds Discord's limit. */\n public setDescription(value: string | null): this {\n if (value === null) delete this.#data.description;\n else\n this.#data.description = validate(value, 4096, \"Embed description\");\n return this;\n }\n /** Sets the embed URL. @param value Absolute URL, or null to clear. @returns This builder. @throws {TypeError} If URL is invalid. */\n public setURL(value: string | null): this {\n if (value === null) delete this.#data.url;\n else this.#data.url = url(value, \"Embed URL\");\n return this;\n }\n /** Sets the embed color. @param value RGB integer. @returns This builder. @throws {RangeError} If color is outside 24-bit RGB range. */\n public setColor(value: number): this {\n if (!Number.isInteger(value) || value < 0 || value > 0xffffff)\n throw new RangeError(\n \"Embed color must be an integer between 0 and 16777215.\",\n );\n this.#data.color = value;\n return this;\n }\n /** Sets the embed timestamp. @param value Date value. @returns This builder. @throws {RangeError} If date is invalid. */\n public setTimestamp(value = new Date()): this {\n const date = value instanceof Date ? value : new Date(value);\n if (Number.isNaN(date.getTime()))\n throw new RangeError(\"Embed timestamp must be a valid date.\");\n this.#data.timestamp = date.toISOString();\n return this;\n }\n /** Sets the embed footer. @param value Footer payload. @returns This builder. @throws {RangeError} If footer text exceeds Discord's limit. */\n public setFooter(value: EmbedFooter): this {\n this.#data.footer = {\n text: validate(value.text, 2048, \"Footer text\"),\n ...(value.icon_url\n ? { icon_url: url(value.icon_url, \"Footer icon URL\") }\n : {}),\n };\n return this;\n }\n /** Sets the embed author. @param value Author payload. @returns This builder. @throws {RangeError} If author name exceeds Discord's limit. */\n public setAuthor(value: EmbedAuthor): this {\n this.#data.author = {\n name: validate(value.name, 256, \"Author name\"),\n ...(value.url ? { url: url(value.url, \"Author URL\") } : {}),\n ...(value.icon_url\n ? { icon_url: url(value.icon_url, \"Author icon URL\") }\n : {}),\n };\n return this;\n }\n /** Sets the thumbnail URL. @param value Thumbnail URL or payload, or null to clear. @returns This builder. @throws {TypeError} If URL is invalid. */\n public setThumbnail(value: { url: string } | string | null): this {\n if (value === null) {\n delete this.#data.thumbnail;\n return this;\n }\n const valueURL = typeof value === \"string\" ? value : value.url;\n this.#data.thumbnail = { url: url(valueURL, \"Thumbnail URL\") };\n return this;\n }\n /** Sets the image URL. @param value Image URL or payload, or null to clear. @returns This builder. @throws {TypeError} If URL is invalid. */\n public setImage(value: { url: string } | string | null): this {\n if (value === null) {\n delete this.#data.image;\n return this;\n }\n const valueURL = typeof value === \"string\" ? value : value.url;\n this.#data.image = { url: url(valueURL, \"Image URL\") };\n return this;\n }\n /** Adds embed fields. Accepts both the spread form `addFields(a, b)` and the\n * single-array form `addFields([a, b])`.\n * @param fields Field payloads, spread or as a single array. @returns This builder. @throws {RangeError} If the 25-field limit is exceeded. */\n public addFields(...fields: EmbedField[] | [EmbedField[]]): this {\n const resolved = (\n fields.length === 1 && Array.isArray(fields[0]) ? fields[0] : fields\n ) as EmbedField[];\n if (!resolved.length)\n throw new TypeError(\"At least one embed field is required.\");\n const current = this.#data.fields ?? [];\n if (current.length + resolved.length > 25)\n throw new RangeError(\n \"An embed cannot contain more than 25 fields.\",\n );\n for (const field of resolved) {\n validate(field.name, 256, \"Embed field name\");\n validate(field.value, 1024, \"Embed field value\");\n }\n this.#data.fields = [\n ...current,\n ...resolved.map((field) => ({ ...field })),\n ];\n return this;\n }\n public setFields(fields: EmbedField[]): this {\n this.#data.fields = [];\n return this.addFields(...fields);\n }\n /** Replaces fields starting at an index. @param index Start index. @param deleteCount Number of fields to remove. @param fields Replacement fields. @returns This builder. @throws {RangeError} If arguments are invalid or the 25-field limit is exceeded. */\n public spliceFields(\n index: number,\n deleteCount: number,\n ...fields: EmbedField[]\n ): this {\n const current = [...(this.#data.fields ?? [])];\n if (\n !Number.isInteger(index) ||\n !Number.isInteger(deleteCount) ||\n index < 0 ||\n deleteCount < 0\n )\n throw new RangeError(\n \"Field index and delete count must be non-negative integers.\",\n );\n for (const field of fields) {\n validate(field.name, 256, \"Embed field name\");\n validate(field.value, 1024, \"Embed field value\");\n }\n current.splice(index, deleteCount, ...fields.map((f) => ({ ...f })));\n if (current.length > 25)\n throw new RangeError(\n \"An embed cannot contain more than 25 fields.\",\n );\n this.#data.fields = current;\n return this;\n }\n /** Removes all embed fields. @returns This builder. */\n public clearFields(): this {\n delete this.#data.fields;\n return this;\n }\n /** Removes the embed title. @returns This builder. */\n public clearTitle(): this {\n delete this.#data.title;\n return this;\n }\n /** Removes the embed description. @returns This builder. */\n public clearDescription(): this {\n delete this.#data.description;\n return this;\n }\n /** Returns a deep-cloned Discord API payload. @returns Strict embed payload. */\n public get data(): APIEmbed {\n return this.toJSON();\n }\n /** Returns a deep-cloned Discord API payload. @returns Strict embed payload. @throws {RangeError} If the text in the embed adds up to more than Discord's 6000-character limit. */\n public toJSON(): APIEmbed {\n const data = this.#data;\n const total =\n (data.title?.length ?? 0) +\n (data.description?.length ?? 0) +\n (data.footer?.text.length ?? 0) +\n (data.author?.name.length ?? 0) +\n (data.fields ?? []).reduce(\n (sum, field) => sum + field.name.length + field.value.length,\n 0,\n );\n if (total > 6000)\n throw new RangeError(\n `An embed cannot contain more than 6000 characters in total (this one has ${total}).`,\n );\n return cloneData(data);\n }\n}\n/** Validates a bounded Discord string field. @param value Field value. @param max Maximum length. @param field Human-readable field name. @returns Validated value. @throws {RangeError} If length is invalid. */\nfunction validate(value: string, max: number, field: string): string {\n if (typeof value !== \"string\" || value.length === 0 || value.length > max)\n throw new RangeError(`${field} must contain 1-${max} characters.`);\n return value;\n}\n/** Validates and normalizes an absolute URL. @param value URL value. @param field Human-readable field name. @returns Normalized URL. @throws {TypeError} If URL is invalid. */\nfunction url(value: string, field: string): string {\n let parsed: URL;\n try {\n parsed = new URL(value);\n } catch (error) {\n throw new TypeError(`${field} must be a valid URL.`, { cause: error });\n }\n // `attachment://` points an image at an uploaded file.\n if (![\"http:\", \"https:\", \"attachment:\"].includes(parsed.protocol))\n throw new TypeError(`${field} must use http, https or attachment.`);\n return parsed.toString();\n}\n",
7
+ "import { cloneData } from \"./clone.js\";\nimport { ButtonType, ComponentEnum } from \"@lunibee/types\";\nexport { ButtonType, ComponentEnum };\n\nexport const TextInputType = { Short: 1, Paragraph: 2 } as const;\n/** One {@link TextInputType} value, usable as a type. */\nexport type TextInputType = (typeof TextInputType)[keyof typeof TextInputType];\n/** An emoji on a button or select option: a custom emoji `id`, or a Unicode `name`. */\nexport interface APIComponentEmoji {\n id?: string | null;\n name?: string | null;\n animated?: boolean;\n}\n/** A button as a builder sends it. Exported from `lunibee` as `APIButtonPayload`. */\nexport interface APIButtonComponent {\n type: typeof ComponentEnum.Button;\n style: 1 | 2 | 3 | 4 | 5 | 6;\n custom_id?: string;\n label?: string;\n emoji?: APIComponentEmoji;\n url?: string;\n /** SKU for premium (style 6) buttons. */\n sku_id?: string;\n disabled?: boolean;\n}\n/** One option of a string select menu. */\nexport interface APISelectOption {\n label: string;\n value: string;\n description?: string;\n emoji?: APIComponentEmoji;\n default?: boolean;\n}\n/** A string select menu (component type 3) as Discord receives it. */\nexport interface APIStringSelectComponent {\n type: typeof ComponentEnum.StringSelect;\n custom_id?: string;\n placeholder?: string;\n min_values?: number;\n max_values?: number;\n required?: boolean;\n disabled?: boolean;\n options?: APISelectOption[];\n}\n/** A user, role, mentionable or channel select menu as Discord receives it. */\nexport interface APIEntitySelectComponent {\n type:\n | typeof ComponentEnum.UserSelect\n | typeof ComponentEnum.RoleSelect\n | typeof ComponentEnum.MentionableSelect\n | typeof ComponentEnum.ChannelSelect;\n custom_id?: string;\n placeholder?: string;\n min_values?: number;\n max_values?: number;\n required?: boolean;\n disabled?: boolean;\n default_values?: APISelectDefaultValue[];\n}\n/** A modal text input as a builder sends it. Exported from `lunibee` as `APITextInputPayload`. */\nexport interface APITextInputComponent {\n type: typeof ComponentEnum.TextInput;\n style: typeof TextInputType.Short | typeof TextInputType.Paragraph;\n custom_id?: string;\n label?: string;\n placeholder?: string;\n min_length?: number;\n max_length?: number;\n required?: boolean;\n value?: string;\n}\n/** A modal (callback type 9 data): title, custom ID and its components. */\nexport interface APIModalComponent {\n type: 9;\n custom_id: string;\n title: string;\n components: APIActionRowComponent[];\n}\n/** Any component an action row can hold: a button, a select menu or a text input. */\nexport type APIActionRowChild =\n | APIButtonComponent\n | APIStringSelectComponent\n | APIEntitySelectComponent\n | APITextInputComponent;\n/** An action row as a builder sends it: up to five buttons, or one select menu or text input. Exported from `lunibee` as `APIActionRowPayload`. */\nexport interface APIActionRowComponent {\n type: typeof ComponentEnum.ActionRow;\n components: APIActionRowChild[];\n}\n/** A Components V2 section: up to three text displays with an accessory. */\nexport interface APISectionComponent {\n type: typeof ComponentEnum.Section;\n components?: APIComponent[]; // text displays\n accessory?: APIComponent; // buttons, thumbnails, etc.\n}\n/** A Components V2 text display (Markdown content). */\nexport interface APITextDisplayComponent {\n type: typeof ComponentEnum.TextDisplay;\n content: string;\n}\n/** A Components V2 media gallery; each item is `{ media: { url }, description?, spoiler? }`. */\nexport interface APIMediaGalleryComponent {\n type: typeof ComponentEnum.MediaGallery;\n items: {\n media: { url: string };\n description?: string;\n spoiler?: boolean;\n }[];\n}\n/** Default values accepted by an auto-populated entity select. */\nexport interface APISelectDefaultValue {\n id: string;\n type: \"user\" | \"role\" | \"channel\";\n}\n/** A Components V2 file display for an uploaded attachment. */\nexport interface APIFileComponent {\n type: typeof ComponentEnum.File;\n file: { url: string };\n spoiler?: boolean;\n}\n/** A Components V2 separator, with optional divider line and spacing. */\nexport interface APISeparatorComponent {\n type: typeof ComponentEnum.Separator;\n spacing?: 1 | 2;\n divider?: boolean;\n}\n/** A Components V2 thumbnail: `{ type: 11, media: { url }, description?, spoiler? }`. */\nexport interface APIThumbnailComponent {\n type: typeof ComponentEnum.Thumbnail;\n media: { url: string };\n description?: string;\n spoiler?: boolean;\n}\n/** A Components V2 content inventory entry. */\nexport interface APIContentInventoryEntryComponent {\n type: typeof ComponentEnum.ContentInventoryEntry;\n id: string;\n}\n/** A Components V2 container: a box around other components, with an optional accent colour. */\nexport interface APIContainerComponent {\n type: typeof ComponentEnum.Container;\n components: APIComponent[];\n accent_color?: number;\n spoiler?: boolean;\n}\n/** Any top-level message component: an action row or a Components V2 layout component. */\nexport type APIComponent =\n | APIActionRowComponent\n | APIButtonComponent\n | APIStringSelectComponent\n | APIEntitySelectComponent\n | APITextInputComponent\n | APISectionComponent\n | APITextDisplayComponent\n | APIThumbnailComponent\n | APIMediaGalleryComponent\n | APIFileComponent\n | APISeparatorComponent\n | APIContentInventoryEntryComponent\n | APIContainerComponent;\n\nexport class CreateActionRow<\n T extends { toJSON(): APIActionRowChild } = { toJSON(): APIActionRowChild },\n> {\n readonly #components: T[] = [];\n public addComponents(...components: T[]): this {\n if (!components.length)\n throw new TypeError(\"At least one component is required.\");\n if (this.#components.length + components.length > 5)\n throw new RangeError(\n \"An action row cannot contain more than 5 components.\",\n );\n this.#components.push(...components);\n return this;\n }\n public clearComponents(): this {\n this.#components.length = 0;\n return this;\n }\n public toJSON(): APIActionRowComponent {\n const components = this.#components.map((component) =>\n component.toJSON(),\n );\n if (components.length === 0)\n throw new RangeError(\"An action row needs at least one component.\");\n const types = components.map((component) => component.type);\n if (\n types.some((type) => type !== ComponentEnum.Button) &&\n components.length > 1\n )\n throw new RangeError(\n \"A select menu or text input must be alone in its action row.\",\n );\n return { type: ComponentEnum.ActionRow, components };\n }\n}\n/** Setters shared by string and entity select menus. */\nexport class CreateSelectMenu {\n readonly #select: APIStringSelectComponent | APIEntitySelectComponent;\n protected constructor(\n data: APIStringSelectComponent | APIEntitySelectComponent,\n ) {\n this.#select = data;\n }\n public setCustomId(value: string): this {\n validateText(value, 100, \"Component custom ID\");\n this.#select.custom_id = value;\n return this;\n }\n public setPlaceholder(value: string): this {\n validateText(value, 150, \"Component placeholder\");\n this.#select.placeholder = value;\n return this;\n }\n public setMinValues(value: number): this {\n validateCount(value, \"min_values\", 0);\n this.#select.min_values = value;\n return this;\n }\n public setMaxValues(value: number): this {\n validateCount(value, \"max_values\", 1);\n this.#select.max_values = value;\n return this;\n }\n public setRequired(value = true): this {\n this.#select.required = value;\n return this;\n }\n public setDisabled(value = true): this {\n this.#select.disabled = value;\n return this;\n }\n}\nexport class CreateStringSelect extends CreateSelectMenu {\n readonly #data: APIStringSelectComponent;\n public constructor() {\n const data: APIStringSelectComponent = {\n type: ComponentEnum.StringSelect,\n };\n super(data);\n this.#data = data;\n }\n public addOptions(...options: APISelectOption[]): this {\n if (!options.length)\n throw new TypeError(\"At least one select option is required.\");\n const current = this.#data.options ?? [];\n if (current.length + options.length > 25)\n throw new RangeError(\n \"A string select cannot contain more than 25 options.\",\n );\n for (const option of options) {\n validateText(option.label, 100, \"Select option label\");\n validateText(option.value, 100, \"Select option value\");\n if (option.description)\n validateText(\n option.description,\n 100,\n \"Select option description\",\n );\n }\n this.#data.options = [\n ...current,\n ...options.map((option) => ({ ...option })),\n ];\n return this;\n }\n public toJSON(): APIStringSelectComponent {\n assertSelect(this.#data);\n const count = this.#data.options?.length ?? 0;\n if (count === 0)\n throw new RangeError(\"A string select needs at least one option.\");\n if ((this.#data.max_values ?? 1) > count)\n throw new RangeError(\n \"max_values cannot exceed the number of options.\",\n );\n return cloneData(this.#data);\n }\n}\nexport class CreateButton {\n readonly #data: APIButtonComponent = {\n type: ComponentEnum.Button,\n style: ButtonType.Secondary,\n };\n /** Sets the style and drops fields that style cannot carry. */\n public setStyle(style: APIButtonComponent[\"style\"]): this {\n const data = this.#data;\n data.style = style;\n if (style === ButtonType.Link) {\n delete data.custom_id;\n delete data.sku_id;\n } else if (style === ButtonType.Premium) {\n delete data.custom_id;\n delete data.url;\n delete data.label;\n delete data.emoji;\n } else {\n delete data.url;\n delete data.sku_id;\n }\n return this;\n }\n public setCustomId(value: string): this {\n validateText(value, 100, \"Button custom ID\");\n if (this.#data.style === ButtonType.Link)\n throw new TypeError(\"Link buttons cannot use custom IDs.\");\n this.#data.custom_id = value;\n return this;\n }\n public setLabel(value: string): this {\n validateText(value, 80, \"Button label\");\n this.#data.label = value;\n return this;\n }\n public setURL(value: string): this {\n validateText(value, 512, \"Button URL\");\n let url: URL;\n try {\n url = new URL(value);\n } catch (error) {\n throw new TypeError(\"Button URL must be a valid URL.\", {\n cause: error,\n });\n }\n if (![\"http:\", \"https:\", \"discord:\"].includes(url.protocol))\n throw new TypeError(\"Button URL must use http, https or discord.\");\n this.setStyle(ButtonType.Link);\n this.#data.url = url.toString();\n return this;\n }\n /** Makes this a premium (purchase) button for a SKU. Premium buttons carry no label, emoji, custom ID or URL. */\n public setSKUId(skuId: string): this {\n validateText(skuId, 20, \"Button SKU ID\");\n this.setStyle(ButtonType.Premium);\n this.#data.sku_id = skuId;\n return this;\n }\n public setEmoji(emoji: APIComponentEmoji | string): this {\n this.#data.emoji =\n typeof emoji === \"string\" ? { name: emoji } : { ...emoji };\n return this;\n }\n public setDisabled(value = true): this {\n this.#data.disabled = value;\n return this;\n }\n public toJSON(): APIButtonComponent {\n const data = this.#data;\n if (data.style === ButtonType.Link) {\n if (!data.url) throw new TypeError(\"Link buttons require a URL.\");\n if (data.custom_id || data.sku_id)\n throw new TypeError(\n \"Link buttons cannot have a custom ID or SKU ID.\",\n );\n } else if (data.style === ButtonType.Premium) {\n if (!data.sku_id)\n throw new TypeError(\"Premium buttons require a SKU ID.\");\n if (data.custom_id || data.url || data.label || data.emoji)\n throw new TypeError(\n \"Premium buttons cannot have a custom ID, URL, label or emoji.\",\n );\n } else {\n if (!data.custom_id)\n throw new TypeError(\"Non-link buttons require a custom ID.\");\n if (data.url || data.sku_id)\n throw new TypeError(\n \"Only link buttons have a URL and only premium buttons have a SKU ID.\",\n );\n }\n if (data.style !== ButtonType.Premium && !data.label && !data.emoji)\n throw new TypeError(\"Buttons require a label or an emoji.\");\n return cloneData(data);\n }\n}\nexport class CreateEntitySelect extends CreateSelectMenu {\n readonly #data: APIEntitySelectComponent;\n public constructor(\n type:\n | typeof ComponentEnum.UserSelect\n | typeof ComponentEnum.RoleSelect\n | typeof ComponentEnum.MentionableSelect\n | typeof ComponentEnum.ChannelSelect,\n ) {\n if (\n type !== ComponentEnum.UserSelect &&\n type !== ComponentEnum.RoleSelect &&\n type !== ComponentEnum.MentionableSelect &&\n type !== ComponentEnum.ChannelSelect\n )\n throw new TypeError(\"Invalid select component type.\");\n const data: APIEntitySelectComponent = { type };\n super(data);\n this.#data = data;\n }\n public setDefaultValues(...values: APISelectDefaultValue[]): this {\n this.#data.default_values = values.map((value) => ({ ...value }));\n return this;\n }\n public toJSON(): APIEntitySelectComponent {\n assertSelect(this.#data);\n return cloneData(this.#data);\n }\n}\nexport class CreateModal {\n readonly #components: Array<{ toJSON(): APIActionRowComponent }> = [];\n #custom_id?: string;\n #title?: string;\n public setCustomId(value: string): this {\n validateText(value, 100, \"Modal custom ID\");\n this.#custom_id = value;\n return this;\n }\n public setTitle(value: string): this {\n validateText(value, 45, \"Modal title\");\n this.#title = value;\n return this;\n }\n public addComponents(\n ...components: Array<{ toJSON(): APIActionRowComponent }>\n ): this {\n if (!components.length)\n throw new TypeError(\"At least one modal component is required.\");\n if (this.#components.length + components.length > 5)\n throw new RangeError(\n \"A modal cannot contain more than 5 action rows.\",\n );\n this.#components.push(...components);\n return this;\n }\n /** Adds text inputs, each in its own action row (Discord's modal layout). @param inputs Text inputs, at most 5 per modal. */\n public addTextInputs(...inputs: CreateTextInput[]): this {\n return this.addComponents(\n ...inputs.map((input) =>\n new CreateActionRow<CreateTextInput>().addComponents(input),\n ),\n );\n }\n public toJSON(): APIModalComponent {\n if (!this.#custom_id || !this.#title)\n throw new TypeError(\"Modals require a custom ID and a title.\");\n if (this.#components.length === 0)\n throw new RangeError(\"Modals require at least one component.\");\n return {\n type: 9,\n custom_id: this.#custom_id,\n title: this.#title,\n components: this.#components.map((component) => component.toJSON()),\n };\n }\n}\nexport class CreateTextInput {\n readonly #data: APITextInputComponent = {\n type: ComponentEnum.TextInput,\n style: TextInputType.Short,\n };\n public setStyle(style: APITextInputComponent[\"style\"]): this {\n this.#data.style = style;\n return this;\n }\n public setCustomId(value: string): this {\n validateText(value, 100, \"Text input custom ID\");\n this.#data.custom_id = value;\n return this;\n }\n public setLabel(value: string): this {\n validateText(value, 45, \"Text input label\");\n this.#data.label = value;\n return this;\n }\n public setPlaceholder(value: string): this {\n validateText(value, 100, \"Text input placeholder\");\n this.#data.placeholder = value;\n return this;\n }\n public setMinLength(value: number): this {\n validateLength(value, \"min_length\", 4000);\n this.#data.min_length = value;\n return this;\n }\n public setMaxLength(value: number): this {\n validateLength(value, \"max_length\", 4000);\n this.#data.max_length = value;\n return this;\n }\n public setRequired(value = true): this {\n this.#data.required = value;\n return this;\n }\n public setValue(value: string): this {\n validateText(value, 4000, \"Text input value\");\n this.#data.value = value;\n return this;\n }\n public toJSON(): APITextInputComponent {\n const data = this.#data;\n if (!data.custom_id)\n throw new TypeError(\"Text inputs require a custom ID.\");\n if (\n data.min_length !== undefined &&\n data.max_length !== undefined &&\n data.min_length > data.max_length\n )\n throw new RangeError(\"min_length cannot exceed max_length.\");\n return cloneData(data);\n }\n}\n\nexport class CreateContainer {\n readonly #components: { toJSON(): APIComponent }[] = [];\n #accentColor?: number;\n #spoiler?: boolean;\n public addComponents(...components: { toJSON(): APIComponent }[]): this {\n if (!components.length)\n throw new TypeError(\"At least one component is required.\");\n this.#components.push(...components);\n return this;\n }\n public setAccentColor(color: number): this {\n if (!Number.isInteger(color) || color < 0 || color > 0xffffff) {\n throw new RangeError(\n \"Accent color must be an integer between 0 and 16777215 (0xFFFFFF).\",\n );\n }\n this.#accentColor = color;\n return this;\n }\n /** Marks the whole container as a spoiler (blurred until clicked). */\n public setSpoiler(spoiler = true): this {\n this.#spoiler = spoiler;\n return this;\n }\n public toJSON(): APIContainerComponent {\n const data: APIContainerComponent = {\n type: ComponentEnum.Container,\n components: this.#components.map((c) => c.toJSON()),\n };\n if (this.#accentColor !== undefined)\n data.accent_color = this.#accentColor;\n if (this.#spoiler !== undefined) data.spoiler = this.#spoiler;\n return data;\n }\n}\n\nexport class CreateSection {\n readonly #components: { toJSON(): APIComponent }[] = [];\n #accessory?: { toJSON(): APIComponent };\n public addComponents(...components: { toJSON(): APIComponent }[]): this {\n if (!components.length)\n throw new TypeError(\"At least one component is required.\");\n this.#components.push(...components);\n return this;\n }\n public setAccessory(accessory: { toJSON(): APIComponent }): this {\n this.#accessory = accessory;\n return this;\n }\n public toJSON(): APISectionComponent {\n return {\n type: ComponentEnum.Section,\n components: this.#components.length\n ? this.#components.map((c) => c.toJSON())\n : undefined,\n accessory: this.#accessory?.toJSON(),\n };\n }\n}\n\nexport class CreateTextDisplay {\n #content = \"\";\n public setContent(content: string): this {\n validateText(content, 4000, \"Text display content\");\n this.#content = content;\n return this;\n }\n public toJSON(): APITextDisplayComponent {\n return {\n type: ComponentEnum.TextDisplay,\n content: this.#content,\n };\n }\n}\n\nexport class CreateMediaGallery {\n readonly #items: APIMediaGalleryComponent[\"items\"] = [];\n public addItems(\n ...items: { url: string; description?: string; spoiler?: boolean }[]\n ): this {\n if (!items.length) {\n throw new TypeError(\"At least one media gallery item is required.\");\n }\n if (this.#items.length + items.length > 10) {\n throw new RangeError(\n \"MediaGallery can only contain up to 10 items.\",\n );\n }\n this.#items.push(\n ...items.map(({ url, description, spoiler }) => ({\n media: { url },\n ...(description !== undefined ? { description } : {}),\n ...(spoiler !== undefined ? { spoiler } : {}),\n })),\n );\n return this;\n }\n public toJSON(): APIMediaGalleryComponent {\n return {\n type: ComponentEnum.MediaGallery,\n items: cloneData(this.#items),\n };\n }\n}\n\nexport class CreateFileComponent {\n #url = \"\";\n #spoiler?: boolean;\n public setUrl(url: string): this {\n validateText(url, 2048, \"File component URL\");\n this.#url = url;\n return this;\n }\n public setSpoiler(spoiler = true): this {\n this.#spoiler = spoiler;\n return this;\n }\n public toJSON(): APIFileComponent {\n if (!this.#url) throw new Error(\"File component must have a URL.\");\n const data: APIFileComponent = {\n type: ComponentEnum.File,\n file: { url: this.#url },\n };\n if (this.#spoiler !== undefined) data.spoiler = this.#spoiler;\n return data;\n }\n}\n\nexport class CreateSeparator {\n #spacing?: 1 | 2;\n #divider?: boolean;\n public setSpacing(spacing: 1 | 2): this {\n this.#spacing = spacing;\n return this;\n }\n public setDivider(divider = true): this {\n this.#divider = divider;\n return this;\n }\n public toJSON(): APISeparatorComponent {\n const data: APISeparatorComponent = {\n type: ComponentEnum.Separator,\n };\n if (this.#spacing !== undefined) data.spacing = this.#spacing;\n if (this.#divider !== undefined) data.divider = this.#divider;\n return data;\n }\n}\n\nexport class CreateThumbnail {\n #url = \"\";\n #description?: string;\n #spoiler?: boolean;\n public setUrl(url: string): this {\n validateText(url, 2048, \"Thumbnail URL\");\n this.#url = url;\n return this;\n }\n /** Sets the thumbnail's alt-text description. */\n public setDescription(description: string): this {\n validateText(description, 1024, \"Thumbnail description\");\n this.#description = description;\n return this;\n }\n /** Marks the thumbnail as a spoiler (blurred until clicked). */\n public setSpoiler(spoiler = true): this {\n this.#spoiler = spoiler;\n return this;\n }\n public toJSON(): APIThumbnailComponent {\n const data: APIThumbnailComponent = {\n type: ComponentEnum.Thumbnail,\n media: { url: this.#url },\n };\n if (this.#description !== undefined)\n data.description = this.#description;\n if (this.#spoiler !== undefined) data.spoiler = this.#spoiler;\n return data;\n }\n}\n\nexport class CreateContentInventoryEntry {\n #id = \"\";\n public setId(id: string): this {\n validateText(id, 100, \"Content inventory entry ID\");\n this.#id = id;\n return this;\n }\n public toJSON(): APIContentInventoryEntryComponent {\n return {\n type: ComponentEnum.ContentInventoryEntry,\n id: this.#id,\n };\n }\n}\n\nfunction validateText(value: string, max: number, field: string): void {\n if (typeof value !== \"string\")\n throw new TypeError(`${field} must be a string.`);\n if (!value.trim())\n throw new RangeError(`${field} must be a non-empty string.`);\n if (value.length > max)\n throw new RangeError(`${field} cannot exceed ${max} characters.`);\n}\nfunction validateCount(\n value: number,\n field: string,\n min: number,\n max = 25,\n): void {\n if (!Number.isInteger(value) || value < min || value > max)\n throw new RangeError(\n `${field} must be an integer between ${min} and ${max}.`,\n );\n}\nfunction validateLength(value: number, field: string, max = 4000): void {\n if (!Number.isInteger(value) || value < 0 || value > max)\n throw new RangeError(\n `${field} must be an integer between 0 and ${max}.`,\n );\n}\n\n/** User select menu builder. */\nexport class CreateUserSelect extends CreateEntitySelect {\n public constructor() {\n super(ComponentEnum.UserSelect);\n }\n}\n/** Role select menu builder. */\nexport class CreateRoleSelect extends CreateEntitySelect {\n public constructor() {\n super(ComponentEnum.RoleSelect);\n }\n}\n/** Mentionable select menu builder. */\nexport class CreateMentionableSelect extends CreateEntitySelect {\n public constructor() {\n super(ComponentEnum.MentionableSelect);\n }\n}\n/** Channel select menu builder. */\nexport class CreateChannelSelect extends CreateEntitySelect {\n public constructor() {\n super(ComponentEnum.ChannelSelect);\n }\n}\n\n/** Checks the fields every select menu needs. */\nfunction assertSelect(data: {\n custom_id?: string;\n min_values?: number;\n max_values?: number;\n}): void {\n if (!data.custom_id)\n throw new TypeError(\"Select menus require a custom ID.\");\n if ((data.min_values ?? 1) > (data.max_values ?? 1))\n throw new RangeError(\"min_values cannot exceed max_values.\");\n}\n\n/** Discord's flag for a message laid out with Components V2 (containers, text displays...). */\nconst IS_COMPONENTS_V2 = 1 << 15;\n\n/**\n * A message payload laid out with Components V2: the components, and the flag\n * Discord requires for them. A V2 message cannot also carry `content` or `embeds`.\n * @param components Top-level components (containers, sections, text displays, action rows...).\n * @param options Extra message fields, such as `allowed_mentions` or `ephemeral`; `flags` are combined.\n * @example channel.send(componentsV2Message(new CreateContainer().addComponents(new CreateTextDisplay().setContent(\"Hi\"))))\n */\nexport function componentsV2Message<\n T extends Record<string, unknown> = Record<string, never>,\n>(\n components: { toJSON(): APIComponent } | Array<{ toJSON(): APIComponent }>,\n options?: T & { flags?: number },\n): { components: APIComponent[]; flags: number } & T {\n const list = Array.isArray(components) ? components : [components];\n if (!list.length)\n throw new TypeError(\n \"A Components V2 message needs at least one component.\",\n );\n return {\n ...(options ?? ({} as T)),\n components: list.map((component) => component.toJSON()),\n flags: (options?.flags ?? 0) | IS_COMPONENTS_V2,\n };\n}\n",
8
+ "import { cloneData } from \"./clone.js\";\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/** Throws unless every context is 0 (guilds), 1 (the bot's DMs) or 2 (other DMs). */\nfunction validateContexts(contexts: number[]): void {\n if (\n contexts.some(\n (context) => context !== 0 && context !== 1 && context !== 2,\n )\n )\n throw new RangeError(\"Command contexts must be 0, 1 or 2.\");\n}\n\n/** Builds Discord application command payloads. */\nexport class CreateSlashCommand {\n readonly #data: Record<string, unknown> = { type: 1 };\n /** Sets the command name. */\n public setName(name: string): this {\n validateName(name, \"Command name\");\n this.#data.name = name;\n return this;\n }\n /** Sets the command description. */\n public setDescription(description: string): this {\n validateText(description, \"Command description\", 100);\n this.#data.description = description;\n return this;\n }\n /** Sets where the command can be used: 0 guilds, 1 the bot's DMs, 2 other DMs. @throws {RangeError} For any other value. */\n public setContexts(...contexts: number[]): this {\n validateContexts(contexts);\n this.#data.contexts = [...contexts];\n return this;\n }\n /** Sets whether the command is NSFW. */\n public setNSFW(nsfw = true): this {\n this.#data.nsfw = nsfw;\n return this;\n }\n /** Sets whether the command is NSFW. */\n public setNsfw(nsfw = true): this {\n return this.setNSFW(nsfw);\n }\n /** Sets command default member permissions. */\n public setDefaultMemberPermissions(\n permissions: bigint | number | string | null,\n ): this {\n this.#data.default_member_permissions =\n permissions === null ? null : BigInt(permissions).toString();\n return this;\n }\n /** Sets command integration types. */\n public setIntegrationTypes(...types: number[]): this {\n this.#data.integration_types = [...types];\n return this;\n }\n /** Adds a string option. */\n public addStringOption(\n configure: (option: CreateStringOption) => CreateStringOption,\n ): this {\n return this.addOption(configure(new CreateStringOption()));\n }\n /** Adds an integer option. */\n public addIntegerOption(\n configure: (option: CreateIntegerOption) => CreateIntegerOption,\n ): this {\n return this.addOption(configure(new CreateIntegerOption()));\n }\n /** Adds a number option. */\n public addNumberOption(\n configure: (option: CreateNumberOption) => CreateNumberOption,\n ): this {\n return this.addOption(configure(new CreateNumberOption()));\n }\n /** Adds a boolean option. */\n public addBooleanOption(\n configure: (option: CreateBooleanOption) => CreateBooleanOption,\n ): this {\n return this.addOption(configure(new CreateBooleanOption()));\n }\n /** Adds a user option. */\n public addUserOption(\n configure: (option: CreateUserOption) => CreateUserOption,\n ): this {\n return this.addOption(configure(new CreateUserOption()));\n }\n /** Adds a channel option. */\n public addChannelOption(\n configure: (option: CreateChannelOption) => CreateChannelOption,\n ): this {\n return this.addOption(configure(new CreateChannelOption()));\n }\n /** Adds a role option. */\n public addRoleOption(\n configure: (option: CreateRoleOption) => CreateRoleOption,\n ): this {\n return this.addOption(configure(new CreateRoleOption()));\n }\n /** Adds a mentionable option. */\n public addMentionableOption(\n configure: (option: CreateMentionableOption) => CreateMentionableOption,\n ): this {\n return this.addOption(configure(new CreateMentionableOption()));\n }\n /** Adds an attachment option. */\n public addAttachmentOption(\n configure: (option: CreateAttachmentOption) => CreateAttachmentOption,\n ): this {\n return this.addOption(configure(new CreateAttachmentOption()));\n }\n /** Adds a subcommand. */\n public addSubcommand(\n configure: (option: CreateSubcommand) => CreateSubcommand,\n ): this {\n return this.addOption(configure(new CreateSubcommand()));\n }\n /** Adds a subcommand group. */\n public addSubcommandGroup(\n configure: (option: CreateSubcommandGroup) => CreateSubcommandGroup,\n ): this {\n return this.addOption(configure(new CreateSubcommandGroup()));\n }\n /** Serializes the command payload. */\n public toJSON(): Record<string, unknown> {\n return cloneData(this.#data);\n }\n /** Adds a validated top-level command option. */\n protected addOption(option: CreateCommandOption): this {\n this.#data.options = appendOption(\n this.#data.options,\n option.toJSON(),\n \"application command\",\n );\n return this;\n }\n}\n\n/** Base builder for command options. */\nexport class CreateCommandOption {\n protected readonly data: Record<string, unknown>;\n /** Creates an option builder. */\n public constructor(type: number) {\n this.data = { type };\n }\n /** Sets the option name. */\n public setName(name: string): this {\n validateName(name, \"Option name\");\n this.data.name = name;\n return this;\n }\n /** Sets the option description. */\n public setDescription(description: string): this {\n validateText(description, \"Option description\", 100);\n this.data.description = description;\n return this;\n }\n /** Makes the option required or optional. */\n public setRequired(required = true): this {\n this.data.required = required;\n return this;\n }\n /** Sets autocomplete; options with choices cannot use it. */\n public setAutocomplete(enabled = true): this {\n if (\n enabled &&\n Array.isArray(this.data.choices) &&\n this.data.choices.length\n )\n throw new RangeError(\"Autocomplete options cannot define choices.\");\n this.data.autocomplete = enabled;\n return this;\n }\n /** Serializes the option payload. */\n public toJSON(): Record<string, unknown> {\n return cloneData(this.data);\n }\n}\n\n/** Builds a string command option. */\nexport class CreateStringOption extends CreateCommandOption {\n /** Creates a string option. */\n public constructor() {\n super(ApplicationCommandOptionEnum.String);\n }\n /** Adds string choices. */\n public addChoices(\n ...choices: Array<{ name: string; value: string }>\n ): this {\n for (const choice of choices)\n validateText(choice.value, \"Choice value\", 100);\n appendChoices(this.data, choices);\n return this;\n }\n /** Sets the minimum string length. */\n public setMinLength(value: number): this {\n validateIntegerRange(value, 0, 6000, \"min_length\");\n this.data.min_length = value;\n return this;\n }\n /** Sets the maximum string length. */\n public setMaxLength(value: number): this {\n validateIntegerRange(value, 1, 6000, \"max_length\");\n if (\n (this.data.min_length as number | undefined) !== undefined &&\n (this.data.min_length as number) > value\n )\n throw new RangeError(\"min_length cannot exceed max_length.\");\n this.data.max_length = value;\n return this;\n }\n}\n/** Shared bounds, choices and autocomplete rules of integer and number options. */\nexport class CreateNumericOption extends CreateCommandOption {\n readonly #integer: boolean;\n /** Creates a numeric option; `integer` rejects fractional bounds. */\n public constructor(type: number, integer: boolean) {\n super(type);\n this.#integer = integer;\n }\n /** Sets the minimum value. */\n public setMinValue(value: number): this {\n validateNumberRange(\n value,\n -MAX_SAFE,\n MAX_SAFE,\n \"min_value\",\n this.#integer,\n );\n const max = this.data.max_value as number | undefined;\n if (max !== undefined && value > max)\n throw new RangeError(\"min_value cannot exceed max_value.\");\n this.data.min_value = value;\n return this;\n }\n /** Sets the maximum value; it cannot be below the minimum. */\n public setMaxValue(value: number): this {\n validateNumberRange(\n value,\n -MAX_SAFE,\n MAX_SAFE,\n \"max_value\",\n this.#integer,\n );\n const min = this.data.min_value as number | undefined;\n if (min !== undefined && min > value)\n throw new RangeError(\"min_value cannot exceed max_value.\");\n this.data.max_value = value;\n return this;\n }\n /** Enables autocomplete; options with choices cannot use it. */\n public override setAutocomplete(enabled = true): this {\n if (\n enabled &&\n Array.isArray(this.data.choices) &&\n this.data.choices.length\n )\n throw new RangeError(\"Autocomplete options cannot define choices.\");\n this.data.autocomplete = enabled;\n return this;\n }\n /** Adds fixed choices. */\n public addChoices(...choices: { name: string; value: number }[]): this {\n appendChoices(this.data, choices);\n return this;\n }\n}\n/** Builds an integer command option. */\nexport class CreateIntegerOption extends CreateNumericOption {\n public constructor() {\n super(ApplicationCommandOptionEnum.Integer, true);\n }\n}\n/** Builds a number command option. */\nexport class CreateNumberOption extends CreateNumericOption {\n public constructor() {\n super(ApplicationCommandOptionEnum.Number, false);\n }\n}\n/** Builds a boolean command option. */\nexport class CreateBooleanOption extends CreateCommandOption {\n /** Creates a boolean option. */\n public constructor() {\n super(ApplicationCommandOptionEnum.Boolean);\n }\n}\n/** Builds a user command option. */\nexport class CreateUserOption extends CreateCommandOption {\n /** Creates a user option. */\n public constructor() {\n super(ApplicationCommandOptionEnum.User);\n }\n}\n/** Builds a role command option. */\nexport class CreateRoleOption extends CreateCommandOption {\n /** Creates a role option. */\n public constructor() {\n super(ApplicationCommandOptionEnum.Role);\n }\n}\n/** Builds a mentionable command option. */\nexport class CreateMentionableOption extends CreateCommandOption {\n /** Creates a mentionable option. */\n public constructor() {\n super(ApplicationCommandOptionEnum.Mentionable);\n }\n}\n/** Builds an attachment command option. */\nexport class CreateAttachmentOption extends CreateCommandOption {\n /** Creates an attachment option. */\n public constructor() {\n super(ApplicationCommandOptionEnum.Attachment);\n }\n}\n/** Builds a channel command option. */\nexport class CreateChannelOption extends CreateCommandOption {\n /** Creates a channel option. */\n public constructor() {\n super(ApplicationCommandOptionEnum.Channel);\n }\n /** Restricts accepted channel types. */\n public addChannelTypes(...types: number[]): this {\n if (types.some((type) => !Number.isInteger(type) || type < 0))\n throw new RangeError(\n \"Channel types must be non-negative integers.\",\n );\n this.data.channel_types = [...new Set(types)];\n return this;\n }\n}\n/** Builds a nested subcommand. */\nexport class CreateSubcommand extends CreateCommandOption {\n /** Creates a subcommand. */\n public constructor() {\n super(ApplicationCommandOptionEnum.Subcommand);\n }\n /** Adds a string option to this subcommand. */\n public addStringOption(\n configure: (option: CreateStringOption) => CreateStringOption,\n ): this {\n return this.addChildOption(configure(new CreateStringOption()));\n }\n /** Adds an integer option to this subcommand. */\n public addIntegerOption(\n configure: (option: CreateIntegerOption) => CreateIntegerOption,\n ): this {\n return this.addChildOption(configure(new CreateIntegerOption()));\n }\n /** Adds a number option to this subcommand. */\n public addNumberOption(\n configure: (option: CreateNumberOption) => CreateNumberOption,\n ): this {\n return this.addChildOption(configure(new CreateNumberOption()));\n }\n /** Adds a boolean option to this subcommand. */\n public addBooleanOption(\n configure: (option: CreateBooleanOption) => CreateBooleanOption,\n ): this {\n return this.addChildOption(configure(new CreateBooleanOption()));\n }\n /** Adds a user option to this subcommand. */\n public addUserOption(\n configure: (option: CreateUserOption) => CreateUserOption,\n ): this {\n return this.addChildOption(configure(new CreateUserOption()));\n }\n /** Adds a channel option to this subcommand. */\n public addChannelOption(\n configure: (option: CreateChannelOption) => CreateChannelOption,\n ): this {\n return this.addChildOption(configure(new CreateChannelOption()));\n }\n /** Adds a role option to this subcommand. */\n public addRoleOption(\n configure: (option: CreateRoleOption) => CreateRoleOption,\n ): this {\n return this.addChildOption(configure(new CreateRoleOption()));\n }\n /** Adds a mentionable option to this subcommand. */\n public addMentionableOption(\n configure: (option: CreateMentionableOption) => CreateMentionableOption,\n ): this {\n return this.addChildOption(configure(new CreateMentionableOption()));\n }\n /** Adds an attachment option to this subcommand. */\n public addAttachmentOption(\n configure: (option: CreateAttachmentOption) => CreateAttachmentOption,\n ): this {\n return this.addChildOption(configure(new CreateAttachmentOption()));\n }\n protected addChildOption(option: CreateCommandOption): this {\n const options =\n (this.data.options as OptionPayload[] | undefined) ?? [];\n if (\n options.some(\n (existing) =>\n existing.type === ApplicationCommandOptionEnum.Subcommand,\n )\n )\n throw new RangeError(\n \"Subcommands cannot contain nested subcommands.\",\n );\n this.data.options = appendOption(\n options,\n option.toJSON(),\n \"subcommand\",\n );\n return this;\n }\n}\n/** Builds a nested subcommand group. */\nexport class CreateSubcommandGroup extends CreateCommandOption {\n /** Creates a subcommand group. */\n public constructor() {\n super(ApplicationCommandOptionEnum.SubcommandGroup);\n }\n /** Adds a subcommand to this group. */\n public addSubcommand(\n configure: (option: CreateSubcommand) => CreateSubcommand,\n ): this {\n const options = (this.data.options as unknown[] | undefined) ?? [];\n if (options.length >= 25)\n throw new RangeError(\n \"A subcommand group cannot contain more than 25 subcommands.\",\n );\n const payload = configure(new CreateSubcommand()).toJSON();\n if (\n options.some(\n (existing) =>\n (existing as Record<string, unknown>).name === payload.name,\n )\n )\n throw new RangeError(\n `Duplicate subcommand name: ${String(payload.name)}.`,\n );\n if (payload.type !== ApplicationCommandOptionEnum.Subcommand)\n throw new TypeError(\n \"Subcommand group children must be subcommands.\",\n );\n options.push(payload);\n this.data.options = options;\n return this;\n }\n}\nconst MAX_SAFE = Number.MAX_SAFE_INTEGER;\n\n/** A serialized option as stored on its parent. */\ntype OptionPayload = Record<string, unknown>;\n\n/**\n * Returns `options` with `payload` appended, enforcing Discord's limit of 25,\n * unique names, and required options before optional ones.\n */\nfunction appendOption(\n options: unknown,\n payload: OptionPayload,\n parent: \"application command\" | \"subcommand\",\n): OptionPayload[] {\n const list = (options as OptionPayload[] | undefined) ?? [];\n if (list.length >= 25)\n throw new RangeError(\n `${parent === \"subcommand\" ? \"A subcommand\" : \"An application command\"} cannot contain more than 25 options.`,\n );\n if (list.some((existing) => existing.name === payload.name))\n throw new RangeError(`Duplicate option name: ${String(payload.name)}.`);\n if (\n payload.required === true &&\n list.some((existing) => existing.required !== true)\n )\n throw new RangeError(\n `Required ${parent} options must be placed before optional options.`,\n );\n return [...list, payload];\n}\n\n/** Appends choices to an option, enforcing the shared choice rules. */\nfunction appendChoices(\n data: OptionPayload,\n choices: { name: string; value: string | number }[],\n): void {\n const current = (data.choices as unknown[] | undefined) ?? [];\n if (!choices.length)\n throw new TypeError(\"At least one choice is required.\");\n if (data.autocomplete === true)\n throw new RangeError(\"Autocomplete options cannot define choices.\");\n if (current.length + choices.length > 25)\n throw new RangeError(\"An option cannot contain more than 25 choices.\");\n for (const choice of choices) {\n validateText(choice.name, \"Choice name\", 100);\n const value: unknown = choice.value;\n if (\n typeof value === \"string\"\n ? value.length === 0 || value.length > 100\n : typeof value !== \"number\" || !Number.isFinite(value)\n )\n throw new TypeError(\n \"Choice value must be a string of 1-100 characters or a finite number.\",\n );\n }\n data.choices = [...current, ...choices.map((choice) => ({ ...choice }))];\n}\n\nfunction validateName(value: string, field: string): void {\n if (!/^[\\p{L}\\p{N}_-]{1,32}$/u.test(value) || value !== value.toLowerCase())\n throw new RangeError(\n `${field} must contain 1-32 lowercase letters, numbers, underscores, or hyphens.`,\n );\n}\nfunction validateText(value: string, field: string, max: number): void {\n if (typeof value !== \"string\" || !value.trim() || value.length > max)\n throw new RangeError(`${field} must contain 1-${max} characters.`);\n}\nfunction validateIntegerRange(\n value: number,\n minimum: number,\n maximum: number,\n field: string,\n): void {\n if (!Number.isInteger(value) || value < minimum || value > maximum)\n throw new RangeError(\n `${field} must be an integer between ${minimum} and ${maximum}.`,\n );\n}\nfunction validateNumberRange(\n value: number,\n minimum: number,\n maximum: number,\n field: string,\n integerOnly = true,\n): void {\n if (\n !Number.isFinite(value) ||\n (integerOnly && !Number.isInteger(value)) ||\n value < minimum ||\n value > maximum\n )\n throw new RangeError(\n `${field} must be ${integerOnly ? \"an integer\" : \"a number\"} between ${minimum} and ${maximum}.`,\n );\n}\n\n// ─── Context Menu Builders ────────────────────────────────────────────────────\n\n/** Builder for application commands that appear in right-click context menus.\n * Example: `new CreateContextMenuCommand().setName(\"x\").setType(2)`. */\nexport class CreateContextMenuCommand {\n protected readonly data: Record<string, unknown>;\n public constructor(type: 2 | 3 = 2) {\n this.data = { type };\n }\n /** Sets the command type: 2 = USER, 3 = MESSAGE. @throws {RangeError} For any other type. */\n public setType(type: 2 | 3): this {\n if (type !== 2 && type !== 3)\n throw new RangeError(\"Context menu command type must be 2 or 3.\");\n this.data.type = type;\n return this;\n }\n /** Sets the command name (shown in the right-click menu).\n * Unlike CHAT_INPUT commands, USER (type 2) and MESSAGE (type 3) context-menu\n * command names may contain uppercase letters and spaces, so no lowercase/charset\n * validation is applied here — only Discord's 1-32 length limit and a non-empty\n * (non-whitespace) requirement are enforced.\n * @param name Display name; 1-32 characters, mixed case and spaces allowed.\n * @throws {RangeError} If the name is empty/whitespace-only or exceeds 32 characters.\n */\n public setName(name: string): this {\n if (\n typeof name !== \"string\" ||\n name.trim().length < 1 ||\n name.length > 32\n )\n throw new RangeError(\"Command name must contain 1-32 characters.\");\n this.data.name = name;\n return this;\n }\n /** Sets default member permissions required to see this command. */\n public setDefaultMemberPermissions(\n permissions: bigint | number | string | null,\n ): this {\n this.data.default_member_permissions =\n permissions === null ? null : BigInt(permissions).toString();\n return this;\n }\n /** Sets command integration types (0 guild install, 1 user install). */\n public setIntegrationTypes(...types: number[]): this {\n this.data.integration_types = [...types];\n return this;\n }\n /** Sets where the command can be used: 0 guilds, 1 the bot's DMs, 2 other DMs. @throws {RangeError} For any other value. */\n public setContexts(...contexts: number[]): this {\n validateContexts(contexts);\n this.data.contexts = [...contexts];\n return this;\n }\n /** Sets the name shown per locale, e.g. `{ \"es-ES\": \"Ver perfil\" }`; null clears it. */\n public setNameLocalizations(\n localizations: Record<string, string> | null,\n ): this {\n this.data.name_localizations =\n localizations === null ? null : { ...localizations };\n return this;\n }\n /** Serializes the command payload for the Discord API. */\n public toJSON(): Record<string, unknown> {\n return cloneData(this.data);\n }\n}\n\n/** Builds a User context menu command (appears when right-clicking a user, type 2).\n * @example\n * new CreateUserCommand().setName(\"View Profile\").toJSON()\n */\nexport class CreateUserCommand extends CreateContextMenuCommand {\n public constructor() {\n super(2);\n }\n}\n\n/** Builds a Message context menu command (appears when right-clicking a message, type 3).\n * @example\n * new CreateMessageCommand().setName(\"Translate Message\").toJSON()\n */\nexport class CreateMessageCommand extends CreateContextMenuCommand {\n public constructor() {\n super(3);\n }\n}\n",
9
+ "import { readFile, realpath } from \"node:fs/promises\";\nimport { basename, isAbsolute, relative, resolve } from \"node:path\";\n\n/** Options for `CreateAttachment`: file name, alt-text description, the contents or a file path, and an optional root folder the path must stay inside. */\nexport interface AttachmentData {\n name: string;\n description?: string;\n file: Uint8Array | ArrayBuffer | Blob | Buffer | string;\n /**\n * Folder a string `file` must stay inside (symlinks included). Set it\n * whenever the path is not one you wrote yourself, e.g. from a command\n * option: without it, any readable file on the machine can be uploaded.\n */\n root?: string;\n}\n\n/** Builder for message attachments and file uploads. */\nexport class CreateAttachment {\n public name: string;\n public description?: string;\n public file: Uint8Array | ArrayBuffer | Blob | Buffer | string;\n /** Folder a string `file` must stay inside; see {@link AttachmentData.root}. */\n public root?: string;\n\n public constructor(\n file: Uint8Array | ArrayBuffer | Blob | Buffer | string,\n data?: Partial<Omit<AttachmentData, \"file\">> | string,\n ) {\n this.file = file;\n if (typeof data === \"string\") {\n this.name = data;\n } else {\n this.name =\n data?.name ??\n (typeof file === \"string\" ? basename(file) : \"file.bin\");\n this.description = data?.description;\n this.root = data?.root;\n }\n }\n\n /** Sets the attachment filename. */\n public setName(name: string): this {\n this.name = name;\n return this;\n }\n\n /** Sets the attachment description / alt text. */\n public setDescription(description: string): this {\n this.description = description;\n return this;\n }\n\n /** Sets the file contents. */\n public setFile(\n file: Uint8Array | ArrayBuffer | Blob | Buffer | string,\n ): this {\n this.file = file;\n return this;\n }\n\n /** Resolves the attachment payload to a binary Uint8Array. */\n public async toBuffer(): Promise<Uint8Array> {\n if (typeof this.file === \"string\") {\n const path =\n this.root === undefined\n ? this.file\n : await insideRoot(this.root, this.file);\n const buffer = await readFile(path);\n return new Uint8Array(buffer);\n }\n if (this.file instanceof Uint8Array) return this.file;\n if (this.file instanceof ArrayBuffer) return new Uint8Array(this.file);\n if (this.file instanceof Blob) {\n const buf = await this.file.arrayBuffer();\n return new Uint8Array(buf);\n }\n if (typeof Buffer !== \"undefined\" && Buffer.isBuffer(this.file)) {\n return new Uint8Array(this.file);\n }\n throw new TypeError(\n \"Attachment file must be a supported binary value or file path.\",\n );\n }\n}\n\n/** Resolves `file` against `root`, refusing anything outside it (after following symlinks). */\nasync function insideRoot(root: string, file: string): Promise<string> {\n const base = await realpath(root).catch(() => {\n throw new Error(\"Attachment root folder was not found.\");\n });\n const target = await realpath(resolve(base, file)).catch(() => {\n throw new Error(\"Attachment file was not found inside its root.\");\n });\n const rel = relative(base, target);\n if (\n rel === \"\" ||\n rel === \"..\" ||\n rel.startsWith(\"../\") ||\n rel.startsWith(\"..\\\\\")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src/index.ts
3
+ function userMention2(id) {
4
+ return `<@${validateSnowflake(id, "User ID")}>`;
5
+ }
6
+ function channelMention2(id) {
7
+ return `<#${validateSnowflake(id, "Channel ID")}>`;
8
+ }
9
+ function roleMention2(id) {
10
+ return `<@&${validateSnowflake(id, "Role ID")}>`;
11
+ }
12
+ function timestamp2(unixSeconds, style) {
13
+ if (!Number.isFinite(unixSeconds))
14
+ throw new TypeError("Timestamp must be a finite Unix timestamp.");
15
+ if (style !== undefined && !/^[tTdDfFR]$/.test(style))
16
+ throw new RangeError("Invalid Discord timestamp style.");
17
+ if (!Number.isSafeInteger(Math.floor(unixSeconds)))
18
+ throw new RangeError("Timestamp is out of range.");
19
+ return `<t:${Math.floor(unixSeconds)}${style ? `:${style}` : ""}>`;
20
+ }
21
+ function bold2(text) {
22
+ return `**${text}**`;
23
+ }
24
+ function italic2(text) {
25
+ return `_${text}_`;
26
+ }
27
+ function underline2(text) {
28
+ return `__${text}__`;
29
+ }
30
+ function strikethrough2(text) {
31
+ return `~~${text}~~`;
32
+ }
33
+ function spoiler2(text) {
34
+ return `||${text}||`;
35
+ }
36
+ function masked2(text) {
37
+ return spoiler2(text);
38
+ }
39
+ function inlineCode2(text) {
40
+ return `\`${text}\``;
41
+ }
42
+ function codeBlock2(text, language = "") {
43
+ const safe = text.replace(/`(?=`)/g, "`\u200B");
44
+ const lang = language.replace(/[^\w+#.-]/g, "");
45
+ return `\`\`\`${lang}
46
+ ${safe}
47
+ \`\`\``;
48
+ }
49
+ function link2(label, url, title) {
50
+ if (!/^(?:https?|discord):\/\//i.test(url))
51
+ throw new TypeError("link() only accepts http, https or discord URLs.");
52
+ const text = label.replace(/[[\]\\]/g, "\\$&").replace(/\n/g, " ");
53
+ const target = url.replace(/[()\s"]/g, (c) => `%${c.charCodeAt(0).toString(16).toUpperCase().padStart(2, "0")}`);
54
+ const titlePart = title ? ` "${title.replace(/["\n)]/g, "")}"` : "";
55
+ return `[${text}](${target}${titlePart})`;
56
+ }
57
+ function blockQuote2(text) {
58
+ return text.split(`
59
+ `).map((line) => `> ${line}`).join(`
60
+ `);
61
+ }
62
+ function heading2(text, level = 1) {
63
+ return `${"#".repeat(level)} ${text}`;
64
+ }
65
+ function subtext2(text) {
66
+ return `-# ${text}`;
67
+ }
68
+ function orderedList2(...items) {
69
+ return items.map((item, i) => `${i + 1}. ${item}`).join(`
70
+ `);
71
+ }
72
+ function bulletList2(...items) {
73
+ return items.map((item) => `- ${item}`).join(`
74
+ `);
75
+ }
76
+ function escapeMarkdown2(value) {
77
+ return value.replace(/[\\*_`~|>]/g, "\\$&");
78
+ }
79
+ function validateSnowflake(id, field) {
80
+ const len = id.length;
81
+ if (len < 1 || len > 20) {
82
+ throw new TypeError(`${field} must be a valid Discord snowflake.`);
83
+ }
84
+ for (let i = 0;i < len; i++) {
85
+ const code = id.charCodeAt(i);
86
+ if (code < 48 || code > 57) {
87
+ throw new TypeError(`${field} must be a valid Discord snowflake.`);
88
+ }
89
+ }
90
+ return id;
91
+ }
92
+
93
+ export { userMention2, channelMention2, roleMention2, timestamp2, bold2, italic2, underline2, strikethrough2, spoiler2, masked2, inlineCode2, codeBlock2, link2, blockQuote2, heading2, subtext2, orderedList2, bulletList2, escapeMarkdown2 };
94
+
95
+ //# debugId=83CDBCCCB55DA13364756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../packages/formatters/src/index.ts"],
4
+ "sourcesContent": [
5
+ "// ─── Mentions ──────────────────────────────────────────────────────────────────\n\n/** Creates a user mention from a Discord snowflake. */\nexport function userMention(id: string): string {\n return `<@${validateSnowflake(id, \"User ID\")}>`;\n}\n\n/** Creates a channel mention from a Discord snowflake. */\nexport function channelMention(id: string): string {\n return `<#${validateSnowflake(id, \"Channel ID\")}>`;\n}\n\n/** Creates a role mention from a Discord snowflake. */\nexport function roleMention(id: string): string {\n return `<@&${validateSnowflake(id, \"Role ID\")}>`;\n}\n\n// ─── Timestamps ────────────────────────────────────────────────────────────────\n\n/** Discord timestamp style formats. */\nexport type TimestampStyle = \"t\" | \"T\" | \"d\" | \"D\" | \"f\" | \"F\" | \"R\";\n\n/** Creates a Discord timestamp tag.\n * @param unixSeconds Unix timestamp in seconds.\n * @param style Optional display style: t=short time, T=long time, d=short date, D=long date, f=short datetime, F=long datetime, R=relative.\n */\nexport function timestamp(\n unixSeconds: number,\n style?: TimestampStyle | string,\n): string {\n if (!Number.isFinite(unixSeconds))\n throw new TypeError(\"Timestamp must be a finite Unix timestamp.\");\n if (style !== undefined && !/^[tTdDfFR]$/.test(style))\n throw new RangeError(\"Invalid Discord timestamp style.\");\n if (!Number.isSafeInteger(Math.floor(unixSeconds)))\n throw new RangeError(\"Timestamp is out of range.\");\n return `<t:${Math.floor(unixSeconds)}${style ? `:${style}` : \"\"}>`;\n}\n\n// ─── Markdown ─────────────────────────────────────────────────────────────────\n\n/** Wraps text in Discord bold markdown. */\nexport function bold(text: string): string {\n return `**${text}**`;\n}\n\n/** Wraps text in Discord italic markdown. */\nexport function italic(text: string): string {\n return `_${text}_`;\n}\n\n/** Wraps text in Discord underline markdown. */\nexport function underline(text: string): string {\n return `__${text}__`;\n}\n\n/** Wraps text in Discord strikethrough markdown. */\nexport function strikethrough(text: string): string {\n return `~~${text}~~`;\n}\n\n/** Wraps text in a Discord spoiler tag (shown masked until clicked). */\nexport function spoiler(text: string): string {\n return `||${text}||`;\n}\n\n/** Alias for spoiler — hides text until revealed. */\nexport function masked(text: string): string {\n return spoiler(text);\n}\n\n/** Wraps text in Discord inline code. */\nexport function inlineCode(text: string): string {\n return `\\`${text}\\``;\n}\n\n/** Wraps text in a Discord fenced code block.\n * @param text Code content.\n * @param language Optional language identifier for syntax highlighting.\n */\nexport function codeBlock(text: string, language = \"\"): string {\n // A zero-width space between every two adjacent backticks: no run of any\n // length (```` included) can then form a closing fence.\n const safe = text.replace(/`(?=`)/g, \"`\\u200b\");\n const lang = language.replace(/[^\\w+#.-]/g, \"\");\n return `\\`\\`\\`${lang}\\n${safe}\\n\\`\\`\\``;\n}\n\n/** Creates a Discord masked hyperlink: [label](url).\n * @param label Display text.\n * @param url Destination URL.\n * @param title Optional hover title.\n */\nexport function link(label: string, url: string, title?: string): string {\n // Brackets in the label and parentheses, quotes or spaces in the URL would\n // otherwise end the link early and let the rest render as a second link.\n if (!/^(?:https?|discord):\\/\\//i.test(url))\n throw new TypeError(\"link() only accepts http, https or discord URLs.\");\n const text = label.replace(/[[\\]\\\\]/g, \"\\\\$&\").replace(/\\n/g, \" \");\n const target = url.replace(\n /[()\\s\"]/g,\n (c) =>\n `%${c.charCodeAt(0).toString(16).toUpperCase().padStart(2, \"0\")}`,\n );\n const titlePart = title ? ` \"${title.replace(/[\"\\n)]/g, \"\")}\"` : \"\";\n return `[${text}](${target}${titlePart})`;\n}\n\n/** Wraps each line of text in a Discord block quote (> prefix). */\nexport function blockQuote(text: string): string {\n return text\n .split(\"\\n\")\n .map((line) => `> ${line}`)\n .join(\"\\n\");\n}\n\n/** Creates a Discord heading at the given level (1–3). */\nexport function heading(text: string, level: 1 | 2 | 3 = 1): string {\n return `${\"#\".repeat(level)} ${text}`;\n}\n\n/** Wraps text in Discord's subtext markdown (-# prefix). */\nexport function subtext(text: string): string {\n return `-# ${text}`;\n}\n\n/** Creates a numbered ordered list from items. */\nexport function orderedList(...items: string[]): string {\n return items.map((item, i) => `${i + 1}. ${item}`).join(\"\\n\");\n}\n\n/** Creates an unordered bullet list from items. */\nexport function bulletList(...items: string[]): string {\n return items.map((item) => `- ${item}`).join(\"\\n\");\n}\n\n// ─── Utilities ─────────────────────────────────────────────────────────────────\n\n/**\n * Escapes the inline Discord markdown characters `\\ * _ ` ~ | >`. It does not\n * neutralise headings, lists or `[label](url)` links: pair it with\n * `allowedMentions` and never rely on it to sanitise untrusted text.\n */\nexport function escapeMarkdown(value: string): string {\n return value.replace(/[\\\\*_`~|>]/g, \"\\\\$&\");\n}\n\nfunction validateSnowflake(id: string, field: string): string {\n const len = id.length;\n if (len < 1 || len > 20) {\n throw new TypeError(`${field} must be a valid Discord snowflake.`);\n }\n for (let i = 0; i < len; i++) {\n const code = id.charCodeAt(i);\n if (code < 48 || code > 57) {\n throw new TypeError(`${field} must be a valid Discord snowflake.`);\n }\n }\n return id;\n}\n"
6
+ ],
7
+ "mappings": ";;AAGO,SAAS,YAAW,CAAC,IAAoB;AAAA,EAC5C,OAAO,KAAK,kBAAkB,IAAI,SAAS;AAAA;AAIxC,SAAS,eAAc,CAAC,IAAoB;AAAA,EAC/C,OAAO,KAAK,kBAAkB,IAAI,YAAY;AAAA;AAI3C,SAAS,YAAW,CAAC,IAAoB;AAAA,EAC5C,OAAO,MAAM,kBAAkB,IAAI,SAAS;AAAA;AAYzC,SAAS,UAAS,CACrB,aACA,OACM;AAAA,EACN,IAAI,CAAC,OAAO,SAAS,WAAW;AAAA,IAC5B,MAAM,IAAI,UAAU,4CAA4C;AAAA,EACpE,IAAI,UAAU,aAAa,CAAC,cAAc,KAAK,KAAK;AAAA,IAChD,MAAM,IAAI,WAAW,kCAAkC;AAAA,EAC3D,IAAI,CAAC,OAAO,cAAc,KAAK,MAAM,WAAW,CAAC;AAAA,IAC7C,MAAM,IAAI,WAAW,4BAA4B;AAAA,EACrD,OAAO,MAAM,KAAK,MAAM,WAAW,IAAI,QAAQ,IAAI,UAAU;AAAA;AAM1D,SAAS,KAAI,CAAC,MAAsB;AAAA,EACvC,OAAO,KAAK;AAAA;AAIT,SAAS,OAAM,CAAC,MAAsB;AAAA,EACzC,OAAO,IAAI;AAAA;AAIR,SAAS,UAAS,CAAC,MAAsB;AAAA,EAC5C,OAAO,KAAK;AAAA;AAIT,SAAS,cAAa,CAAC,MAAsB;AAAA,EAChD,OAAO,KAAK;AAAA;AAIT,SAAS,QAAO,CAAC,MAAsB;AAAA,EAC1C,OAAO,KAAK;AAAA;AAIT,SAAS,OAAM,CAAC,MAAsB;AAAA,EACzC,OAAO,SAAQ,IAAI;AAAA;AAIhB,SAAS,WAAU,CAAC,MAAsB;AAA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