discord-message-transcript-base 1.3.1 → 1.3.2-dev.1.50

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 (39) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/core/markdown.d.ts +1 -1
  3. package/dist/core/markdown.js +130 -74
  4. package/dist/core/output.d.ts +2 -1
  5. package/dist/core/output.js +1 -1
  6. package/dist/core/sanitizer.d.ts +1 -1
  7. package/dist/core/sanitizer.js +19 -18
  8. package/dist/index.d.ts +5 -6
  9. package/dist/index.js +6 -8
  10. package/dist/internalIndex.d.ts +4 -0
  11. package/dist/internalIndex.js +4 -0
  12. package/dist/renderers/html/html.d.ts +1 -1
  13. package/dist/renderers/html/html.js +61 -35
  14. package/dist/types/internal/index.d.ts +7 -0
  15. package/dist/types/internal/index.js +7 -0
  16. package/dist/types/internal/message/components.d.ts +252 -0
  17. package/dist/types/internal/message/components.js +1 -0
  18. package/dist/types/internal/message/componentsV2.d.ts +138 -0
  19. package/dist/types/internal/message/componentsV2.js +1 -0
  20. package/dist/types/internal/message/enum.d.ts +41 -0
  21. package/dist/types/{types.js → internal/message/enum.js} +6 -52
  22. package/dist/types/internal/message/messageItens.d.ts +149 -0
  23. package/dist/types/internal/message/messageItens.js +1 -0
  24. package/dist/types/internal/parse.d.ts +53 -0
  25. package/dist/types/internal/parse.js +7 -0
  26. package/dist/types/internal/return.d.ts +17 -0
  27. package/dist/types/internal/return.js +13 -0
  28. package/dist/types/internal/transcript.d.ts +91 -0
  29. package/dist/types/internal/transcript.js +1 -0
  30. package/dist/types/internal/util.d.ts +51 -0
  31. package/dist/types/internal/util.js +1 -0
  32. package/dist/types/public/index.d.ts +2 -0
  33. package/dist/types/public/index.js +2 -0
  34. package/dist/types/public/return.d.ts +25 -0
  35. package/dist/types/public/return.js +21 -0
  36. package/dist/types/public/transcript.d.ts +25 -0
  37. package/dist/types/public/transcript.js +1 -0
  38. package/package.json +6 -2
  39. package/dist/types/types.d.ts +0 -824
@@ -1,3 +1,4 @@
1
- import { JsonData, Uploadable } from "@/types";
2
1
  import Stream from 'stream';
2
+ import { JsonData } from '@/types/internal/message/messageItens.js';
3
+ import { Uploadable } from '@/types/internal/util.js';
3
4
  export declare function output(json: JsonData): Promise<string | Stream | Buffer | Uploadable>;
@@ -1,5 +1,5 @@
1
1
  import { Readable } from 'stream';
