discord-message-transcript-base 1.2.0-dev.1.2.0.12.0 → 1.2.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.
- package/dist/core/output.js +1 -1
- package/dist/renderers/html/html.d.ts +1 -1
- package/dist/renderers/html/html.js +6 -7
- package/dist/types/types.d.ts +463 -1
- package/dist/types/types.js +36 -0
- package/package.json +4 -1
package/dist/core/output.js
CHANGED
|
@@ -2,7 +2,7 @@ import { Readable } from 'stream';
|
|
|
2
2
|
import { Html } from "../renderers/html/html.js";
|
|
3
3
|
export async function output(json) {
|
|
4
4
|
const objectHTML = new Html(json);
|
|
5
|
-
const stringHTML = objectHTML.toHTML();
|
|
5
|
+
const stringHTML = await objectHTML.toHTML();
|
|
6
6
|
if (json.options.returnType == "string") {
|
|
7
7
|
return stringHTML;
|
|
8
8
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { CustomError } from "../../core/customMessages.js";
|
|
2
1
|
import { markdownToHTML } from "../../core/markdown.js";
|
|
3
2
|
import { JsonButtonStyle, JsonComponentType } from "../../types/types.js";
|
|
4
3
|
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";
|
|
@@ -24,7 +23,7 @@ export class Html {
|
|
|
24
23
|
});
|
|
25
24
|
}
|
|
26
25
|
catch (error) {
|
|
27
|
-
throw new
|
|
26
|
+
throw new Error("[discord-message-transcript] Invalid LocalDate and/or TimeZone.");
|
|
28
27
|
}
|
|
29
28
|
}
|
|
30
29
|
getIcon() {
|
|
@@ -74,8 +73,8 @@ export class Html {
|
|
|
74
73
|
</div>
|
|
75
74
|
`;
|
|
76
75
|
}
|
|
77
|
-
messagesBuilder() {
|
|
78
|
-
return this.data.messages.map(message => {
|
|
76
|
+
async messagesBuilder() {
|
|
77
|
+
return (await Promise.all(this.data.messages.map(async (message) => {
|
|
79
78
|
const date = new Date(message.createdTimestamp);
|
|
80
79
|
return `
|
|
81
80
|
<div class="messageDiv" id="${message.id}" data-author-id="${message.authorId}">
|
|
@@ -104,9 +103,9 @@ export class Html {
|
|
|
104
103
|
</div>
|
|
105
104
|
</div>
|
|
106
105
|
`;
|
|
107
|
-
}).join("");
|
|
106
|
+
}))).join("");
|
|
108
107
|
}
|
|
109
|
-
toHTML() {
|
|
108
|
+
async toHTML() {
|
|
110
109
|
const { options } = this.data;
|
|
111
110
|
const cssContent = `
|
|
112
111
|
${DEFAULT_CSS}
|
|
@@ -138,7 +137,7 @@ export class Html {
|
|
|
138
137
|
${this.headerBuilder()}
|
|
139
138
|
</header>
|
|
140
139
|
<main style="display: flex; flex-direction: column; padding: 2.25%; flex: 1;">
|
|
141
|
-
${this.messagesBuilder()}
|
|
140
|
+
${await this.messagesBuilder()}
|
|
142
141
|
</main>
|
|
143
142
|
${options.watermark ? `<footer>
|
|
144
143
|
<br>
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,19 +1,64 @@
|
|
|
1
1
|
import Stream from "stream";
|
|
2
|
+
/**
|
|
3
|
+
* A union of all component types that can be placed inside a `JsonContainerComponent`.
|
|
4
|
+
*/
|
|
2
5
|
export type JsonComponentInContainer = JsonActionRow | JsonFileComponent | JsonMediaGalleryComponent | JsonSectionComponent | JsonSeparatorComponent | JsonTextDisplayComponent;
|
|
6
|
+
/**
|
|
7
|
+
* A union of all possible select menu types.
|
|
8
|
+
*/
|
|
3
9
|
export type JsonSelectMenu = JsonSelectMenuOthers | JsonSelectMenuString;
|
|
10
|
+
/**
|
|
11
|
+
* A union of all top-level component types that can exist directly in a message.
|
|
12
|
+
*/
|
|
4
13
|
export type JsonTopLevelComponent = JsonActionRow | JsonButtonComponent | JsonSelectMenu | JsonV2Component;
|
|
14
|
+
/**
|
|
15
|
+
* A union of all V2 component types.
|
|
16
|
+
*/
|
|
5
17
|
export type JsonV2Component = JsonContainerComponent | JsonFileComponent | JsonMediaGalleryComponent | JsonSectionComponent | JsonSeparatorComponent | JsonTextDisplayComponent | JsonThumbnailComponent;
|
|
18
|
+
/**
|
|
19
|
+
* A union of all possible timestamp styles for formatting dates and times in Discord.
|
|
20
|
+
*/
|
|
6
21
|
export type StyleTimeStampKey = "t" | "T" | "d" | "D" | "f" | "F";
|
|
22
|
+
/**
|
|
23
|
+
* Represents a BCP 47 language tag for date/time formatting.
|
|
24
|
+
*/
|
|
7
25
|
export type LocalDate = 'ar-EG' | 'ar-SA' | 'bn-BD' | 'bn-IN' | 'cs-CZ' | 'da-DK' | 'de-AT' | 'de-CH' | 'de-DE' | 'el-GR' | 'en-AU' | 'en-CA' | 'en-GB' | 'en-IN' | 'en-US' | 'es-AR' | 'es-CO' | 'es-ES' | 'es-MX' | 'fa-IR' | 'fi-FI' | 'fr-BE' | 'fr-CA' | 'fr-FR' | 'he-IL' | 'hi-IN' | 'hu-HU' | 'id-ID' | 'it-IT' | 'ja-JP' | 'ko-KR' | 'ms-MY' | 'nl-BE' | 'nl-NL' | 'no-NO' | 'pl-PL' | 'pt-BR' | 'pt-PT' | 'ro-RO' | 'ru-RU' | 'sv-SE' | 'th-TH' | 'tr-TR' | 'uk-UA' | 'ur-PK' | 'vi-VN' | 'zh-CN' | 'zh-HK' | 'zh-TW' | (string & {});
|
|
26
|
+
/**
|
|
27
|
+
* Represents an IANA time zone name for date/time formatting.
|
|
28
|
+
*/
|
|
8
29
|
export type TimeZone = 'Africa/Cairo' | 'Africa/Johannesburg' | 'Africa/Lagos' | 'America/Argentina/Buenos_Aires' | 'America/Bogota' | 'America/Los_Angeles' | 'America/Mexico_City' | 'America/New_York' | 'America/Sao_Paulo' | 'America/Toronto' | 'America/Vancouver' | 'Asia/Bangkok' | 'Asia/Dhaka' | 'Asia/Dubai' | 'Asia/Ho_Chi_Minh' | 'Asia/Hong_Kong' | 'Asia/Istanbul' | 'Asia/Jakarta' | 'Asia/Jerusalem' | 'Asia/Karachi' | 'Asia/Kolkata' | 'Asia/Kuala_Lumpur' | 'Asia/Manila' | 'Asia/Riyadh' | 'Asia/Seoul' | 'Asia/Shanghai' | 'Asia/Taipei' | 'Asia/Tehran' | 'Asia/Tokyo' | 'Australia/Melbourne' | 'Australia/Perth' | 'Australia/Sydney' | 'Europe/Amsterdam' | 'Europe/Athens' | 'Europe/Berlin' | 'Europe/Brussels' | 'Europe/Budapest' | 'Europe/Copenhagen' | 'Europe/Helsinki' | 'Europe/Kyiv' | 'Europe/Lisbon' | 'Europe/London' | 'Europe/Madrid' | 'Europe/Moscow' | 'Europe/Oslo' | 'Europe/Paris' | 'Europe/Prague' | 'Europe/Rome' | 'Europe/Stockholm' | 'Europe/Warsaw' | 'Pacific/Auckland' | 'UTC' | (string & {});
|
|
30
|
+
/**
|
|
31
|
+
* A conditional type that maps a `ReturnTypeBase` literal to the actual TypeScript type.
|
|
32
|
+
*/
|
|
9
33
|
export type OutputTypeBase<T extends ReturnTypeBase> = T extends typeof ReturnTypeBase.Buffer ? Buffer : T extends typeof ReturnTypeBase.Stream ? Stream : T extends typeof ReturnTypeBase.Uploadable ? Uploadable : string;
|
|
34
|
+
/**
|
|
35
|
+
* An enum-like object for the possible return types, excluding 'attachment'.
|
|
36
|
+
*/
|
|
10
37
|
export declare const ReturnTypeBase: {
|
|
38
|
+
/**
|
|
39
|
+
* Returns a `Buffer`.
|
|
40
|
+
*/
|
|
11
41
|
readonly Buffer: "buffer";
|
|
42
|
+
/**
|
|
43
|
+
* Returns a `Stream.Readable`.
|
|
44
|
+
*/
|
|
12
45
|
readonly Stream: "stream";
|
|
46
|
+
/**
|
|
47
|
+
* Returns a `string`.
|
|
48
|
+
*/
|
|
13
49
|
readonly String: "string";
|
|
50
|
+
/**
|
|
51
|
+
* Returns an `Uploadable` object.
|
|
52
|
+
*/
|
|
14
53
|
readonly Uploadable: "uploadable";
|
|
15
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* A type representing the possible values of `ReturnTypeBase`.
|
|
57
|
+
*/
|
|
16
58
|
export type ReturnTypeBase = typeof ReturnTypeBase[keyof typeof ReturnTypeBase];
|
|
59
|
+
/**
|
|
60
|
+
* An enum for all possible return types, used for parsing.
|
|
61
|
+
*/
|
|
17
62
|
export declare enum ReturnTypeParse {
|
|
18
63
|
Attachment = "attachment",
|
|
19
64
|
Buffer = "buffer",
|
|
@@ -21,30 +66,99 @@ export declare enum ReturnTypeParse {
|
|
|
21
66
|
String = "string",
|
|
22
67
|
Uploadable = "uploadable"
|
|
23
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* An enum-like object for the possible transcript formats.
|
|
71
|
+
*/
|
|
24
72
|
export declare const ReturnFormat: {
|
|
73
|
+
/**
|
|
74
|
+
* JSON format.
|
|
75
|
+
*/
|
|
25
76
|
readonly JSON: "JSON";
|
|
77
|
+
/**
|
|
78
|
+
* HTML format.
|
|
79
|
+
*/
|
|
26
80
|
readonly HTML: "HTML";
|
|
27
81
|
};
|
|
82
|
+
/**
|
|
83
|
+
* A type representing the possible values of `ReturnFormat`.
|
|
84
|
+
*/
|
|
28
85
|
export type ReturnFormat = typeof ReturnFormat[keyof typeof ReturnFormat];
|
|
86
|
+
/**
|
|
87
|
+
* Base options for creating a transcript.
|
|
88
|
+
*/
|
|
29
89
|
export interface TranscriptOptionsBase {
|
|
90
|
+
/**
|
|
91
|
+
* The name of the generated file.
|
|
92
|
+
*/
|
|
30
93
|
fileName: string;
|
|
94
|
+
/**
|
|
95
|
+
* Whether to include attachments.
|
|
96
|
+
*/
|
|
31
97
|
includeAttachments: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Whether to include buttons.
|
|
100
|
+
*/
|
|
32
101
|
includeButtons: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Whether to include other components (like select menus).
|
|
104
|
+
*/
|
|
33
105
|
includeComponents: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Whether to include empty messages.
|
|
108
|
+
*/
|
|
34
109
|
includeEmpty: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Whether to include embeds.
|
|
112
|
+
*/
|
|
35
113
|
includeEmbeds: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Whether to include polls.
|
|
116
|
+
*/
|
|
36
117
|
includePolls: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Whether to include reactions.
|
|
120
|
+
*/
|
|
37
121
|
includeReactions: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Whether to include V2 components.
|
|
124
|
+
*/
|
|
38
125
|
includeV2Components: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* The locale for date formatting.
|
|
128
|
+
*/
|
|
39
129
|
localDate: LocalDate;
|
|
130
|
+
/**
|
|
131
|
+
* The number of messages to include.
|
|
132
|
+
*/
|
|
40
133
|
quantity: number;
|
|
134
|
+
/**
|
|
135
|
+
* The format of the transcript (HTML or JSON).
|
|
136
|
+
*/
|
|
41
137
|
returnFormat: ReturnFormat;
|
|
138
|
+
/**
|
|
139
|
+
* The type of the returned value (buffer, string, etc.).
|
|
140
|
+
*/
|
|
42
141
|
returnType: ReturnTypeBase;
|
|
142
|
+
/**
|
|
143
|
+
* Whether to save images as base64.
|
|
144
|
+
*/
|
|
43
145
|
saveImages: boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Whether to generate a self-contained HTML file.
|
|
148
|
+
*/
|
|
44
149
|
selfContained: boolean;
|
|
150
|
+
/**
|
|
151
|
+
* The timezone for date formatting.
|
|
152
|
+
*/
|
|
45
153
|
timeZone: TimeZone;
|
|
154
|
+
/**
|
|
155
|
+
* Whether to include the watermark.
|
|
156
|
+
*/
|
|
46
157
|
watermark: boolean;
|
|
47
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* Transcript options used for parsing, with a different `returnType`.
|
|
161
|
+
*/
|
|
48
162
|
export interface TranscriptOptionsParse {
|
|
49
163
|
fileName: string;
|
|
50
164
|
includeAttachments: boolean;
|
|
@@ -69,7 +183,7 @@ export interface TranscriptOptionsParse {
|
|
|
69
183
|
*/
|
|
70
184
|
export type ConvertTranscriptOptions<T extends ReturnTypeBase> = Partial<{
|
|
71
185
|
/**
|
|
72
|
-
* The type
|
|
186
|
+
* The desired output type for the transcript.
|
|
73
187
|
* - ReturnType.String - The transcript content as a string.
|
|
74
188
|
* - ReturnType.Buffer - The transcript content as a `Buffer`.
|
|
75
189
|
* - ReturnType.Stream - The transcript content as a `Stream`.
|
|
@@ -88,56 +202,185 @@ export type ConvertTranscriptOptions<T extends ReturnTypeBase> = Partial<{
|
|
|
88
202
|
*/
|
|
89
203
|
watermark: boolean;
|
|
90
204
|
}>;
|
|
205
|
+
/**
|
|
206
|
+
* Structure containing arrays of all mentions found in the transcript.
|
|
207
|
+
*/
|
|
91
208
|
export interface ArrayMentions {
|
|
209
|
+
/**
|
|
210
|
+
* An array of mentioned channels.
|
|
211
|
+
*/
|
|
92
212
|
channels: JsonMessageMentionsChannels[];
|
|
213
|
+
/**
|
|
214
|
+
* An array of mentioned roles.
|
|
215
|
+
*/
|
|
93
216
|
roles: JsonMessageMentionsRoles[];
|
|
217
|
+
/**
|
|
218
|
+
* An array of mentioned users.
|
|
219
|
+
*/
|
|
94
220
|
users: JsonMessageMentionsUsers[];
|
|
95
221
|
}
|
|
222
|
+
/**
|
|
223
|
+
* A JSON-serializable representation of a Discord Action Row component.
|
|
224
|
+
*/
|
|
96
225
|
export interface JsonActionRow {
|
|
226
|
+
/**
|
|
227
|
+
* The components within the action row (e.g., buttons, select menus).
|
|
228
|
+
*/
|
|
97
229
|
components: (JsonButtonComponent | JsonSelectMenu)[];
|
|
230
|
+
/**
|
|
231
|
+
* The type of the component.
|
|
232
|
+
*/
|
|
98
233
|
type: JsonComponentType.ActionRow;
|
|
99
234
|
}
|
|
235
|
+
/**
|
|
236
|
+
* A JSON-serializable representation of a message attachment.
|
|
237
|
+
*/
|
|
100
238
|
export interface JsonAttachment {
|
|
239
|
+
/**
|
|
240
|
+
* The MIME type of the attachment.
|
|
241
|
+
*/
|
|
101
242
|
contentType: string | null;
|
|
243
|
+
/**
|
|
244
|
+
* The name of the attachment file.
|
|
245
|
+
*/
|
|
102
246
|
name: string;
|
|
247
|
+
/**
|
|
248
|
+
* The size of the attachment in bytes.
|
|
249
|
+
*/
|
|
103
250
|
size: number;
|
|
251
|
+
/**
|
|
252
|
+
* Whether the attachment is a spoiler.
|
|
253
|
+
*/
|
|
104
254
|
spoiler: boolean;
|
|
255
|
+
/**
|
|
256
|
+
* The URL of the attachment.
|
|
257
|
+
*/
|
|
105
258
|
url: string;
|
|
106
259
|
}
|
|
260
|
+
/**
|
|
261
|
+
* A JSON-serializable representation of a message author.
|
|
262
|
+
*/
|
|
107
263
|
export interface JsonAuthor {
|
|
264
|
+
/**
|
|
265
|
+
* The URL of the author's avatar.
|
|
266
|
+
*/
|
|
108
267
|
avatarURL: string;
|
|
268
|
+
/**
|
|
269
|
+
* Whether the author is a bot.
|
|
270
|
+
*/
|
|
109
271
|
bot: boolean;
|
|
272
|
+
/**
|
|
273
|
+
* The display name of the author.
|
|
274
|
+
*/
|
|
110
275
|
displayName: string;
|
|
276
|
+
/**
|
|
277
|
+
* The guild-specific tag of the author, if any.
|
|
278
|
+
*/
|
|
111
279
|
guildTag: string | null;
|
|
280
|
+
/**
|
|
281
|
+
* The ID of the author.
|
|
282
|
+
*/
|
|
112
283
|
id: string;
|
|
284
|
+
/**
|
|
285
|
+
* Information about the author as a guild member.
|
|
286
|
+
*/
|
|
113
287
|
member: {
|
|
288
|
+
/**
|
|
289
|
+
* The member's display color in hex format.
|
|
290
|
+
*/
|
|
114
291
|
displayHexColor: string;
|
|
292
|
+
/**
|
|
293
|
+
* The member's display name in the guild.
|
|
294
|
+
*/
|
|
115
295
|
displayName: string;
|
|
116
296
|
} | null;
|
|
297
|
+
/**
|
|
298
|
+
* Whether the author is a system user.
|
|
299
|
+
*/
|
|
117
300
|
system: boolean;
|
|
118
301
|
}
|
|
302
|
+
/**
|
|
303
|
+
* A JSON-serializable representation of a button component.
|
|
304
|
+
*/
|
|
119
305
|
export interface JsonButtonComponent {
|
|
306
|
+
/**
|
|
307
|
+
* Whether the button is disabled.
|
|
308
|
+
*/
|
|
120
309
|
disabled: boolean;
|
|
310
|
+
/**
|
|
311
|
+
* The emoji on the button, if any.
|
|
312
|
+
*/
|
|
121
313
|
emoji: string | null;
|
|
314
|
+
/**
|
|
315
|
+
* The label text on the button.
|
|
316
|
+
*/
|
|
122
317
|
label: string | null;
|
|
318
|
+
/**
|
|
319
|
+
* The style of the button.
|
|
320
|
+
*/
|
|
123
321
|
style: JsonButtonStyle;
|
|
322
|
+
/**
|
|
323
|
+
* The type of the component.
|
|
324
|
+
*/
|
|
124
325
|
type: JsonComponentType.Button;
|
|
326
|
+
/**
|
|
327
|
+
* The URL for link-style buttons.
|
|
328
|
+
*/
|
|
125
329
|
url: string | null;
|
|
126
330
|
}
|
|
331
|
+
/**
|
|
332
|
+
* A JSON-serializable representation of a V2 container component.
|
|
333
|
+
*/
|
|
127
334
|
export interface JsonContainerComponent {
|
|
335
|
+
/**
|
|
336
|
+
* The components inside the container.
|
|
337
|
+
*/
|
|
128
338
|
components: JsonComponentInContainer[];
|
|
339
|
+
/**
|
|
340
|
+
* The accent color of the container's border.
|
|
341
|
+
*/
|
|
129
342
|
hexAccentColor: string | null;
|
|
343
|
+
/**
|
|
344
|
+
* Whether the container's content is a spoiler.
|
|
345
|
+
*/
|
|
130
346
|
spoiler: boolean;
|
|
347
|
+
/**
|
|
348
|
+
* The type of the component.
|
|
349
|
+
*/
|
|
131
350
|
type: JsonComponentType.Container;
|
|
132
351
|
}
|
|
352
|
+
/**
|
|
353
|
+
* The root object for a JSON transcript, containing all data.
|
|
354
|
+
*/
|
|
133
355
|
export interface JsonData {
|
|
356
|
+
/**
|
|
357
|
+
* A list of all unique authors in the transcript.
|
|
358
|
+
*/
|
|
134
359
|
authors: JsonAuthor[];
|
|
360
|
+
/**
|
|
361
|
+
* Information about the channel where the transcript was created.
|
|
362
|
+
*/
|
|
135
363
|
channel: JsonDataChannel;
|
|
364
|
+
/**
|
|
365
|
+
* Information about the guild.
|
|
366
|
+
*/
|
|
136
367
|
guild: JsonDataGuild | null;
|
|
368
|
+
/**
|
|
369
|
+
* An array of all messages in the transcript.
|
|
370
|
+
*/
|
|
137
371
|
messages: JsonMessage[];
|
|
372
|
+
/**
|
|
373
|
+
* The options used to create this transcript.
|
|
374
|
+
*/
|
|
138
375
|
options: TranscriptOptionsBase;
|
|
376
|
+
/**
|
|
377
|
+
* A list of all mentions found in the messages.
|
|
378
|
+
*/
|
|
139
379
|
mentions: ArrayMentions;
|
|
140
380
|
}
|
|
381
|
+
/**
|
|
382
|
+
* The root object for a JSON transcript, used for parsing.
|
|
383
|
+
*/
|
|
141
384
|
export interface JsonDataParse {
|
|
142
385
|
authors: JsonAuthor[];
|
|
143
386
|
channel: JsonDataChannel;
|
|
@@ -146,21 +389,54 @@ export interface JsonDataParse {
|
|
|
146
389
|
options: TranscriptOptionsParse;
|
|
147
390
|
mentions: ArrayMentions;
|
|
148
391
|
}
|
|
392
|
+
/**
|
|
393
|
+
* A JSON-serializable representation of the transcript's channel.
|
|
394
|
+
*/
|
|
149
395
|
export interface JsonDataChannel {
|
|
396
|
+
/**
|
|
397
|
+
* The ID of the channel.
|
|
398
|
+
*/
|
|
150
399
|
id: string;
|
|
400
|
+
/**
|
|
401
|
+
* The icon URL for the channel (e.g., for DMs).
|
|
402
|
+
*/
|
|
151
403
|
img: string | null;
|
|
404
|
+
/**
|
|
405
|
+
* The name of the channel.
|
|
406
|
+
*/
|
|
152
407
|
name: string;
|
|
408
|
+
/**
|
|
409
|
+
* The parent category of the channel, if any.
|
|
410
|
+
*/
|
|
153
411
|
parent: {
|
|
154
412
|
name: string;
|
|
155
413
|
id: string;
|
|
156
414
|
} | null;
|
|
415
|
+
/**
|
|
416
|
+
* The topic of the channel.
|
|
417
|
+
*/
|
|
157
418
|
topic: string | null;
|
|
158
419
|
}
|
|
420
|
+
/**
|
|
421
|
+
* A JSON-serializable representation of the transcript's guild.
|
|
422
|
+
*/
|
|
159
423
|
export interface JsonDataGuild {
|
|
424
|
+
/**
|
|
425
|
+
* The URL of the guild's icon.
|
|
426
|
+
*/
|
|
160
427
|
icon: string | null;
|
|
428
|
+
/**
|
|
429
|
+
* The ID of the guild.
|
|
430
|
+
*/
|
|
161
431
|
id: string;
|
|
432
|
+
/**
|
|
433
|
+
* The name of the guild.
|
|
434
|
+
*/
|
|
162
435
|
name: string;
|
|
163
436
|
}
|
|
437
|
+
/**
|
|
438
|
+
* A JSON-serializable representation of a message embed.
|
|
439
|
+
*/
|
|
164
440
|
export interface JsonEmbed {
|
|
165
441
|
author: {
|
|
166
442
|
name: string;
|
|
@@ -189,22 +465,52 @@ export interface JsonEmbed {
|
|
|
189
465
|
type: string;
|
|
190
466
|
url: string | null;
|
|
191
467
|
}
|
|
468
|
+
/**
|
|
469
|
+
* A JSON-serializable representation of a V2 file component.
|
|
470
|
+
*/
|
|
192
471
|
export interface JsonFileComponent {
|
|
472
|
+
/**
|
|
473
|
+
* The name of the file.
|
|
474
|
+
*/
|
|
193
475
|
fileName: string | null;
|
|
476
|
+
/**
|
|
477
|
+
* The size of the file in bytes.
|
|
478
|
+
*/
|
|
194
479
|
size: number;
|
|
480
|
+
/**
|
|
481
|
+
* Whether the file is a spoiler.
|
|
482
|
+
*/
|
|
195
483
|
spoiler: boolean;
|
|
484
|
+
/**
|
|
485
|
+
* The type of the component.
|
|
486
|
+
*/
|
|
196
487
|
type: JsonComponentType.File;
|
|
488
|
+
/**
|
|
489
|
+
* The URL of the file.
|
|
490
|
+
*/
|
|
197
491
|
url: string;
|
|
198
492
|
}
|
|
493
|
+
/**
|
|
494
|
+
* A JSON-serializable representation of a V2 media gallery component.
|
|
495
|
+
*/
|
|
199
496
|
export interface JsonMediaGalleryComponent {
|
|
497
|
+
/**
|
|
498
|
+
* The items within the media gallery.
|
|
499
|
+
*/
|
|
200
500
|
items: {
|
|
201
501
|
media: {
|
|
202
502
|
url: string;
|
|
203
503
|
};
|
|
204
504
|
spoiler: boolean;
|
|
205
505
|
}[];
|
|
506
|
+
/**
|
|
507
|
+
* The type of the component.
|
|
508
|
+
*/
|
|
206
509
|
type: JsonComponentType.MediaGallery;
|
|
207
510
|
}
|
|
511
|
+
/**
|
|
512
|
+
* A JSON-serializable representation of a Discord message.
|
|
513
|
+
*/
|
|
208
514
|
export interface JsonMessage {
|
|
209
515
|
attachments: JsonAttachment[];
|
|
210
516
|
authorId: string;
|
|
@@ -221,80 +527,203 @@ export interface JsonMessage {
|
|
|
221
527
|
} | null;
|
|
222
528
|
system: boolean;
|
|
223
529
|
}
|
|
530
|
+
/**
|
|
531
|
+
* Structure containing arrays of mentions found in a message.
|
|
532
|
+
*/
|
|
224
533
|
export interface JsonMessageMentions {
|
|
225
534
|
channels: JsonMessageMentionsChannels[];
|
|
226
535
|
roles: JsonMessageMentionsRoles[];
|
|
227
536
|
users: JsonMessageMentionsUsers[];
|
|
228
537
|
}
|
|
538
|
+
/**
|
|
539
|
+
* A JSON-serializable representation of a channel mention.
|
|
540
|
+
*/
|
|
229
541
|
export interface JsonMessageMentionsChannels {
|
|
230
542
|
id: string;
|
|
231
543
|
name: string | null;
|
|
232
544
|
}
|
|
545
|
+
/**
|
|
546
|
+
* A JSON-serializable representation of a role mention.
|
|
547
|
+
*/
|
|
233
548
|
export interface JsonMessageMentionsRoles {
|
|
234
549
|
id: string;
|
|
235
550
|
name: string;
|
|
236
551
|
color: string;
|
|
237
552
|
}
|
|
553
|
+
/**
|
|
554
|
+
* A JSON-serializable representation of a user mention.
|
|
555
|
+
*/
|
|
238
556
|
export interface JsonMessageMentionsUsers {
|
|
239
557
|
id: string;
|
|
240
558
|
name: string;
|
|
241
559
|
color: string | null;
|
|
242
560
|
}
|
|
561
|
+
/**
|
|
562
|
+
* A JSON-serializable representation of a poll.
|
|
563
|
+
*/
|
|
243
564
|
export interface JsonPoll {
|
|
565
|
+
/**
|
|
566
|
+
* The answers available in the poll.
|
|
567
|
+
*/
|
|
244
568
|
answers: JsonPollAnswer[];
|
|
569
|
+
/**
|
|
570
|
+
* A formatted string indicating when the poll expires.
|
|
571
|
+
*/
|
|
245
572
|
expiry: string | null;
|
|
573
|
+
/**
|
|
574
|
+
* Whether the poll has been finalized.
|
|
575
|
+
*/
|
|
246
576
|
isFinalized: boolean;
|
|
577
|
+
/**
|
|
578
|
+
* The question of the poll.
|
|
579
|
+
*/
|
|
247
580
|
question: string;
|
|
248
581
|
}
|
|
582
|
+
/**
|
|
583
|
+
* A JSON-serializable representation of a single answer in a poll.
|
|
584
|
+
*/
|
|
249
585
|
export interface JsonPollAnswer {
|
|
586
|
+
/**
|
|
587
|
+
* The number of votes for this answer.
|
|
588
|
+
*/
|
|
250
589
|
count: number;
|
|
590
|
+
/**
|
|
591
|
+
* The emoji associated with this answer, if any.
|
|
592
|
+
*/
|
|
251
593
|
emoji: {
|
|
252
594
|
id: string | null;
|
|
253
595
|
name: string | null;
|
|
254
596
|
animated: boolean;
|
|
255
597
|
} | null;
|
|
598
|
+
/**
|
|
599
|
+
* The ID of the answer.
|
|
600
|
+
*/
|
|
256
601
|
id: number;
|
|
602
|
+
/**
|
|
603
|
+
* The text of the answer.
|
|
604
|
+
*/
|
|
257
605
|
text: string;
|
|
258
606
|
}
|
|
607
|
+
/**
|
|
608
|
+
* A JSON-serializable representation of a message reaction.
|
|
609
|
+
*/
|
|
259
610
|
export interface JsonReaction {
|
|
611
|
+
/**
|
|
612
|
+
* The number of times the emoji was reacted.
|
|
613
|
+
*/
|
|
260
614
|
count: number;
|
|
615
|
+
/**
|
|
616
|
+
* The emoji that was reacted.
|
|
617
|
+
*/
|
|
261
618
|
emoji: string;
|
|
262
619
|
}
|
|
620
|
+
/**
|
|
621
|
+
* A JSON-serializable representation of a V2 section component.
|
|
622
|
+
*/
|
|
263
623
|
export interface JsonSectionComponent {
|
|
624
|
+
/**
|
|
625
|
+
* The accessory component on the right side of the section.
|
|
626
|
+
*/
|
|
264
627
|
accessory: JsonButtonComponent | JsonThumbnailComponent;
|
|
628
|
+
/**
|
|
629
|
+
* The components inside the section.
|
|
630
|
+
*/
|
|
265
631
|
components: JsonTextDisplayComponent[];
|
|
632
|
+
/**
|
|
633
|
+
* The type of the component.
|
|
634
|
+
*/
|
|
266
635
|
type: JsonComponentType.Section;
|
|
267
636
|
}
|
|
637
|
+
/**
|
|
638
|
+
* A JSON-serializable representation of an option in a select menu.
|
|
639
|
+
*/
|
|
268
640
|
export interface JsonSelectOption {
|
|
641
|
+
/**
|
|
642
|
+
* The description of the option.
|
|
643
|
+
*/
|
|
269
644
|
description: string | null;
|
|
645
|
+
/**
|
|
646
|
+
* The emoji for the option, if any.
|
|
647
|
+
*/
|
|
270
648
|
emoji: {
|
|
271
649
|
id: string | null;
|
|
272
650
|
name: string | null;
|
|
273
651
|
animated: boolean;
|
|
274
652
|
} | null;
|
|
653
|
+
/**
|
|
654
|
+
* The user-facing label for the option.
|
|
655
|
+
*/
|
|
275
656
|
label: string;
|
|
276
657
|
}
|
|
658
|
+
/**
|
|
659
|
+
* A JSON-serializable representation of a V2 separator component.
|
|
660
|
+
*/
|
|
277
661
|
export interface JsonSeparatorComponent {
|
|
662
|
+
/**
|
|
663
|
+
* Whether the separator is a visible line.
|
|
664
|
+
*/
|
|
278
665
|
divider: boolean;
|
|
666
|
+
/**
|
|
667
|
+
* The spacing size of the separator.
|
|
668
|
+
*/
|
|
279
669
|
spacing: JsonSeparatorSpacingSize;
|
|
670
|
+
/**
|
|
671
|
+
* The type of the component.
|
|
672
|
+
*/
|
|
280
673
|
type: JsonComponentType.Separator;
|
|
281
674
|
}
|
|
675
|
+
/**
|
|
676
|
+
* A JSON-serializable representation of a V2 text display component.
|
|
677
|
+
*/
|
|
282
678
|
export interface JsonTextDisplayComponent {
|
|
679
|
+
/**
|
|
680
|
+
* The content of the text display.
|
|
681
|
+
*/
|
|
283
682
|
content: string;
|
|
683
|
+
/**
|
|
684
|
+
* The type of the component.
|
|
685
|
+
*/
|
|
284
686
|
type: JsonComponentType.TextDisplay;
|
|
285
687
|
}
|
|
688
|
+
/**
|
|
689
|
+
* A JSON-serializable representation of a V2 thumbnail component.
|
|
690
|
+
*/
|
|
286
691
|
export interface JsonThumbnailComponent {
|
|
692
|
+
/**
|
|
693
|
+
* The media information for the thumbnail.
|
|
694
|
+
*/
|
|
287
695
|
media: {
|
|
288
696
|
url: string;
|
|
289
697
|
};
|
|
698
|
+
/**
|
|
699
|
+
* Whether the thumbnail is a spoiler.
|
|
700
|
+
*/
|
|
290
701
|
spoiler: boolean;
|
|
702
|
+
/**
|
|
703
|
+
* The type of the component.
|
|
704
|
+
*/
|
|
291
705
|
type: JsonComponentType.Thumbnail;
|
|
292
706
|
}
|
|
707
|
+
/**
|
|
708
|
+
* Represents an object that can be uploaded.
|
|
709
|
+
*/
|
|
293
710
|
export interface Uploadable {
|
|
711
|
+
/**
|
|
712
|
+
* The content to be uploaded.
|
|
713
|
+
*/
|
|
294
714
|
content: string;
|
|
715
|
+
/**
|
|
716
|
+
* The MIME type of the content.
|
|
717
|
+
*/
|
|
295
718
|
contentType: "application/json" | "text/html";
|
|
719
|
+
/**
|
|
720
|
+
* The name of the file.
|
|
721
|
+
*/
|
|
296
722
|
fileName: string;
|
|
297
723
|
}
|
|
724
|
+
/**
|
|
725
|
+
* An enum representing the styles of a Discord button.
|
|
726
|
+
*/
|
|
298
727
|
export declare enum JsonButtonStyle {
|
|
299
728
|
Primary = 1,
|
|
300
729
|
Secondary = 2,
|
|
@@ -303,6 +732,9 @@ export declare enum JsonButtonStyle {
|
|
|
303
732
|
Link = 5,
|
|
304
733
|
Premium = 6
|
|
305
734
|
}
|
|
735
|
+
/**
|
|
736
|
+
* An enum representing all known component types.
|
|
737
|
+
*/
|
|
306
738
|
export declare enum JsonComponentType {
|
|
307
739
|
ActionRow = 1,
|
|
308
740
|
Button = 2,
|
|
@@ -323,19 +755,49 @@ export declare enum JsonComponentType {
|
|
|
323
755
|
Label = 18,
|
|
324
756
|
FileUpload = 19
|
|
325
757
|
}
|
|
758
|
+
/**
|
|
759
|
+
* An enum representing the spacing size of a separator component.
|
|
760
|
+
*/
|
|
326
761
|
export declare enum JsonSeparatorSpacingSize {
|
|
327
762
|
Small = 1,
|
|
328
763
|
Large = 2
|
|
329
764
|
}
|
|
765
|
+
/**
|
|
766
|
+
* A JSON-serializable representation of a non-string select menu.
|
|
767
|
+
*/
|
|
330
768
|
interface JsonSelectMenuOthers {
|
|
769
|
+
/**
|
|
770
|
+
* Whether the select menu is disabled.
|
|
771
|
+
*/
|
|
331
772
|
disabled: boolean;
|
|
773
|
+
/**
|
|
774
|
+
* The placeholder text for the select menu.
|
|
775
|
+
*/
|
|
332
776
|
placeholder: string | null;
|
|
777
|
+
/**
|
|
778
|
+
* The type of the select menu.
|
|
779
|
+
*/
|
|
333
780
|
type: JsonComponentType.UserSelect | JsonComponentType.RoleSelect | JsonComponentType.MentionableSelect | JsonComponentType.ChannelSelect;
|
|
334
781
|
}
|
|
782
|
+
/**
|
|
783
|
+
* A JSON-serializable representation of a string select menu.
|
|
784
|
+
*/
|
|
335
785
|
interface JsonSelectMenuString {
|
|
786
|
+
/**
|
|
787
|
+
* Whether the select menu is disabled.
|
|
788
|
+
*/
|
|
336
789
|
disabled: boolean;
|
|
790
|
+
/**
|
|
791
|
+
* The options available in the select menu.
|
|
792
|
+
*/
|
|
337
793
|
options: JsonSelectOption[];
|
|
794
|
+
/**
|
|
795
|
+
* The placeholder text for the select menu.
|
|
796
|
+
*/
|
|
338
797
|
placeholder: string | null;
|
|
798
|
+
/**
|
|
799
|
+
* The type of the select menu.
|
|
800
|
+
*/
|
|
339
801
|
type: JsonComponentType.StringSelect;
|
|
340
802
|
}
|
|
341
803
|
export {};
|
package/dist/types/types.js
CHANGED
|
@@ -1,9 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An enum-like object for the possible return types, excluding 'attachment'.
|
|
3
|
+
*/
|
|
1
4
|
export const ReturnTypeBase = {
|
|
5
|
+
/**
|
|
6
|
+
* Returns a `Buffer`.
|
|
7
|
+
*/
|
|
2
8
|
Buffer: "buffer",
|
|
9
|
+
/**
|
|
10
|
+
* Returns a `Stream.Readable`.
|
|
11
|
+
*/
|
|
3
12
|
Stream: "stream",
|
|
13
|
+
/**
|
|
14
|
+
* Returns a `string`.
|
|
15
|
+
*/
|
|
4
16
|
String: "string",
|
|
17
|
+
/**
|
|
18
|
+
* Returns an `Uploadable` object.
|
|
19
|
+
*/
|
|
5
20
|
Uploadable: "uploadable"
|
|
6
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* An enum for all possible return types, used for parsing.
|
|
24
|
+
*/
|
|
7
25
|
export var ReturnTypeParse;
|
|
8
26
|
(function (ReturnTypeParse) {
|
|
9
27
|
ReturnTypeParse["Attachment"] = "attachment";
|
|
@@ -13,10 +31,22 @@ export var ReturnTypeParse;
|
|
|
13
31
|
ReturnTypeParse["Uploadable"] = "uploadable";
|
|
14
32
|
})(ReturnTypeParse || (ReturnTypeParse = {}));
|
|
15
33
|
;
|
|
34
|
+
/**
|
|
35
|
+
* An enum-like object for the possible transcript formats.
|
|
36
|
+
*/
|
|
16
37
|
export const ReturnFormat = {
|
|
38
|
+
/**
|
|
39
|
+
* JSON format.
|
|
40
|
+
*/
|
|
17
41
|
JSON: "JSON",
|
|
42
|
+
/**
|
|
43
|
+
* HTML format.
|
|
44
|
+
*/
|
|
18
45
|
HTML: "HTML"
|
|
19
46
|
};
|
|
47
|
+
/**
|
|
48
|
+
* An enum representing the styles of a Discord button.
|
|
49
|
+
*/
|
|
20
50
|
export var JsonButtonStyle;
|
|
21
51
|
(function (JsonButtonStyle) {
|
|
22
52
|
JsonButtonStyle[JsonButtonStyle["Primary"] = 1] = "Primary";
|
|
@@ -26,6 +56,9 @@ export var JsonButtonStyle;
|
|
|
26
56
|
JsonButtonStyle[JsonButtonStyle["Link"] = 5] = "Link";
|
|
27
57
|
JsonButtonStyle[JsonButtonStyle["Premium"] = 6] = "Premium";
|
|
28
58
|
})(JsonButtonStyle || (JsonButtonStyle = {}));
|
|
59
|
+
/**
|
|
60
|
+
* An enum representing all known component types.
|
|
61
|
+
*/
|
|
29
62
|
export var JsonComponentType;
|
|
30
63
|
(function (JsonComponentType) {
|
|
31
64
|
JsonComponentType[JsonComponentType["ActionRow"] = 1] = "ActionRow";
|
|
@@ -47,6 +80,9 @@ export var JsonComponentType;
|
|
|
47
80
|
JsonComponentType[JsonComponentType["Label"] = 18] = "Label";
|
|
48
81
|
JsonComponentType[JsonComponentType["FileUpload"] = 19] = "FileUpload";
|
|
49
82
|
})(JsonComponentType || (JsonComponentType = {}));
|
|
83
|
+
/**
|
|
84
|
+
* An enum representing the spacing size of a separator component.
|
|
85
|
+
*/
|
|
50
86
|
export var JsonSeparatorSpacingSize;
|
|
51
87
|
(function (JsonSeparatorSpacingSize) {
|
|
52
88
|
JsonSeparatorSpacingSize[JsonSeparatorSpacingSize["Small"] = 1] = "Small";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "discord-message-transcript-base",
|
|
3
|
-
"version": "1.2.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -32,6 +32,9 @@
|
|
|
32
32
|
"@types/node": "^25.0.6",
|
|
33
33
|
"typescript": "^5.9.3"
|
|
34
34
|
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
35
38
|
"scripts": {
|
|
36
39
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
37
40
|
"build": "tsc && node scripts/copy.js"
|