discord-message-transcript-base 1.0.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.
@@ -0,0 +1,341 @@
1
+ import Stream from "stream";
2
+ export type JsonComponentInContainer = JsonActionRow | JsonFileComponent | JsonMediaGalleryComponent | JsonSectionComponent | JsonSeparatorComponent | JsonTextDisplayComponent;
3
+ export type JsonSelectMenu = JsonSelectMenuOthers | JsonSelectMenuString;
4
+ export type JsonTopLevelComponent = JsonActionRow | JsonButtonComponent | JsonSelectMenu | JsonV2Component;
5
+ export type JsonV2Component = JsonContainerComponent | JsonFileComponent | JsonMediaGalleryComponent | JsonSectionComponent | JsonSeparatorComponent | JsonTextDisplayComponent | JsonThumbnailComponent;
6
+ export type StyleTimeStampKey = "t" | "T" | "d" | "D" | "f" | "F";
7
+ 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 & {});
8
+ 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 & {});
9
+ 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;
10
+ export declare const ReturnTypeBase: {
11
+ readonly Buffer: "buffer";
12
+ readonly Stream: "stream";
13
+ readonly String: "string";
14
+ readonly Uploadable: "uploadable";
15
+ };
16
+ export type ReturnTypeBase = typeof ReturnTypeBase[keyof typeof ReturnTypeBase];
17
+ export declare enum ReturnTypeParse {
18
+ Attachment = "attachment",
19
+ Buffer = "buffer",
20
+ Stream = "stream",
21
+ String = "string",
22
+ Uploadable = "uploadable"
23
+ }
24
+ export declare const ReturnFormat: {
25
+ readonly JSON: "JSON";
26
+ readonly HTML: "HTML";
27
+ };
28
+ export type ReturnFormat = typeof ReturnFormat[keyof typeof ReturnFormat];
29
+ export interface TranscriptOptionsBase {
30
+ fileName: string;
31
+ includeAttachments: boolean;
32
+ includeButtons: boolean;
33
+ includeComponents: boolean;
34
+ includeEmpty: boolean;
35
+ includeEmbeds: boolean;
36
+ includePolls: boolean;
37
+ includeReactions: boolean;
38
+ includeV2Components: boolean;
39
+ localDate: LocalDate;
40
+ quantity: number;
41
+ returnFormat: ReturnFormat;
42
+ returnType: ReturnTypeBase;
43
+ saveImages: boolean;
44
+ selfContained: boolean;
45
+ timeZone: TimeZone;
46
+ watermark: boolean;
47
+ }
48
+ export interface TranscriptOptionsParse {
49
+ fileName: string;
50
+ includeAttachments: boolean;
51
+ includeButtons: boolean;
52
+ includeComponents: boolean;
53
+ includeEmpty: boolean;
54
+ includeEmbeds: boolean;
55
+ includePolls: boolean;
56
+ includeReactions: boolean;
57
+ includeV2Components: boolean;
58
+ localDate: LocalDate;
59
+ quantity: number;
60
+ returnFormat: ReturnFormat;
61
+ returnType: ReturnTypeParse;
62
+ saveImages: boolean;
63
+ selfContained: boolean;
64
+ timeZone: TimeZone;
65
+ watermark: boolean;
66
+ }
67
+ /**
68
+ * Options for converting a JSON transcript to HTML.
69
+ */
70
+ export type ConvertTranscriptOptions<T extends ReturnTypeBase> = Partial<{
71
+ /**
72
+ * The type of the returned value.
73
+ * - ReturnType.String - The transcript content as a string.
74
+ * - ReturnType.Buffer - The transcript content as a `Buffer`.
75
+ * - ReturnType.Stream - The transcript content as a `Stream`.
76
+ * - ReturnType.Uploadable` - An object with `content`, `contentType` and `fileName`.
77
+ * @default ReturnType.String
78
+ */
79
+ returnType: T;
80
+ /**
81
+ * Whether the generated HTML should be self-contained (CSS and JS in HTML).
82
+ * @default false
83
+ */
84
+ selfContained: boolean;
85
+ /**
86
+ * If you want to include the watermark.
87
+ * @default true
88
+ */
89
+ watermark: boolean;
90
+ }>;
91
+ export interface ArrayMentions {
92
+ channels: JsonMessageMentionsChannels[];
93
+ roles: JsonMessageMentionsRoles[];
94
+ users: JsonMessageMentionsUsers[];
95
+ }
96
+ export interface JsonActionRow {
97
+ components: (JsonButtonComponent | JsonSelectMenu)[];
98
+ type: JsonComponentType.ActionRow;
99
+ }
100
+ export interface JsonAttachment {
101
+ contentType: string | null;
102
+ name: string;
103
+ size: number;
104
+ spoiler: boolean;
105
+ url: string;
106
+ }
107
+ export interface JsonAuthor {
108
+ avatarURL: string;
109
+ bot: boolean;
110
+ displayName: string;
111
+ guildTag: string | null;
112
+ id: string;
113
+ member: {
114
+ displayHexColor: string;
115
+ displayName: string;
116
+ } | null;
117
+ system: boolean;
118
+ }
119
+ export interface JsonButtonComponent {
120
+ disabled: boolean;
121
+ emoji: string | null;
122
+ label: string | null;
123
+ style: JsonButtonStyle;
124
+ type: JsonComponentType.Button;
125
+ url: string | null;
126
+ }
127
+ export interface JsonContainerComponent {
128
+ components: JsonComponentInContainer[];
129
+ hexAccentColor: string | null;
130
+ spoiler: boolean;
131
+ type: JsonComponentType.Container;
132
+ }
133
+ export interface JsonData {
134
+ authors: JsonAuthor[];
135
+ channel: JsonDataChannel;
136
+ guild: JsonDataGuild | null;
137
+ messages: JsonMessage[];
138
+ options: TranscriptOptionsBase;
139
+ mentions: ArrayMentions;
140
+ }
141
+ export interface JsonDataParse {
142
+ authors: JsonAuthor[];
143
+ channel: JsonDataChannel;
144
+ guild: JsonDataGuild | null;
145
+ messages: JsonMessage[];
146
+ options: TranscriptOptionsParse;
147
+ mentions: ArrayMentions;
148
+ }
149
+ export interface JsonDataChannel {
150
+ id: string;
151
+ img: string | null;
152
+ name: string;
153
+ parent: {
154
+ name: string;
155
+ id: string;
156
+ } | null;
157
+ topic: string | null;
158
+ }
159
+ export interface JsonDataGuild {
160
+ icon: string | null;
161
+ id: string;
162
+ name: string;
163
+ }
164
+ export interface JsonEmbed {
165
+ author: {
166
+ name: string;
167
+ url: string | null;
168
+ iconURL: string | null;
169
+ } | null;
170
+ description: string | null;
171
+ fields: {
172
+ inline: boolean | null;
173
+ name: string;
174
+ value: string;
175
+ }[];
176
+ footer: {
177
+ iconURL: string | null;
178
+ text: string;
179
+ } | null;
180
+ hexColor: string | null;
181
+ image: {
182
+ url: string;
183
+ } | null;
184
+ thumbnail: {
185
+ url: string;
186
+ } | null;
187
+ timestamp: string | null;
188
+ title: string | null;
189
+ type: string;
190
+ url: string | null;
191
+ }
192
+ export interface JsonFileComponent {
193
+ fileName: string | null;
194
+ size: number;
195
+ spoiler: boolean;
196
+ type: JsonComponentType.File;
197
+ url: string;
198
+ }
199
+ export interface JsonMediaGalleryComponent {
200
+ items: {
201
+ media: {
202
+ url: string;
203
+ };
204
+ spoiler: boolean;
205
+ }[];
206
+ type: JsonComponentType.MediaGallery;
207
+ }
208
+ export interface JsonMessage {
209
+ attachments: JsonAttachment[];
210
+ authorId: string;
211
+ components: JsonTopLevelComponent[];
212
+ content: string;
213
+ createdTimestamp: number;
214
+ embeds: JsonEmbed[];
215
+ id: string;
216
+ mentions: boolean;
217
+ poll: JsonPoll | null;
218
+ reactions: JsonReaction[];
219
+ references: {
220
+ messageId: string | null;
221
+ } | null;
222
+ system: boolean;
223
+ }
224
+ export interface JsonMessageMentions {
225
+ channels: JsonMessageMentionsChannels[];
226
+ roles: JsonMessageMentionsRoles[];
227
+ users: JsonMessageMentionsUsers[];
228
+ }
229
+ export interface JsonMessageMentionsChannels {
230
+ id: string;
231
+ name: string | null;
232
+ }
233
+ export interface JsonMessageMentionsRoles {
234
+ id: string;
235
+ name: string;
236
+ color: string;
237
+ }
238
+ export interface JsonMessageMentionsUsers {
239
+ id: string;
240
+ name: string;
241
+ color: string | null;
242
+ }
243
+ export interface JsonPoll {
244
+ answers: JsonPollAnswer[];
245
+ expiry: string | null;
246
+ isFinalized: boolean;
247
+ question: string;
248
+ }
249
+ export interface JsonPollAnswer {
250
+ count: number;
251
+ emoji: {
252
+ id: string | null;
253
+ name: string | null;
254
+ animated: boolean;
255
+ } | null;
256
+ id: number;
257
+ text: string;
258
+ }
259
+ export interface JsonReaction {
260
+ count: number;
261
+ emoji: string;
262
+ }
263
+ export interface JsonSectionComponent {
264
+ accessory: JsonButtonComponent | JsonThumbnailComponent;
265
+ components: JsonTextDisplayComponent[];
266
+ type: JsonComponentType.Section;
267
+ }
268
+ export interface JsonSelectOption {
269
+ description: string | null;
270
+ emoji: {
271
+ id: string | null;
272
+ name: string | null;
273
+ animated: boolean;
274
+ } | null;
275
+ label: string;
276
+ }
277
+ export interface JsonSeparatorComponent {
278
+ divider: boolean;
279
+ spacing: JsonSeparatorSpacingSize;
280
+ type: JsonComponentType.Separator;
281
+ }
282
+ export interface JsonTextDisplayComponent {
283
+ content: string;
284
+ type: JsonComponentType.TextDisplay;
285
+ }
286
+ export interface JsonThumbnailComponent {
287
+ media: {
288
+ url: string;
289
+ };
290
+ spoiler: boolean;
291
+ type: JsonComponentType.Thumbnail;
292
+ }
293
+ export interface Uploadable {
294
+ content: string;
295
+ contentType: "application/json" | "text/html";
296
+ fileName: string;
297
+ }
298
+ export declare enum JsonButtonStyle {
299
+ Primary = 1,
300
+ Secondary = 2,
301
+ Success = 3,
302
+ Danger = 4,
303
+ Link = 5,
304
+ Premium = 6
305
+ }
306
+ export declare enum JsonComponentType {
307
+ ActionRow = 1,
308
+ Button = 2,
309
+ StringSelect = 3,
310
+ TextInput = 4,
311
+ UserSelect = 5,
312
+ RoleSelect = 6,
313
+ MentionableSelect = 7,
314
+ ChannelSelect = 8,
315
+ Section = 9,
316
+ TextDisplay = 10,
317
+ Thumbnail = 11,
318
+ MediaGallery = 12,
319
+ File = 13,
320
+ Separator = 14,
321
+ ContentInventoryEntry = 16,
322
+ Container = 17,
323
+ Label = 18,
324
+ FileUpload = 19
325
+ }
326
+ export declare enum JsonSeparatorSpacingSize {
327
+ Small = 1,
328
+ Large = 2
329
+ }
330
+ interface JsonSelectMenuOthers {
331
+ disabled: boolean;
332
+ placeholder: string | null;
333
+ type: JsonComponentType.UserSelect | JsonComponentType.RoleSelect | JsonComponentType.MentionableSelect | JsonComponentType.ChannelSelect;
334
+ }
335
+ interface JsonSelectMenuString {
336
+ disabled: boolean;
337
+ options: JsonSelectOption[];
338
+ placeholder: string | null;
339
+ type: JsonComponentType.StringSelect;
340
+ }
341
+ export {};
@@ -0,0 +1,54 @@
1
+ export const ReturnTypeBase = {
2
+ Buffer: "buffer",
3
+ Stream: "stream",
4
+ String: "string",
5
+ Uploadable: "uploadable"
6
+ };
7
+ export var ReturnTypeParse;
8
+ (function (ReturnTypeParse) {
9
+ ReturnTypeParse["Attachment"] = "attachment";
10
+ ReturnTypeParse["Buffer"] = "buffer";
11
+ ReturnTypeParse["Stream"] = "stream";
12
+ ReturnTypeParse["String"] = "string";
13
+ ReturnTypeParse["Uploadable"] = "uploadable";
14
+ })(ReturnTypeParse || (ReturnTypeParse = {}));
15
+ ;
16
+ export const ReturnFormat = {
17
+ JSON: "JSON",
18
+ HTML: "HTML"
19
+ };
20
+ export var JsonButtonStyle;
21
+ (function (JsonButtonStyle) {
22
+ JsonButtonStyle[JsonButtonStyle["Primary"] = 1] = "Primary";
23
+ JsonButtonStyle[JsonButtonStyle["Secondary"] = 2] = "Secondary";
24
+ JsonButtonStyle[JsonButtonStyle["Success"] = 3] = "Success";
25
+ JsonButtonStyle[JsonButtonStyle["Danger"] = 4] = "Danger";
26
+ JsonButtonStyle[JsonButtonStyle["Link"] = 5] = "Link";
27
+ JsonButtonStyle[JsonButtonStyle["Premium"] = 6] = "Premium";
28
+ })(JsonButtonStyle || (JsonButtonStyle = {}));
29
+ export var JsonComponentType;
30
+ (function (JsonComponentType) {
31
+ JsonComponentType[JsonComponentType["ActionRow"] = 1] = "ActionRow";
32
+ JsonComponentType[JsonComponentType["Button"] = 2] = "Button";
33
+ JsonComponentType[JsonComponentType["StringSelect"] = 3] = "StringSelect";
34
+ JsonComponentType[JsonComponentType["TextInput"] = 4] = "TextInput";
35
+ JsonComponentType[JsonComponentType["UserSelect"] = 5] = "UserSelect";
36
+ JsonComponentType[JsonComponentType["RoleSelect"] = 6] = "RoleSelect";
37
+ JsonComponentType[JsonComponentType["MentionableSelect"] = 7] = "MentionableSelect";
38
+ JsonComponentType[JsonComponentType["ChannelSelect"] = 8] = "ChannelSelect";
39
+ JsonComponentType[JsonComponentType["Section"] = 9] = "Section";
40
+ JsonComponentType[JsonComponentType["TextDisplay"] = 10] = "TextDisplay";
41
+ JsonComponentType[JsonComponentType["Thumbnail"] = 11] = "Thumbnail";
42
+ JsonComponentType[JsonComponentType["MediaGallery"] = 12] = "MediaGallery";
43
+ JsonComponentType[JsonComponentType["File"] = 13] = "File";
44
+ JsonComponentType[JsonComponentType["Separator"] = 14] = "Separator";
45
+ JsonComponentType[JsonComponentType["ContentInventoryEntry"] = 16] = "ContentInventoryEntry";
46
+ JsonComponentType[JsonComponentType["Container"] = 17] = "Container";
47
+ JsonComponentType[JsonComponentType["Label"] = 18] = "Label";
48
+ JsonComponentType[JsonComponentType["FileUpload"] = 19] = "FileUpload";
49
+ })(JsonComponentType || (JsonComponentType = {}));
50
+ export var JsonSeparatorSpacingSize;
51
+ (function (JsonSeparatorSpacingSize) {
52
+ JsonSeparatorSpacingSize[JsonSeparatorSpacingSize["Small"] = 1] = "Small";
53
+ JsonSeparatorSpacingSize[JsonSeparatorSpacingSize["Large"] = 2] = "Large";
54
+ })(JsonSeparatorSpacingSize || (JsonSeparatorSpacingSize = {}));
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "discord-message-transcript-base",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/index.js",
10
+ "require": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ },
13
+ "./*": {
14
+ "import": "./dist/*.js",
15
+ "require": "./dist/*.js",
16
+ "types": "./dist/*.d.ts"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist",
21
+ "LICENSE"
22
+ ],
23
+ "scripts": {
24
+ "test": "echo \"Error: no test specified\" && exit 1",
25
+ "build": "tsc && node scripts/copy.js"
26
+ },
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/HenriqueMairesse/discord-message-transcript.git"
30
+ },
31
+ "keywords": [],
32
+ "author": "",
33
+ "license": "Apache-2.0",
34
+ "type": "module",
35
+ "bugs": {
36
+ "url": "https://github.com/HenriqueMairesse/discord-message-transcript/issues"
37
+ },
38
+ "homepage": "https://github.com/HenriqueMairesse/discord-message-transcript#readme",
39
+ "devDependencies": {
40
+ "@types/node": "^25.0.6",
41
+ "typescript": "^5.9.3"
42
+ }
43
+ }