2
- import { Html } from "@/renderers/html/html.js";
2
+ import { Html } from "../renderers/html/html.js";
3
3
  export async function output(json) {
4
4
  const objectHTML = new Html(json);
5
5
  const stringHTML = await objectHTML.toHTML();
@@ -1,4 +1,4 @@
1
- import { hexColor } from "@/types";
1
+ import { hexColor } from "@/types/internal/util.js";
2
2
  export declare const FALLBACK_PIXEL = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
3
3
  export declare function sanitize(text: string): string;
4
4
  export declare function isValidHexColor(colorInput: string, canReturnNull: false): hexColor;
@@ -1,25 +1,26 @@
1
1
  export const FALLBACK_PIXEL = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
2
+ const HEX_REGEX = /^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
3
+ const DEFAULT_COLOR = "#000000";
4
+ const SANITIZE_REGEX = /[&<>"']/g;
5
+ const SANITIZE_MAP = {
6
+ "&": "&amp;",
7
+ "<": "&lt;",
8
+ ">": "&gt;",
9
+ '"': "&quot;",
10
+ "'": "&#39;",
11
+ };
2
12
  export function sanitize(text) {
3
- return text
4
- .replace(/&/g, "&amp;")
5
- .replace(/</g, "&lt;")
6
- .replace(/>/g, "&gt;")
7
- .replace(/"/g, "&quot;")
8
- .replace(/'/g, "&#39;");
13
+ return text.replace(SANITIZE_REGEX, ch => SANITIZE_MAP[ch]);
9
14
  }
10
15
  export function isValidHexColor(colorInput, canReturnNull) {
11
16
  if (!colorInput)
12
- return null;
13
- const hexColorRegex = /^#([A-Fa-f0-9]{3,4}|[A-Fa-f0-9]{6}([A-Fa-f0-9]{2})?)$/;
17
+ return canReturnNull ? null : DEFAULT_COLOR;
14
18
  let color = colorInput.trim();
15
- if (/^[A-Fa-f0-9]+$/.test(color)) {
16
- color = "#" + color;
17
- }
18
- if (hexColorRegex.test(color)) {
19
- return color;
20
- }
21
- if (canReturnNull) {
22
- return null;
23
- }
24
- return "#000000"; // Falback to a default hexColor if can't be null
19
+ // Add '#' if don't come with
20
+ if (!color.startsWith('#'))
21
+ color = `#${color}`;
22
+ const isValid = HEX_REGEX.test(color);
23
+ if (isValid)
24
+ return color.toLowerCase();
25
+ return canReturnNull ? null : DEFAULT_COLOR; // Falback to a default hexColor if can't be null
25
26
  }
package/dist/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
- import { ConvertTranscriptOptions, ReturnTypeBase, OutputTypeBase } from "@/types";
2
- export * from '@/types';
3
- export { CustomError, CustomWarn } from "@/core/customMessages.js";
4
- export { output as outputBase } from "@/core/output.js";
5
- export { FALLBACK_PIXEL, isValidHexColor, sanitize } from "@/core/sanitizer.js";
1
+ import { OutputType } from "@/types/internal/parse.js";
2
+ import { ReturnType } from "@/types/public/return.js";
3
+ import { ConvertTranscriptOptions } from "@/types/public/transcript.js";
4
+ export * from '@/types/public/index.js';
6
5
  /**
7
6
  * Converts a JSON transcript string into an HTML transcript.
8
7
  * Depending on the `returnType` option, this function can return a `string`, a `Buffer`, a `Stream`, or an `Uploadable` object.
@@ -11,4 +10,4 @@ export { FALLBACK_PIXEL, isValidHexColor, sanitize } from "@/core/sanitizer.js";
11
10
  * @param options Configuration options for converting the transcript. See {@link ConvertTranscriptOptions} for details.
12
11
  * @returns A promise that resolves to the HTML transcript in the specified format.
13
12
  */
14
- export declare function renderHTMLFromJSON<T extends ReturnTypeBase = typeof ReturnTypeBase.String>(jsonString: string, options?: ConvertTranscriptOptions<T>): Promise<OutputTypeBase<T>>;
13
+ export declare function renderHTMLFromJSON<T extends ReturnType = typeof ReturnType.String>(jsonString: string, options?: ConvertTranscriptOptions<T>): Promise<OutputType<T>>;
package/dist/index.js CHANGED
@@ -1,10 +1,8 @@
1
- import { CustomError } from "@/core/customMessages.js";
2
- import { output } from "@/core/output.js";
3
- import { ReturnTypeBase, ReturnFormat } from "@/types";
4
- export * from '@/types';
5
- export { CustomError, CustomWarn } from "@/core/customMessages.js";
6
- export { output as outputBase } from "@/core/output.js";
7
- export { FALLBACK_PIXEL, isValidHexColor, sanitize } from "@/core/sanitizer.js";
1
+ import { CustomError } from "./core/customMessages.js";
2
+ import { output } from "./core/output.js";
3
+ import { ReturnFormat } from "@/types/internal/return.js";
4
+ import { ReturnType } from "@/types/public/return.js";
5
+ export * from '@/types/public/index.js';
8
6
  /**
9
7
  * Converts a JSON transcript string into an HTML transcript.
10
8
  * Depending on the `returnType` option, this function can return a `string`, a `Buffer`, a `Stream`, or an `Uploadable` object.
@@ -21,7 +19,7 @@ export async function renderHTMLFromJSON(jsonString, options = {}) {
21
19
  options: {
22
20
  ...jsonParse.options,
23
21
  returnFormat: ReturnFormat.HTML,
24
- returnType: options?.returnType ?? ReturnTypeBase.String,
22
+ returnType: options?.returnType ?? ReturnType.String,
25
23
  selfContained: options?.selfContained ?? false,
26
24
  watermark: options.watermark ?? jsonParse.options.watermark
27
25
  }
@@ -0,0 +1,4 @@
1
+ export { CustomError, CustomWarn } from "./core/customMessages.js";
2
+ export { output as outputBase } from "./core/output.js";
3
+ export { FALLBACK_PIXEL, isValidHexColor, sanitize } from "./core/sanitizer.js";
4
+ export * from "@/types/internal/index.js";
@@ -0,0 +1,4 @@
1
+ export { CustomError, CustomWarn } from "./core/customMessages.js";
2
+ export { output as outputBase } from "./core/output.js";
3
+ export { FALLBACK_PIXEL, isValidHexColor, sanitize } from "./core/sanitizer.js";
4
+ export * from "@/types/internal/index.js";
@@ -1,4 +1,4 @@
1
- import { JsonData } from "../../types/types.js";
1
+ import { JsonData } from "@/types/internal/message/messageItens.js";
2
2
  export declare class Html {
3
3
  data: JsonData;
4
4
  dateFormat: Intl.DateTimeFormat;
@@ -1,13 +1,40 @@
1
- import { markdownToHTML } from "@/core/markdown.js";
2
- import { JsonButtonStyle, JsonComponentType } from "../../types/types.js";
1
+ import { markdownToHTML } from "../../core/markdown.js";
3
2
  import { ACTIONROW_CSS, ATTACHMENT_CSS, BUTTON_CSS, COMPONENTS_CSS, COMPONENTSV2_CSS, DEFAULT_CSS, EMBED_CSS, MESSAGE_CSS, POLL_CSS, POLL_RESULT_EMBED_CSS, REACTIONS_CSS } from "./css.js";
4
3
  import { script } from "./js.js";
5
4
  import packageJson from "package.json" with { type: 'json' };
6
- import { sanitize } from "@/core/sanitizer.js";
7
- import highlightHash from "@/assets/highlightJsHash.json" with { type: 'json' };
8
- import transcriptHash from "@/assets/transcriptHash.json" with { type: 'json' };
9
- const COUNT_UNIT = ["KB", "MB", "GB", "TB"];
10
- const BUTTON_COLOR = ["black", "#5865f2", "#323538", "#32c05f", "#be3638", "#323538", "#5865f2"];
5
+ import { sanitize } from "../../core/sanitizer.js";
6
+ import highlightHash from "../../assets/highlightJsHash.json" with { type: 'json' };
7
+ import transcriptHash from "../../assets/transcriptHash.json" with { type: 'json' };
8
+ import { JsonComponentType, JsonButtonStyle } from "@/types/internal/message/enum.js";
9
+ const FILE_SIZE_UNIT = ["KB", "MB", "GB", "TB"];
10
+ const FILE_SIZE_THRESHOLD = 512;
11
+ const BUTTON_COLORS = {
12
+ 1: "#5865f2", // Primary
13
+ 2: "#323538", // Secondary
14
+ 3: "#32c05f", // Sucess
15
+ 4: "#be3638", // Danger
16
+ 5: "#323538", // Link
17
+ 6: "#5865f2" // Premium
18
+ };
19
+ const ICONS = {
20
+ Reply: "reply-icon",
21
+ Download: "download-icon",
22
+ Link: "link-icon",
23
+ };
24
+ const TEXT = {
25
+ TranscriptFooter: 'Transcript generated by <a href="https://github.com/HenriqueMairesse/discord-message-transcript">discord-message-transcript</a>',
26
+ Spoiler: "SPOILER",
27
+ File: {
28
+ DefaultName: "attachment",
29
+ Unavailable: {
30
+ Video: "Video unavailable",
31
+ Audio: "Audio unavailable",
32
+ }
33
+ },
34
+ Pool: {
35
+ Closed: " • Poll closed",
36
+ }
37
+ };
11
38
  export class Html {
12
39
  data;
13
40
  dateFormat;
@@ -82,7 +109,7 @@ export class Html {
82
109
  <div class="messageDiv" id="${sanitize(message.id)}" data-author-id="${sanitize(message.authorId)}">
83
110
  ${message.references && message.references.messageId ?
84
111
  `<div class="messageReply" data-id="${sanitize(message.references.messageId)}">
85
- <svg class="messageReplySvg"><use href="#reply-icon"></use></svg>
112
+ <svg class="messageReplySvg"><use href="#${ICONS.Reply}"></use></svg>
86
113
  <img class="messageReplyImg" src="">
87
114
  <div class="replyBadges"></div>
88
115
  <div class="messageReplyText"></div>
@@ -143,7 +170,7 @@ export class Html {
143
170
  </main>
144
171
  ${options.watermark ? `<footer>
145
172
  <br>
146
- <div style="padding: 1rem 0; font-weight: 700; text-align: center; font-size: 1.5rem; background-color: #2b2d31;">Transcript generated by <a href="https://github.com/HenriqueMairesse/discord-message-transcript">discord-message-transcript</a></div>
173
+ <div style="padding: 1rem 0; font-weight: 700; text-align: center; font-size: 1.5rem; background-color: #2b2d31;">${TEXT.TranscriptFooter}</div>
147
174
  </footer> ` : ""}
148
175
  <script id="authorData" type="application/json">
149
176
  ${JSON.stringify({ authors: this.data.authors })}
@@ -157,7 +184,7 @@ export class Html {
157
184
  const totalVotes = poll.answers.reduce((acc, answer) => acc + answer.count, 0);
158
185
  let footerText = `${totalVotes} votes`;
159
186
  if (poll.isFinalized) {
160
- footerText += ` • Poll closed`;
187
+ footerText += TEXT.Pool.Closed;
161
188
  }
162
189
  else if (poll.expiry) {
163
190
  footerText += ` • ${poll.expiry}`;
@@ -262,39 +289,39 @@ export class Html {
262
289
  }
263
290
  else if (attachment.contentType?.startsWith('video/')) {
264
291
  if (attachment.url == "") {
265
- html = `<video class="attachmentVideo" controls src="${attachment.url}"></video>`;
292
+ html = `<div class="attachmentVideoUnavailable">${TEXT.File.Unavailable.Video}</div>`;
266
293
  }
267
294
  else {
268
- html = `<div class="attachmentVideoUnavailable">Video unavailable</div>`;
295
+ html = `<video class="attachmentVideo" controls src="${attachment.url}"></video>`;
269
296
  }
270
297
  }
271
298
  else if (attachment.contentType?.startsWith('audio/')) {
272
299
  if (attachment.url == "") {
273
- html = `<audio class="attachmentAudio" controls src="${attachment.url}"></audio>`;
300
+ html = `<div class="attachmentAudioUnavailable">${TEXT.File.Unavailable.Audio}</div>`;
274
301
  }
275
302
  else {
276
- html = `<div class="attachmentAudioUnavailable">Audio unavailable</div>`;
303
+ html = `<audio class="attachmentAudio" controls src="${attachment.url}"></audio>`;
277
304
  }
278
305
  }
279
306
  else {
280
307
  let fileSize = attachment.size / 1024;
281
308
  let count = 0;
282
- while (fileSize > 512 && count < COUNT_UNIT.length - 1) {
309
+ while (fileSize > FILE_SIZE_THRESHOLD && count < FILE_SIZE_UNIT.length - 1) {
283
310
  fileSize = fileSize / 1024;
284
311
  count++;
285
312
  }
286
313
  html = `
287
314
  <div class="attachmentFile">
288
315
  <div class="attachmentFileInfo">
289
- <p class="attachmentFileName">${attachment.name ? sanitize(attachment.name) : 'attachment'}</p>
290
- <div class="attachmentFileSize">${fileSize.toFixed(2)} ${COUNT_UNIT[count]}</div>
316
+ <p class="attachmentFileName">${attachment.name ? sanitize(attachment.name) : TEXT.File.DefaultName}</p>
317
+ <div class="attachmentFileSize">${fileSize.toFixed(2)} ${FILE_SIZE_UNIT[count]}</div>
291
318
  </div>
292
319
  ${attachment.url != "" ?
293
320
  `<a class="attachmentDownload" href="${attachment.url}" target="_blank">
294
- <svg class="attachmentDownloadIcon"><use href="#download-icon"></use></svg>
321
+ <svg class="attachmentDownloadIcon"><use href="#${ICONS.Download}"></use></svg>
295
322
  </a>` :
296
323
  `<span class="attachmentDownload">
297
- <svg class="attachmentDownloadIcon"><use href="#download-icon"></use></svg>
324
+ <svg class="attachmentDownloadIcon"><use href="#${ICONS.Download}"></use></svg>
298
325
  </span>`}
299
326
  </div>
300
327
  `;
@@ -327,22 +354,22 @@ export class Html {
327
354
  case JsonComponentType.File: {
328
355
  let fileSize = (component.size ?? 0) / 1024;
329
356
  let count = 0;
330
- while (fileSize > 512 && count < COUNT_UNIT.length - 1) {
357
+ while (fileSize > FILE_SIZE_THRESHOLD && count < FILE_SIZE_UNIT.length - 1) {
331
358
  fileSize = fileSize / 1024;
332
359
  count++;
333
360
  }
334
361
  const html = `
335
362
  <div class="attachmentFile">
336
363
  <div class="attachmentFileInfo">
337
- <p class="attachmentFileName">${component.fileName ? sanitize(component.fileName) : 'file'}</p>
338
- <div class="attachmentFileSize">${fileSize.toFixed(2)} ${COUNT_UNIT[count]}</div>
364
+ <p class="attachmentFileName">${component.fileName ? sanitize(component.fileName) : TEXT.File.DefaultName}</p>
365
+ <div class="attachmentFileSize">${fileSize.toFixed(2)} ${FILE_SIZE_UNIT[count]}</div>
339
366
  </div>
340
367
  ${component.url != "" ?
341
368
  `<a class="attachmentDownload" href="${component.url}" target="_blank">
342
- <svg class="attachmentDownloadIcon"><use href="#download-icon"></use></svg>
369
+ <svg class="attachmentDownloadIcon"><use href="#${ICONS.Download}"></use></svg>
343
370
  </a>` :
344
371
  `<span class="attachmentDownload">
345
- <svg class="attachmentDownloadIcon"><use href="#download-icon"></use></svg>
372
+ <svg class="attachmentDownloadIcon"><use href="#${ICONS.Download}"></use></svg>
346
373
  </span>`}
347
374
  </div>
348
375
  `;
@@ -367,12 +394,11 @@ export class Html {
367
394
  <div class="sectionLeft">
368
395
  ${this.componentBuilder(message, component.components)}
369
396
  </div>
370
- <div class="sectionRight">
397
+ ${component.accessory ? `<div class="sectionRight">
371
398
  ${component.accessory.type == JsonComponentType.Button ? this.buttonBuilder(component.accessory)
372
- : component.accessory.type == JsonComponentType.Thumbnail ? this.spoilerAttachmentBuilder(component.accessory.spoiler, `
373
- <img class="sectionThumbnail" src="${component.accessory.media.url}">
374
- `) : ""}
375
- </div>
399
+ : component.accessory.type == JsonComponentType.Thumbnail ? this.spoilerAttachmentBuilder(component.accessory.spoiler, `<img class="sectionThumbnail" src="${component.accessory.media.url}">`)
400
+ : ""}
401
+ </div>` : ""}
376
402
  </div>
377
403
  `;
378
404
  }
@@ -389,12 +415,12 @@ export class Html {
389
415
  }
390
416
  buttonBuilder(button) {
391
417
  return `
392
- <div class="button" style="background-color: ${BUTTON_COLOR[button.style]}">
418
+ <div class="button" style="background-color: ${BUTTON_COLORS[button.style]}">
393
419
  ${button.style == JsonButtonStyle.Link && button.url ? `
394
420
  <a class="buttonLink" href="${sanitize(button.url)}" target="_blank">
395
421
  ${button.emoji ? `<p class="buttonEmoji">${sanitize(button.emoji)}</p>` : ""}
396
422
  ${button.label ? `<p class="buttonLabel">${sanitize(button.label)}</p>` : ""}
397
- <svg class="buttonLinkIcon"><use href="#link-icon"></use></svg>
423
+ <svg class="buttonLinkIcon"><use href="#${ICONS.Link}"></use></svg>
398
424
  </a>` : `
399
425
  ${button.emoji ? `<p class="buttonEmoji">${sanitize(button.emoji)}</p>` : ""}
400
426
  ${button.label ? `<p class="buttonLabel">${sanitize(button.label)}</p>` : ""}
@@ -434,22 +460,22 @@ export class Html {
434
460
  `;
435
461
  }
436
462
  spoilerAttachmentBuilder(spoiler, html) {
437
- return spoiler ? `<div class="spoilerAttachment"><div class="spoilerAttachmentOverlay">SPOILER</div><div class="spoilerAttachmentContent">${html}</div></div>` : html;
463
+ return spoiler ? `<div class="spoilerAttachment"><div class="spoilerAttachmentOverlay">${TEXT.Spoiler}</div><div class="spoilerAttachmentContent">${html}</div></div>` : html;
438
464
  }
439
465
  svgBuilder() {
440
466
  const { options } = this.data;
441
467
  return `
442
468
  <svg style="display: none;">
443
469
  <defs>
444
- <symbol id="reply-icon" viewBox="0 0 16 16" fill="none">
470
+ <symbol id="${ICONS.Reply}" viewBox="0 0 16 16" fill="none">
445
471
  <g transform="rotate(90 8 8)">
446
472
  <path d="M6 2V9C6 11.5 8.5 14 11 14H14" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/>
447
473
  </g>
448
474
  </symbol>
449
- ${options.includeAttachments ? `<symbol id="download-icon" viewBox="0 -960 960 960">
475
+ ${options.includeAttachments ? `<symbol id="${ICONS.Download}" viewBox="0 -960 960 960">
450
476
  <path d="m720-120 160-160-56-56-64 64v-167h-80v167l-64-64-56 56 160 160ZM560 0v-80h320V0H560ZM240-160q-33 0-56.5-23.5T160-240v-560q0-33 23.5-56.5T240-880h280l240 240v121h-80v-81H480v-200H240v560h240v80H240Zm0-80v-560 560Z"/>
451
477
  </symbol> ` : ""}
452
- ${options.includeButtons ? `<symbol id="link-icon" viewBox="0 -960 960 960" fill="#e3e3e3">
478
+ ${options.includeButtons ? `<symbol id="${ICONS.Link}" viewBox="0 -960 960 960" fill="#e3e3e3">
453
479
  <path d="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h280v80H200v560h560v-280h80v280q0 33-23.5 56.5T760-120H200Zm188-212-56-56 372-372H560v-80h280v280h-80v-144L388-332Z"/>
454
480
  </symbol>` : ""}
455
481
  </defs>
@@ -0,0 +1,7 @@
1
+ export * from "./message/components.js";
2
+ export * from "./message/componentsV2.js";
3
+ export * from "./message/enum.js";
4
+ export * from "./message/messageItens.js";
5
+ export * from "./return.js";
6
+ export * from "./transcript.js";
7
+ export * from "./util.js";
@@ -0,0 +1,7 @@
1
+ export * from "./message/components.js";
2
+ export * from "./message/componentsV2.js";
3
+ export * from "./message/enum.js";
4
+ export * from "./message/messageItens.js";
5
+ export * from "./return.js";
6
+ export * from "./transcript.js";
7
+ export * from "./util.js";
@@ -0,0 +1,252 @@
1
+ import { hexColor } from "../util.js";
2
+ import { JsonButtonStyle, JsonComponentType } from "./enum.js";
3
+ /**
4
+ * A union of all possible select menu types.
5
+ */
6
+ export type JsonSelectMenu = JsonSelectMenuOthers | JsonSelectMenuString;
7
+ /**
8
+ * A JSON-serializable representation of a Discord Action Row component.
9
+ */
10
+ export interface JsonActionRow {
11
+ /**
12
+ * The components within the action row (e.g., buttons, select menus).
13
+ */
14
+ components: (JsonButtonComponent | JsonSelectMenu)[];
15
+ /**
16
+ * The type of the component.
17
+ */
18
+ type: JsonComponentType.ActionRow;
19
+ }
20
+ /**
21
+ * A JSON-serializable representation of a message attachment.
22
+ */
23
+ export interface JsonAttachment {
24
+ /**
25
+ * The MIME type of the attachment.
26
+ */
27
+ contentType: string | null;
28
+ /**
29
+ * The name of the attachment file.
30
+ */
31
+ name: string;
32
+ /**
33
+ * The size of the attachment in bytes.
34
+ */
35
+ size: number;
36
+ /**
37
+ * Whether the attachment is a spoiler.
38
+ */
39
+ spoiler: boolean;
40
+ /**
41
+ * The URL of the attachment.
42
+ */
43
+ url: string;
44
+ }
45
+ /**
46
+ * A JSON-serializable representation of a message author.
47
+ */
48
+ export interface JsonAuthor {
49
+ /**
50
+ * The URL of the author's avatar.
51
+ */
52
+ avatarURL: string;
53
+ /**
54
+ * Whether the author is a bot.
55
+ */
56
+ bot: boolean;
57
+ /**
58
+ * The display name of the author.
59
+ */
60
+ displayName: string;
61
+ /**
62
+ * The guild-specific tag of the author, if any.
63
+ */
64
+ guildTag: string | null;
65
+ /**
66
+ * The ID of the author.
67
+ */
68
+ id: string;
69
+ /**
70
+ * Information about the author as a guild member.
71
+ */
72
+ member: {
73
+ /**
74
+ * The member's display color in hex format.
75
+ */
76
+ displayHexColor: hexColor;
77
+ /**
78
+ * The member's display name in the guild.
79
+ */
80
+ displayName: string;
81
+ } | null;
82
+ /**
83
+ * Whether the author is a system user.
84
+ */
85
+ system: boolean;
86
+ }
87
+ /**
88
+ * A JSON-serializable representation of a button component.
89
+ */
90
+ export interface JsonButtonComponent {
91
+ /**
92
+ * Whether the button is disabled.
93
+ */
94
+ disabled: boolean;
95
+ /**
96
+ * The emoji on the button, if any.
97
+ */
98
+ emoji: string | null;
99
+ /**
100
+ * The label text on the button.
101
+ */
102
+ label: string | null;
103
+ /**
104
+ * The style of the button.
105
+ */
106
+ style: JsonButtonStyle;
107
+ /**
108
+ * The type of the component.
109
+ */
110
+ type: JsonComponentType.Button;
111
+ /**
112
+ * The URL for link-style buttons.
113
+ */
114
+ url: string | null;
115
+ }
116
+ /**
117
+ * A JSON-serializable representation of a message embed.
118
+ */
119
+ export interface JsonEmbed {
120
+ author: {
121
+ name: string;
122
+ url: string | null;
123
+ iconURL: string | null;
124
+ } | null;
125
+ description: string | null;
126
+ fields: {
127
+ inline: boolean | null;
128
+ name: string;
129
+ value: string;
130
+ }[];
131
+ footer: {
132
+ iconURL: string | null;
133
+ text: string;
134
+ } | null;
135
+ hexColor: hexColor | null;
136
+ image: {
137
+ url: string;
138
+ } | null;
139
+ thumbnail: {
140
+ url: string;
141
+ } | null;
142
+ timestamp: string | null;
143
+ title: string | null;
144
+ type: string;
145
+ url: string | null;
146
+ }
147
+ /**
148
+ * A JSON-serializable representation of a poll.
149
+ */
150
+ export interface JsonPoll {
151
+ /**
152
+ * The answers available in the poll.
153
+ */
154
+ answers: JsonPollAnswer[];
155
+ /**
156
+ * A formatted string indicating when the poll expires.
157
+ */
158
+ expiry: string | null;
159
+ /**
160
+ * Whether the poll has been finalized.
161
+ */
162
+ isFinalized: boolean;
163
+ /**
164
+ * The question of the poll.
165
+ */
166
+ question: string;
167
+ }
168
+ /**
169
+ * A JSON-serializable representation of a single answer in a poll.
170
+ */
171
+ export interface JsonPollAnswer {
172
+ /**
173
+ * The number of votes for this answer.
174
+ */
175
+ count: number;
176
+ /**
177
+ * The emoji associated with this answer, if any.
178
+ */
179
+ emoji: {
180
+ id: string | null;
181
+ name: string | null;
182
+ animated: boolean;
183
+ } | null;
184
+ /**
185
+ * The ID of the answer.
186
+ */
187
+ id: number;
188
+ /**
189
+ * The text of the answer.
190
+ */
191
+ text: string;
192
+ }
193
+ /**
194
+ * A JSON-serializable representation of an option in a select menu.
195
+ */
196
+ export interface JsonSelectOption {
197
+ /**
198
+ * The description of the option.
199
+ */
200
+ description: string | null;
201
+ /**
202
+ * The emoji for the option, if any.
203
+ */
204
+ emoji: {
205
+ id: string | null;
206
+ name: string | null;
207
+ animated: boolean;
208
+ } | null;
209
+ /**
210
+ * The user-facing label for the option.
211
+ */
212
+ label: string;
213
+ }
214
+ /**
215
+ * A JSON-serializable representation of a non-string select menu.
216
+ */
217
+ interface JsonSelectMenuOthers {
218
+ /**
219
+ * Whether the select menu is disabled.
220
+ */
221
+ disabled: boolean;
222
+ /**
223
+ * The placeholder text for the select menu.
224
+ */
225
+ placeholder: string | null;
226
+ /**
227
+ * The type of the select menu.
228
+ */
229
+ type: JsonComponentType.UserSelect | JsonComponentType.RoleSelect | JsonComponentType.MentionableSelect | JsonComponentType.ChannelSelect;
230
+ }
231
+ /**
232
+ * A JSON-serializable representation of a string select menu.
233
+ */
234
+ interface JsonSelectMenuString {
235
+ /**
236
+ * Whether the select menu is disabled.
237
+ */
238
+ disabled: boolean;
239
+ /**
240
+ * The options available in the select menu.
241
+ */
242
+ options: JsonSelectOption[];
243
+ /**
244
+ * The placeholder text for the select menu.
245
+ */
246
+ placeholder: string | null;
247
+ /**
248
+ * The type of the select menu.
249
+ */
250
+ type: JsonComponentType.StringSelect;
251
+ }
252
+ export {};
@@ -0,0 +1 @@
1
+ export {};