discord-message-transcript 1.3.2-dev.0.49 → 1.3.2-dev.1.51
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/assetResolver/base64/imageToBase64.d.ts +1 -1
- package/dist/core/assetResolver/base64/imageToBase64.js +2 -2
- package/dist/core/assetResolver/cdn/cdnCustomError.js +1 -1
- package/dist/core/assetResolver/cdn/cdnResolver.d.ts +3 -2
- package/dist/core/assetResolver/cdn/cdnResolver.js +2 -2
- package/dist/core/assetResolver/cdn/uploadCareCdnResolver.js +1 -1
- package/dist/core/assetResolver/cdn/validateCdnUrl.js +1 -1
- package/dist/core/assetResolver/index.d.ts +4 -3
- package/dist/core/assetResolver/url/authorUrlResolver.d.ts +2 -2
- package/dist/core/assetResolver/url/imageUrlResolver.d.ts +2 -2
- package/dist/core/assetResolver/url/imageUrlResolver.js +2 -2
- package/dist/core/assetResolver/url/messageUrlResolver.d.ts +2 -2
- package/dist/core/assetResolver/url/messageUrlResolver.js +3 -3
- package/dist/core/assetResolver/url/urlResolver.d.ts +3 -2
- package/dist/core/assetResolver/url/urlResolver.js +1 -1
- package/dist/core/discordParser/componentToJson.d.ts +1 -1
- package/dist/core/discordParser/componentToJson.js +1 -2
- package/dist/core/discordParser/fetchMessages.d.ts +2 -2
- package/dist/core/discordParser/fetchMessages.js +1 -1
- package/dist/core/discordParser/getMentions.d.ts +1 -1
- package/dist/core/discordParser/getMentions.js +1 -1
- package/dist/core/discordParser/index.d.ts +3 -2
- package/dist/core/discordParser/index.js +1 -1
- package/dist/core/mappers.d.ts +3 -2
- package/dist/core/mappers.js +3 -2
- package/dist/core/networkSecurity/dns.d.ts +1 -1
- package/dist/core/networkSecurity/urlSafety.d.ts +2 -2
- package/dist/core/networkSecurity/urlSafety.js +1 -1
- package/dist/core/output.d.ts +1 -1
- package/dist/core/output.js +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +8 -8
- package/dist/renderers/json/json.d.ts +2 -2
- package/dist/renderers/json/json.js +1 -1
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +3 -0
- package/dist/types/private/cdn.d.ts +89 -0
- package/dist/types/private/cdn.js +1 -0
- package/dist/types/private/discordParser.d.ts +18 -0
- package/dist/types/private/discordParser.js +1 -0
- package/dist/types/private/maps.d.ts +17 -0
- package/dist/types/private/maps.js +1 -0
- package/dist/types/private/network.d.ts +12 -0
- package/dist/types/private/network.js +1 -0
- package/dist/types/private/others.d.ts +4 -0
- package/dist/types/private/others.js +1 -0
- package/dist/types/private/transcript.d.ts +123 -0
- package/dist/types/private/transcript.js +1 -0
- package/dist/types/public/createAndConvertTranscript.d.ts +32 -0
- package/dist/types/public/createAndConvertTranscript.js +1 -0
- package/dist/types/public/return.d.ts +37 -0
- package/package.json +3 -3
- package/dist/types/types.d.ts +0 -322
- /package/dist/types/{types.js → public/return.js} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { safeUrlReturn } from '
|
|
1
|
+
import { safeUrlReturn } from '../../../types/private/network.js';
|
|
2
2
|
export declare function imageToBase64(safeUrlObject: safeUrlReturn, disableWarnings: boolean): Promise<string>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { CustomWarn } from 'discord-message-transcript-base';
|
|
1
|
+
import { CustomWarn } from 'discord-message-transcript-base/internal';
|
|
2
2
|
import { getBase64Limiter } from '../limiter.js';
|
|
3
3
|
import https from 'https';
|
|
4
4
|
import http from 'http';
|
|
5
|
-
import { createLookup } from '
|
|
5
|
+
import { createLookup } from '../../networkSecurity/index.js';
|
|
6
6
|
import { USER_AGENT } from '../contants.js';
|
|
7
7
|
const MAX_BYTES = 25 * 1024 * 1024; // 25MB
|
|
8
8
|
export async function imageToBase64(safeUrlObject, disableWarnings) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { TranscriptOptionsBase } from "discord-message-transcript-base/internal";
|
|
2
|
+
import { safeUrlReturn } from "../../../types/private/network.js";
|
|
3
|
+
import { CDNOptions } from "../../../types/private/cdn.js";
|
|
3
4
|
export declare function cdnResolver(safeUrlObject: safeUrlReturn, options: TranscriptOptionsBase, cdnOptions: CDNOptions): Promise<string>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CustomWarn } from "discord-message-transcript-base";
|
|
1
|
+
import { CustomWarn } from "discord-message-transcript-base/internal";
|
|
2
2
|
import { getCDNLimiter } from "../limiter.js";
|
|
3
|
-
import { createLookup } from "
|
|
3
|
+
import { createLookup } from "../../networkSecurity/index.js";
|
|
4
4
|
import https from 'https';
|
|
5
5
|
import http from 'http';
|
|
6
6
|
import { uploadCareCdnResolver } from "./uploadCareCdnResolver.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sleep } from "
|
|
1
|
+
import { sleep } from "../../../utils/sleep.js";
|
|
2
2
|
import { CDNProviderError, warnCdnError } from "./cdnCustomError.js";
|
|
3
3
|
import { USER_AGENT } from "../contants.js";
|
|
4
4
|
// https://uploadcare.com/api-refs/upload-api/#tag/Upload/operation/fromURLUpload
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CustomWarn } from "discord-message-transcript-base";
|
|
1
|
+
import { CustomWarn } from "discord-message-transcript-base/internal";
|
|
2
2
|
export function validateCdnUrl(url, disableWarnings) {
|
|
3
3
|
if (url.includes('"') || url.includes('<') || url.includes('>')) {
|
|
4
4
|
CustomWarn(`Unsafe URL received from CDN, using fallback.\nURL: ${url}`, disableWarnings);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Json } from "
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { Json } from "../../renderers/json/json.js";
|
|
2
|
+
import { TranscriptOptionsBase } from "discord-message-transcript-base/internal";
|
|
3
|
+
import { Maps } from "../../types/private/maps.js";
|
|
4
|
+
import { CDNOptions } from "../../types/private/cdn.js";
|
|
4
5
|
export * from "./limiter.js";
|
|
5
6
|
export * from "./url/imageUrlResolver.js";
|
|
6
7
|
export * from "./url/urlResolver.js";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { JsonAuthor, TranscriptOptionsBase } from "discord-message-transcript-base";
|
|
2
|
-
import { CDNOptions } from "
|
|
1
|
+
import { JsonAuthor, TranscriptOptionsBase } from "discord-message-transcript-base/internal";
|
|
2
|
+
import { CDNOptions } from "../../../types/private/cdn.js";
|
|
3
3
|
export declare function authorUrlResolver(authors: Map<string, JsonAuthor>, options: TranscriptOptionsBase, cdnOptions: CDNOptions | null, urlCache: Map<string, Promise<string>>): Promise<JsonAuthor[]>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JsonAttachment, TranscriptOptionsBase } from "discord-message-transcript-base";
|
|
2
|
-
import { safeUrlReturn } from "
|
|
1
|
+
import { JsonAttachment, TranscriptOptionsBase } from "discord-message-transcript-base/internal";
|
|
2
|
+
import { safeUrlReturn } from "../../../types/private/network.js";
|
|
3
3
|
export declare function imageUrlResolver(url: string, options: TranscriptOptionsBase, canReturnNull: false, attachments?: JsonAttachment[]): Promise<safeUrlReturn>;
|
|
4
4
|
export declare function imageUrlResolver(url: string | null, options: TranscriptOptionsBase, canReturnNull: true, attachments?: JsonAttachment[]): Promise<safeUrlReturn | null>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FALLBACK_PIXEL } from "discord-message-transcript-base";
|
|
2
|
-
import { isSafeForHTML } from "
|
|
1
|
+
import { FALLBACK_PIXEL } from "discord-message-transcript-base/internal";
|
|
2
|
+
import { isSafeForHTML } from "../../networkSecurity/index.js";
|
|
3
3
|
export async function imageUrlResolver(url, options, canReturnNull, attachments) {
|
|
4
4
|
if (!url)
|
|
5
5
|
return null;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { JsonMessage, TranscriptOptionsBase } from "discord-message-transcript-base/internal";
|
|
2
|
+
import { CDNOptions } from "../../../types/private/cdn.js";
|
|
3
3
|
export declare function messagesUrlResolver(messages: JsonMessage[], options: TranscriptOptionsBase, cdnOptions: CDNOptions | null, urlCache: Map<string, Promise<string>>): Promise<JsonMessage[]>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { JsonComponentType } from "discord-message-transcript-base";
|
|
1
|
+
import { JsonComponentType } from "discord-message-transcript-base/internal";
|
|
2
2
|
import { imageUrlResolver } from "./imageUrlResolver.js";
|
|
3
|
-
import { isSafeForHTML } from "
|
|
3
|
+
import { isSafeForHTML } from "../../networkSecurity/index.js";
|
|
4
4
|
import { urlResolver } from "./urlResolver.js";
|
|
5
|
-
import { isJsonComponentInContainer } from "
|
|
5
|
+
import { isJsonComponentInContainer } from "../../discordParser/componentToJson.js";
|
|
6
6
|
export async function messagesUrlResolver(messages, options, cdnOptions, urlCache) {
|
|
7
7
|
return await Promise.all(messages.map(async (message) => {
|
|
8
8
|
// Needs to wait for resolve correct when used attachment://
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { TranscriptOptionsBase } from "discord-message-transcript-base/internal";
|
|
2
|
+
import { safeUrlReturn } from "../../../types/private/network.js";
|
|
3
|
+
import { CDNOptions } from "../../../types/private/cdn.js";
|
|
3
4
|
export declare function urlResolver(safeUrlObject: safeUrlReturn, options: TranscriptOptionsBase, cdnOptions: CDNOptions | null, urlCache: Map<string, Promise<string>>): Promise<string>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FALLBACK_PIXEL } from "discord-message-transcript-base";
|
|
1
|
+
import { FALLBACK_PIXEL } from "discord-message-transcript-base/internal";
|
|
2
2
|
import { cdnResolver } from "../cdn/cdnResolver.js";
|
|
3
3
|
import { imageToBase64 } from "../base64/imageToBase64.js";
|
|
4
4
|
export async function urlResolver(safeUrlObject, options, cdnOptions, urlCache) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { TopLevelComponent } from "discord.js";
|
|
2
|
-
import { JsonTopLevelComponent, TranscriptOptionsBase, JsonComponentInContainer } from "discord-message-transcript-base";
|
|
2
|
+
import { JsonTopLevelComponent, TranscriptOptionsBase, JsonComponentInContainer } from "discord-message-transcript-base/internal";
|
|
3
3
|
export declare function componentsToJson(components: TopLevelComponent[], options: TranscriptOptionsBase): Promise<JsonTopLevelComponent[]>;
|
|
4
4
|
export declare function isJsonComponentInContainer(component: JsonTopLevelComponent): component is JsonComponentInContainer;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ComponentType } from "discord.js";
|
|
2
2
|
import { mapButtonStyle, mapSelectorType, mapSeparatorSpacing } from "../mappers.js";
|
|
3
|
-
import { JsonComponentType } from "discord-message-transcript-base";
|
|
4
|
-
import { isValidHexColor } from "discord-message-transcript-base";
|
|
3
|
+
import { JsonComponentType, isValidHexColor } from "discord-message-transcript-base/internal";
|
|
5
4
|
export async function componentsToJson(components, options) {
|
|
6
5
|
const filtered = components.filter(c => options.includeV2Components || c.type === ComponentType.ActionRow);
|
|
7
6
|
const processed = await Promise.all(filtered.map(c => convertComponent(c, options)));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { JsonMessage } from "discord-message-transcript-base";
|
|
2
|
-
import { FetchMessagesContext } from "
|
|
1
|
+
import { JsonMessage } from "discord-message-transcript-base/internal";
|
|
2
|
+
import { FetchMessagesContext } from "../../types/private/discordParser.js";
|
|
3
3
|
export declare function fetchMessages(ctx: FetchMessagesContext): Promise<{
|
|
4
4
|
messages: JsonMessage[];
|
|
5
5
|
end: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EmbedType } from "discord.js";
|
|
2
2
|
import { componentsToJson } from "./componentToJson.js";
|
|
3
|
-
import { isValidHexColor, sanitize } from "discord-message-transcript-base";
|
|
3
|
+
import { isValidHexColor, sanitize } from "discord-message-transcript-base/internal";
|
|
4
4
|
import { getMentions } from "./getMentions.js";
|
|
5
5
|
export async function fetchMessages(ctx) {
|
|
6
6
|
const { channel, options, transcriptState, lastMessageId } = ctx;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ChannelType } from "discord.js";
|
|
2
|
-
import { isValidHexColor, sanitize } from "discord-message-transcript-base";
|
|
2
|
+
import { isValidHexColor, sanitize } from "discord-message-transcript-base/internal";
|
|
3
3
|
export async function getMentions(message, mentions) {
|
|
4
4
|
message.mentions.channels.forEach(channel => {
|
|
5
5
|
if (!mentions.channels.has(channel.id)) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { TranscriptOptionsBase } from "discord-message-transcript-base";
|
|
1
|
+
import { TranscriptOptionsBase } from "discord-message-transcript-base/internal";
|
|
3
2
|
import { TextBasedChannel } from "discord.js";
|
|
3
|
+
import { ReturnDiscordParser } from "../../types/private/discordParser.js";
|
|
4
|
+
import { CDNOptions } from "../../types/private/cdn.js";
|
|
4
5
|
export declare function discordParser(channel: TextBasedChannel, options: TranscriptOptionsBase, cdnOptions: CDNOptions | null): Promise<ReturnDiscordParser>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fetchMessages } from "./fetchMessages.js";
|
|
2
|
-
import { Json } from "
|
|
2
|
+
import { Json } from "../../renderers/json/json.js";
|
|
3
3
|
export async function discordParser(channel, options, cdnOptions) {
|
|
4
4
|
const urlCache = new Map();
|
|
5
5
|
const authors = new Map();
|
package/dist/core/mappers.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ButtonStyle, ComponentType, SeparatorSpacingSize } from "discord.js";
|
|
2
|
-
import { JsonButtonStyle, JsonComponentType, JsonSeparatorSpacingSize
|
|
3
|
-
import { ReturnType } from "
|
|
2
|
+
import { JsonButtonStyle, JsonComponentType, JsonSeparatorSpacingSize } from "discord-message-transcript-base/internal";
|
|
3
|
+
import { ReturnType } from "../types/public/return.js";
|
|
4
|
+
import { ReturnType as ReturnTypeBase } from "discord-message-transcript-base";
|
|
4
5
|
export declare function mapButtonStyle(style: ButtonStyle): JsonButtonStyle;
|
|
5
6
|
export declare function mapSeparatorSpacing(spacing: SeparatorSpacingSize): JsonSeparatorSpacingSize;
|
|
6
7
|
export declare function mapComponentType(componentType: ComponentType): JsonComponentType;
|
package/dist/core/mappers.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ButtonStyle, ComponentType, SeparatorSpacingSize } from "discord.js";
|
|
2
|
-
import { CustomError, JsonButtonStyle, JsonComponentType, JsonSeparatorSpacingSize
|
|
3
|
-
import { ReturnType } from "
|
|
2
|
+
import { CustomError, JsonButtonStyle, JsonComponentType, JsonSeparatorSpacingSize } from "discord-message-transcript-base/internal";
|
|
3
|
+
import { ReturnType } from "../types/public/return.js";
|
|
4
|
+
import { ReturnType as ReturnTypeBase } from "discord-message-transcript-base";
|
|
4
5
|
export function mapButtonStyle(style) {
|
|
5
6
|
switch (style) {
|
|
6
7
|
case ButtonStyle.Primary:
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { LookupResult } from "
|
|
1
|
+
import { LookupResult } from "../../types/private/network.js";
|
|
2
2
|
export declare function resolveAllIps(host: string): Promise<LookupResult[]>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { TranscriptOptionsBase } from "discord-message-transcript-base";
|
|
2
|
-
import { safeUrlReturn } from "
|
|
1
|
+
import { TranscriptOptionsBase } from "discord-message-transcript-base/internal";
|
|
2
|
+
import { safeUrlReturn } from "../../types/private/network.js";
|
|
3
3
|
export declare function isSafeForHTML(url: string, options: TranscriptOptionsBase): Promise<safeUrlReturn>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CustomWarn } from "discord-message-transcript-base";
|
|
1
|
+
import { CustomWarn } from "discord-message-transcript-base/internal";
|
|
2
2
|
import { TRUSTED_DISCORD_HOSTS } from "./constants.js";
|
|
3
3
|
import { isPrivateIp } from "./ip.js";
|
|
4
4
|
import { resolveAllIps } from "./dns.js";
|
package/dist/core/output.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { AttachmentBuilder } from "discord.js";
|
|
2
2
|
import Stream from 'stream';
|
|
3
|
-
import { JsonData, Uploadable } from "discord-message-transcript-base";
|
|
3
|
+
import { JsonData, Uploadable } from "discord-message-transcript-base/internal";
|
|
4
4
|
export declare function output(json: JsonData): Promise<string | Stream | AttachmentBuilder | Buffer | Uploadable>;
|
package/dist/core/output.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Readable } from 'stream';
|
|
2
|
-
import { outputBase, CustomError } from "discord-message-transcript-base";
|
|
2
|
+
import { outputBase, CustomError } from "discord-message-transcript-base/internal";
|
|
3
3
|
export async function output(json) {
|
|
4
4
|
const stringJSON = JSON.stringify(json);
|
|
5
5
|
if (json.options.returnFormat == "JSON") {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export
|
|
2
|
-
export {
|
|
3
|
-
export { setBase64Concurrency, setCDNConcurrency } from '@/assetResolver';
|
|
1
|
+
export * from "./types/index.js";
|
|
2
|
+
export { setBase64Concurrency, setCDNConcurrency } from './core/assetResolver/index.js';
|
|
4
3
|
import { TextBasedChannel } from "discord.js";
|
|
5
|
-
import {
|
|
4
|
+
import { OutputType, ReturnType } from "./types/public/return.js";
|
|
5
|
+
import { ConvertTranscriptOptions, CreateTranscriptOptions } from "./types/public/createAndConvertTranscript.js";
|
|
6
6
|
/**
|
|
7
7
|
* Creates a transcript of a Discord channel's messages.
|
|
8
8
|
* Depending on the `returnType` option, this function can return an `AttachmentBuilder`,
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export
|
|
2
|
-
export {
|
|
3
|
-
export { setBase64Concurrency, setCDNConcurrency } from '@/assetResolver';
|
|
1
|
+
export * from "./types/index.js";
|
|
2
|
+
export { setBase64Concurrency, setCDNConcurrency } from './core/assetResolver/index.js';
|
|
4
3
|
import { AttachmentBuilder } from "discord.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { returnTypeMapper } from "
|
|
9
|
-
import { jsonAssetResolver } from "
|
|
4
|
+
import { output } from "./core/output.js";
|
|
5
|
+
import { ReturnFormat, outputBase, CustomError, CustomWarn } from "discord-message-transcript-base/internal";
|
|
6
|
+
import { ReturnType as ReturnTypeBase } from "discord-message-transcript-base";
|
|
7
|
+
import { returnTypeMapper } from "./core/mappers.js";
|
|
8
|
+
import { jsonAssetResolver } from "./core/assetResolver/index.js";
|
|
10
9
|
import { discordParser } from "./core/discordParser/index.js";
|
|
10
|
+
import { ReturnType } from "./types/public/return.js";
|
|
11
11
|
/**
|
|
12
12
|
* Creates a transcript of a Discord channel's messages.
|
|
13
13
|
* Depending on the `returnType` option, this function can return an `AttachmentBuilder`,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Guild, TextBasedChannel } from "discord.js";
|
|
2
|
-
import { ArrayMentions, JsonAuthor, JsonMessage, TranscriptOptionsBase, JsonData } from "discord-message-transcript-base";
|
|
3
|
-
import { CDNOptions } from "
|
|
2
|
+
import { ArrayMentions, JsonAuthor, JsonMessage, TranscriptOptionsBase, JsonData } from "discord-message-transcript-base/internal";
|
|
3
|
+
import { CDNOptions } from "../../types/private/cdn.js";
|
|
4
4
|
export declare class Json {
|
|
5
5
|
private guild;
|
|
6
6
|
private channel;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { MimeType } from "./others.js";
|
|
2
|
+
/**
|
|
3
|
+
* Base options applicable to all CDN providers.
|
|
4
|
+
*/
|
|
5
|
+
export type CDNBase = Partial<{
|
|
6
|
+
/**
|
|
7
|
+
* Whether to upload audio files to the CDN.
|
|
8
|
+
* @default true
|
|
9
|
+
*/
|
|
10
|
+
includeAudio: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Whether to upload image files (excluding GIFs) to the CDN.
|
|
13
|
+
* @default true
|
|
14
|
+
*/
|
|
15
|
+
includeImage: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Whether to upload video files (and GIFs) to the CDN.
|
|
18
|
+
* @default true
|
|
19
|
+
*/
|
|
20
|
+
includeVideo: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Whether to upload any other file types to the CDN.
|
|
23
|
+
* @default true
|
|
24
|
+
*/
|
|
25
|
+
includeOthers: boolean;
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* A discriminated union of all possible CDN configurations.
|
|
29
|
+
*/
|
|
30
|
+
export type CDNOptions = (CDNBase & CDNOptionsCustom<any>) | (CDNBase & CDNOptionsCloudinary) | (CDNBase & CDNOptionsUploadcare);
|
|
31
|
+
/**
|
|
32
|
+
* Configuration for using a custom, user-provided CDN resolver function.
|
|
33
|
+
*/
|
|
34
|
+
export type CDNOptionsCustom<T = unknown> = {
|
|
35
|
+
/** Specifies the use of a custom CDN resolver. */
|
|
36
|
+
provider: "CUSTOM";
|
|
37
|
+
/**
|
|
38
|
+
* An async function that takes a URL and returns a new URL.
|
|
39
|
+
* @param url The original Discord asset URL.
|
|
40
|
+
* @param contentType The MIME type of the asset.
|
|
41
|
+
* @param customData Any additional data you want to pass to your resolver.
|
|
42
|
+
* @returns The new URL of the asset on your CDN.
|
|
43
|
+
*/
|
|
44
|
+
resolver: (url: string, contentType: MimeType | null, customData: T) => Promise<string> | string;
|
|
45
|
+
/**
|
|
46
|
+
* Any custom data you wish to make available within your resolver function.
|
|
47
|
+
*/
|
|
48
|
+
customData: T;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Configuration for using Cloudinary as the CDN.
|
|
52
|
+
*/
|
|
53
|
+
export type CDNOptionsCloudinary = {
|
|
54
|
+
/**
|
|
55
|
+
* Specifies the use of the built-in Cloudinary provider.
|
|
56
|
+
*/
|
|
57
|
+
provider: "CLOUDINARY";
|
|
58
|
+
/**
|
|
59
|
+
* Your Cloudinary cloud name.
|
|
60
|
+
*/
|
|
61
|
+
cloudName: string;
|
|
62
|
+
/**
|
|
63
|
+
* Your Cloudinary API key.
|
|
64
|
+
* */
|
|
65
|
+
apiKey: string;
|
|
66
|
+
/**
|
|
67
|
+
* Your Cloudinary API secret.
|
|
68
|
+
*/
|
|
69
|
+
apiSecret: string;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Configuration for using Uploadcare as the CDN.
|
|
73
|
+
*/
|
|
74
|
+
export type CDNOptionsUploadcare = {
|
|
75
|
+
/**
|
|
76
|
+
* Specifies the use of the built-in Uploadcare provider.
|
|
77
|
+
*/
|
|
78
|
+
provider: "UPLOADCARE";
|
|
79
|
+
/**
|
|
80
|
+
* Your Uploadcare public key.
|
|
81
|
+
*/
|
|
82
|
+
publicKey: string;
|
|
83
|
+
/**
|
|
84
|
+
* Your Uploadcare CDN domain.
|
|
85
|
+
* Example: "aaa111aaa1.ucarecd.net".
|
|
86
|
+
* DO NOT INCLUDE https://
|
|
87
|
+
*/
|
|
88
|
+
cdnDomain: string;
|
|
89
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Json } from "../../renderers/json/json.js";
|
|
2
|
+
import { MapMentions, Maps } from "./maps.js";
|
|
3
|
+
import { TextBasedChannel } from "discord.js";
|
|
4
|
+
import { JsonAuthor, TranscriptOptionsBase } from "discord-message-transcript-base/internal";
|
|
5
|
+
export type ReturnDiscordParser = [
|
|
6
|
+
json: Json,
|
|
7
|
+
maps: Maps
|
|
8
|
+
];
|
|
9
|
+
export type FetchMessagesContext = {
|
|
10
|
+
channel: TextBasedChannel;
|
|
11
|
+
options: TranscriptOptionsBase;
|
|
12
|
+
transcriptState: TranscriptState;
|
|
13
|
+
lastMessageId: string | undefined;
|
|
14
|
+
};
|
|
15
|
+
export type TranscriptState = {
|
|
16
|
+
authors: Map<string, JsonAuthor>;
|
|
17
|
+
mentions: MapMentions;
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { JsonAuthor, JsonMessageMentionsChannels, JsonMessageMentionsRoles, JsonMessageMentionsUsers } from "discord-message-transcript-base/internal";
|
|
2
|
+
export type MapAuthors = Map<string, JsonAuthor>;
|
|
3
|
+
export type MapCache = Map<string, Promise<string>>;
|
|
4
|
+
/**
|
|
5
|
+
* Defines the structure for storing discovered mentions (users, roles, channels) during transcript creation.
|
|
6
|
+
* Uses Maps for efficient lookups.
|
|
7
|
+
*/
|
|
8
|
+
export interface MapMentions {
|
|
9
|
+
channels: Map<string, JsonMessageMentionsChannels>;
|
|
10
|
+
roles: Map<string, JsonMessageMentionsRoles>;
|
|
11
|
+
users: Map<string, JsonMessageMentionsUsers>;
|
|
12
|
+
}
|
|
13
|
+
export type Maps = {
|
|
14
|
+
authors: MapAuthors;
|
|
15
|
+
mentions: MapMentions;
|
|
16
|
+
urlCache: MapCache;
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { LocalDate, ReturnFormat, TimeZone } from "discord-message-transcript-base/internal";
|
|
2
|
+
import { CDNOptions } from "./cdn.js";
|
|
3
|
+
import { ReturnType } from "../public/return.js";
|
|
4
|
+
/**
|
|
5
|
+
* Defines the complete set of options for creating a transcript.
|
|
6
|
+
*/
|
|
7
|
+
export interface TranscriptOptions<T extends ReturnType> {
|
|
8
|
+
/**
|
|
9
|
+
* Configuration for uploading attachments and other assets to a CDN.
|
|
10
|
+
*/
|
|
11
|
+
cdnOptions: CDNOptions;
|
|
12
|
+
/**
|
|
13
|
+
* Disable all warnings to keep console output clean.
|
|
14
|
+
* ⚠️ Can hide issues like unsafe URLs or fallback usage.
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
disableWarnings: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* The name of the generated file (without extension).
|
|
20
|
+
* @default `Transcript-channel-name-channel-id`
|
|
21
|
+
*/
|
|
22
|
+
fileName: string;
|
|
23
|
+
/**
|
|
24
|
+
* Whether to include attachments in the transcript.
|
|
25
|
+
* @default true
|
|
26
|
+
*/
|
|
27
|
+
includeAttachments: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Whether to include message component buttons in the transcript.
|
|
30
|
+
* @default true
|
|
31
|
+
*/
|
|
32
|
+
includeButtons: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Whether to include non-button message components (like select menus) in the transcript.
|
|
35
|
+
* @default true
|
|
36
|
+
*/
|
|
37
|
+
includeComponents: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Whether to include messages that have no content.
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
includeEmpty: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Whether to include embeds in the transcript.
|
|
45
|
+
* @default true
|
|
46
|
+
*/
|
|
47
|
+
includeEmbeds: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Whether to include polls in the transcript.
|
|
50
|
+
* @default true
|
|
51
|
+
*/
|
|
52
|
+
includePolls: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Whether to include message reactions in the transcript.
|
|
55
|
+
* @default true
|
|
56
|
+
*/
|
|
57
|
+
includeReactions: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Whether to include newer (V2) components like `Container`, `MediaGallery`, etc.
|
|
60
|
+
* @default true
|
|
61
|
+
*/
|
|
62
|
+
includeV2Components: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* The locale to use for formatting dates (e.g., 'en-US', 'pt-BR').
|
|
65
|
+
* Must be a valid BCP 47 language tag.
|
|
66
|
+
* @default 'en-GB'
|
|
67
|
+
*/
|
|
68
|
+
localDate: LocalDate;
|
|
69
|
+
/**
|
|
70
|
+
* The maximum number of messages to fetch. Set to `0` to fetch all messages in the channel.
|
|
71
|
+
* @default 0
|
|
72
|
+
*/
|
|
73
|
+
quantity: number;
|
|
74
|
+
/**
|
|
75
|
+
* The format of the returned transcript.
|
|
76
|
+
* - ReturnFormat.HTML - Returns the transcript as HTML
|
|
77
|
+
* - ReturnFormat.JSON - Returns the transcript as JSON
|
|
78
|
+
* @default ReturnFormat.HTML
|
|
79
|
+
*/
|
|
80
|
+
returnFormat: ReturnFormat;
|
|
81
|
+
/**
|
|
82
|
+
* The desired output type for the transcript.
|
|
83
|
+
* - ReturnType.Attachment - The transcript content as a `Attachment`
|
|
84
|
+
* - ReturnType.String - The transcript content as a string.
|
|
85
|
+
* - ReturnType.Buffer - The transcript content as a `Buffer`.
|
|
86
|
+
* - ReturnType.Stream - The transcript content as a `Stream`.
|
|
87
|
+
* - ReturnType.Uploadable` - An object with `content`, `contentType` and `fileName`.
|
|
88
|
+
* @default ReturnType.Attachment
|
|
89
|
+
*/
|
|
90
|
+
returnType: T;
|
|
91
|
+
/**
|
|
92
|
+
* Enables safe mode, blocking potentially unsafe URLs and content.
|
|
93
|
+
* Prevents suspicious links, images, or HTML from being included in the final transcript.
|
|
94
|
+
*
|
|
95
|
+
* ⚠️ Disabling may allow unsafe content to appear in the transcript.
|
|
96
|
+
* @default true
|
|
97
|
+
*/
|
|
98
|
+
safeMode: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Whether to save images as base64 data directly in the transcript.
|
|
101
|
+
* This is an alternative to using a CDN and results in larger file sizes.
|
|
102
|
+
* Will not work if using CDN.
|
|
103
|
+
* @default false
|
|
104
|
+
*/
|
|
105
|
+
saveImages: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Whether the generated HTML should have its CSS and JS embedded directly in the file.
|
|
108
|
+
* Only applicable if `returnFormat` is `HTML`.
|
|
109
|
+
* @default false
|
|
110
|
+
*/
|
|
111
|
+
selfContained: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* The timezone to use for formatting dates (e.g., 'UTC', 'America/New_York').
|
|
114
|
+
* Must be a valid IANA time zone name.
|
|
115
|
+
* @default 'UTC'
|
|
116
|
+
*/
|
|
117
|
+
timeZone: TimeZone;
|
|
118
|
+
/**
|
|
119
|
+
* Whether to include the 'Generated with discord-message-transcript' watermark in the footer.
|
|
120
|
+
* @default true
|
|
121
|
+
*/
|
|
122
|
+
watermark: boolean;
|
|
123
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ReturnType } from "../public/return.js";
|
|
2
|
+
import { TranscriptOptions } from "../private/transcript.js";
|
|
3
|
+
/**
|
|
4
|
+
* Options for creating a transcript, with all properties being optional.
|
|
5
|
+
* @see TranscriptOptions
|
|
6
|
+
*/
|
|
7
|
+
export type CreateTranscriptOptions<T extends ReturnType> = Partial<TranscriptOptions<T>>;
|
|
8
|
+
/**
|
|
9
|
+
* Options for converting a JSON transcript to an HTML transcript.
|
|
10
|
+
*/
|
|
11
|
+
export type ConvertTranscriptOptions<T extends ReturnType> = Partial<{
|
|
12
|
+
/**
|
|
13
|
+
* The desired output type for the transcript.
|
|
14
|
+
* - ReturnType.Attachment - The transcript content as a `Attachment`
|
|
15
|
+
* - ReturnType.String - The transcript content as a string.
|
|
16
|
+
* - ReturnType.Buffer - The transcript content as a `Buffer`.
|
|
17
|
+
* - ReturnType.Stream - The transcript content as a `Stream`.
|
|
18
|
+
* - ReturnType.Uploadable` - An object with `content`, `contentType` and `fileName`.
|
|
19
|
+
* @default ReturnType.Attachment
|
|
20
|
+
*/
|
|
21
|
+
returnType: T;
|
|
22
|
+
/**
|
|
23
|
+
* Whether the generated HTML should have its CSS and JS embedded directly in the file.
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
selfContained: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Whether to include the 'Generated with discord-message-transcript' watermark in the footer.
|
|
29
|
+
* @default true
|
|
30
|
+
*/
|
|
31
|
+
watermark: boolean;
|
|
32
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Uploadable } from "discord-message-transcript-base/internal";
|
|
2
|
+
import { AttachmentBuilder } from "discord.js";
|
|
3
|
+
import Stream from 'stream';
|
|
4
|
+
/**
|
|
5
|
+
* An enum-like object providing the possible return types for the transcript functions.
|
|
6
|
+
*/
|
|
7
|
+
export declare const ReturnType: {
|
|
8
|
+
/**
|
|
9
|
+
* Returns a `discord.js` AttachmentBuilder.
|
|
10
|
+
*/
|
|
11
|
+
readonly Attachment: "attachment";
|
|
12
|
+
/**
|
|
13
|
+
* Returns a `Buffer`.
|
|
14
|
+
*/
|
|
15
|
+
readonly Buffer: "buffer";
|
|
16
|
+
/**
|
|
17
|
+
* Returns a `Stream.Readable`.
|
|
18
|
+
* */
|
|
19
|
+
readonly Stream: "stream";
|
|
20
|
+
/**
|
|
21
|
+
* Returns a `string`.
|
|
22
|
+
* */
|
|
23
|
+
readonly String: "string";
|
|
24
|
+
/**
|
|
25
|
+
* Returns an `Uploadable` object with content, contentType, and fileName.
|
|
26
|
+
*/
|
|
27
|
+
readonly Uploadable: "uploadable";
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* The type representing the possible values of the `ReturnType` enum.
|
|
31
|
+
*/
|
|
32
|
+
export type ReturnType = typeof ReturnType[keyof typeof ReturnType];
|
|
33
|
+
/**
|
|
34
|
+
* A conditional type that maps the `ReturnType` string literal to the actual TypeScript type returned by the function.
|
|
35
|
+
* @template T The `ReturnType` literal.
|
|
36
|
+
*/
|
|
37
|
+
export type OutputType<T extends ReturnType> = T extends typeof ReturnType.Buffer ? Buffer : T extends typeof ReturnType.Stream ? Stream : T extends typeof ReturnType.String ? string : T extends typeof ReturnType.Uploadable ? Uploadable : AttachmentBuilder;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "discord-message-transcript",
|
|
3
|
-
"version": "1.3.2-dev.
|
|
3
|
+
"version": "1.3.2-dev.1.51",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"homepage": "https://github.com/HenriqueMairesse/discord-message-transcript#readme",
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"discord-message-transcript-base": "1.3.2-dev.
|
|
48
|
+
"discord-message-transcript-base": "1.3.2-dev.1.51"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"discord.js": ">=14.19.0 <15"
|
|
@@ -55,6 +55,6 @@
|
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"clean": "pnpm exec rimraf dist",
|
|
58
|
-
"build": "pnpm run clean && tsc"
|
|
58
|
+
"build": "pnpm run clean && tsc && tsc-alias"
|
|
59
59
|
}
|
|
60
60
|
}
|
package/dist/types/types.d.ts
DELETED
|
@@ -1,322 +0,0 @@
|
|
|
1
|
-
import { Json } from "@/renderers/json/json.js";
|
|
2
|
-
import { JsonMessageMentionsChannels, JsonMessageMentionsRoles, JsonMessageMentionsUsers, LocalDate, TimeZone, Uploadable, ReturnFormat, TranscriptOptionsBase, JsonAuthor } from "discord-message-transcript-base";
|
|
3
|
-
import { AttachmentBuilder, TextBasedChannel } from "discord.js";
|
|
4
|
-
import Stream from 'stream';
|
|
5
|
-
/**
|
|
6
|
-
* An enum-like object providing the possible return types for the transcript functions.
|
|
7
|
-
*/
|
|
8
|
-
export declare const ReturnType: {
|
|
9
|
-
/**
|
|
10
|
-
* Returns a `discord.js` AttachmentBuilder.
|
|
11
|
-
*/
|
|
12
|
-
readonly Attachment: "attachment";
|
|
13
|
-
/**
|
|
14
|
-
* Returns a `Buffer`.
|
|
15
|
-
*/
|
|
16
|
-
readonly Buffer: "buffer";
|
|
17
|
-
/**
|
|
18
|
-
* Returns a `Stream.Readable`.
|
|
19
|
-
* */
|
|
20
|
-
readonly Stream: "stream";
|
|
21
|
-
/**
|
|
22
|
-
* Returns a `string`.
|
|
23
|
-
* */
|
|
24
|
-
readonly String: "string";
|
|
25
|
-
/**
|
|
26
|
-
* Returns an `Uploadable` object with content, contentType, and fileName.
|
|
27
|
-
*/
|
|
28
|
-
readonly Uploadable: "uploadable";
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* The type representing the possible values of the `ReturnType` enum.
|
|
32
|
-
*/
|
|
33
|
-
export type ReturnType = typeof ReturnType[keyof typeof ReturnType];
|
|
34
|
-
/**
|
|
35
|
-
* A conditional type that maps the `ReturnType` string literal to the actual TypeScript type returned by the function.
|
|
36
|
-
* @template T The `ReturnType` literal.
|
|
37
|
-
*/
|
|
38
|
-
export type OutputType<T extends ReturnType> = T extends typeof ReturnType.Buffer ? Buffer : T extends typeof ReturnType.Stream ? Stream : T extends typeof ReturnType.String ? string : T extends typeof ReturnType.Uploadable ? Uploadable : AttachmentBuilder;
|
|
39
|
-
/**
|
|
40
|
-
* Options for creating a transcript, with all properties being optional.
|
|
41
|
-
* @see TranscriptOptions
|
|
42
|
-
*/
|
|
43
|
-
export type CreateTranscriptOptions<T extends ReturnType> = Partial<TranscriptOptions<T>>;
|
|
44
|
-
/**
|
|
45
|
-
* Options for converting a JSON transcript to an HTML transcript.
|
|
46
|
-
*/
|
|
47
|
-
export type ConvertTranscriptOptions<T extends ReturnType> = Partial<{
|
|
48
|
-
/**
|
|
49
|
-
* The desired output type for the transcript.
|
|
50
|
-
* - ReturnType.Attachment - The transcript content as a `Attachment`
|
|
51
|
-
* - ReturnType.String - The transcript content as a string.
|
|
52
|
-
* - ReturnType.Buffer - The transcript content as a `Buffer`.
|
|
53
|
-
* - ReturnType.Stream - The transcript content as a `Stream`.
|
|
54
|
-
* - ReturnType.Uploadable` - An object with `content`, `contentType` and `fileName`.
|
|
55
|
-
* @default ReturnType.Attachment
|
|
56
|
-
*/
|
|
57
|
-
returnType: T;
|
|
58
|
-
/**
|
|
59
|
-
* Whether the generated HTML should have its CSS and JS embedded directly in the file.
|
|
60
|
-
* @default false
|
|
61
|
-
*/
|
|
62
|
-
selfContained: boolean;
|
|
63
|
-
/**
|
|
64
|
-
* Whether to include the 'Generated with discord-message-transcript' watermark in the footer.
|
|
65
|
-
* @default true
|
|
66
|
-
*/
|
|
67
|
-
watermark: boolean;
|
|
68
|
-
}>;
|
|
69
|
-
/**
|
|
70
|
-
* Defines the complete set of options for creating a transcript.
|
|
71
|
-
*/
|
|
72
|
-
export interface TranscriptOptions<T extends ReturnType> {
|
|
73
|
-
/**
|
|
74
|
-
* Configuration for uploading attachments and other assets to a CDN.
|
|
75
|
-
*/
|
|
76
|
-
cdnOptions: CDNOptions;
|
|
77
|
-
/**
|
|
78
|
-
* Disable all warnings to keep console output clean.
|
|
79
|
-
* ⚠️ Can hide issues like unsafe URLs or fallback usage.
|
|
80
|
-
* @default false
|
|
81
|
-
*/
|
|
82
|
-
disableWarnings: boolean;
|
|
83
|
-
/**
|
|
84
|
-
* The name of the generated file (without extension).
|
|
85
|
-
* @default `Transcript-channel-name-channel-id`
|
|
86
|
-
*/
|
|
87
|
-
fileName: string;
|
|
88
|
-
/**
|
|
89
|
-
* Whether to include attachments in the transcript.
|
|
90
|
-
* @default true
|
|
91
|
-
*/
|
|
92
|
-
includeAttachments: boolean;
|
|
93
|
-
/**
|
|
94
|
-
* Whether to include message component buttons in the transcript.
|
|
95
|
-
* @default true
|
|
96
|
-
*/
|
|
97
|
-
includeButtons: boolean;
|
|
98
|
-
/**
|
|
99
|
-
* Whether to include non-button message components (like select menus) in the transcript.
|
|
100
|
-
* @default true
|
|
101
|
-
*/
|
|
102
|
-
includeComponents: boolean;
|
|
103
|
-
/**
|
|
104
|
-
* Whether to include messages that have no content.
|
|
105
|
-
* @default false
|
|
106
|
-
*/
|
|
107
|
-
includeEmpty: boolean;
|
|
108
|
-
/**
|
|
109
|
-
* Whether to include embeds in the transcript.
|
|
110
|
-
* @default true
|
|
111
|
-
*/
|
|
112
|
-
includeEmbeds: boolean;
|
|
113
|
-
/**
|
|
114
|
-
* Whether to include polls in the transcript.
|
|
115
|
-
* @default true
|
|
116
|
-
*/
|
|
117
|
-
includePolls: boolean;
|
|
118
|
-
/**
|
|
119
|
-
* Whether to include message reactions in the transcript.
|
|
120
|
-
* @default true
|
|
121
|
-
*/
|
|
122
|
-
includeReactions: boolean;
|
|
123
|
-
/**
|
|
124
|
-
* Whether to include newer (V2) components like `Container`, `MediaGallery`, etc.
|
|
125
|
-
* @default true
|
|
126
|
-
*/
|
|
127
|
-
includeV2Components: boolean;
|
|
128
|
-
/**
|
|
129
|
-
* The locale to use for formatting dates (e.g., 'en-US', 'pt-BR').
|
|
130
|
-
* Must be a valid BCP 47 language tag.
|
|
131
|
-
* @default 'en-GB'
|
|
132
|
-
*/
|
|
133
|
-
localDate: LocalDate;
|
|
134
|
-
/**
|
|
135
|
-
* The maximum number of messages to fetch. Set to `0` to fetch all messages in the channel.
|
|
136
|
-
* @default 0
|
|
137
|
-
*/
|
|
138
|
-
quantity: number;
|
|
139
|
-
/**
|
|
140
|
-
* The format of the returned transcript.
|
|
141
|
-
* - ReturnFormat.HTML - Returns the transcript as HTML
|
|
142
|
-
* - ReturnFormat.JSON - Returns the transcript as JSON
|
|
143
|
-
* @default ReturnFormat.HTML
|
|
144
|
-
*/
|
|
145
|
-
returnFormat: ReturnFormat;
|
|
146
|
-
/**
|
|
147
|
-
* The desired output type for the transcript.
|
|
148
|
-
* - ReturnType.Attachment - The transcript content as a `Attachment`
|
|
149
|
-
* - ReturnType.String - The transcript content as a string.
|
|
150
|
-
* - ReturnType.Buffer - The transcript content as a `Buffer`.
|
|
151
|
-
* - ReturnType.Stream - The transcript content as a `Stream`.
|
|
152
|
-
* - ReturnType.Uploadable` - An object with `content`, `contentType` and `fileName`.
|
|
153
|
-
* @default ReturnType.Attachment
|
|
154
|
-
*/
|
|
155
|
-
returnType: T;
|
|
156
|
-
/**
|
|
157
|
-
* Enables safe mode, blocking potentially unsafe URLs and content.
|
|
158
|
-
* Prevents suspicious links, images, or HTML from being included in the final transcript.
|
|
159
|
-
*
|
|
160
|
-
* ⚠️ Disabling may allow unsafe content to appear in the transcript.
|
|
161
|
-
* @default true
|
|
162
|
-
*/
|
|
163
|
-
safeMode: boolean;
|
|
164
|
-
/**
|
|
165
|
-
* Whether to save images as base64 data directly in the transcript.
|
|
166
|
-
* This is an alternative to using a CDN and results in larger file sizes.
|
|
167
|
-
* Will not work if using CDN.
|
|
168
|
-
* @default false
|
|
169
|
-
*/
|
|
170
|
-
saveImages: boolean;
|
|
171
|
-
/**
|
|
172
|
-
* Whether the generated HTML should have its CSS and JS embedded directly in the file.
|
|
173
|
-
* Only applicable if `returnFormat` is `HTML`.
|
|
174
|
-
* @default false
|
|
175
|
-
*/
|
|
176
|
-
selfContained: boolean;
|
|
177
|
-
/**
|
|
178
|
-
* The timezone to use for formatting dates (e.g., 'UTC', 'America/New_York').
|
|
179
|
-
* Must be a valid IANA time zone name.
|
|
180
|
-
* @default 'UTC'
|
|
181
|
-
*/
|
|
182
|
-
timeZone: TimeZone;
|
|
183
|
-
/**
|
|
184
|
-
* Whether to include the 'Generated with discord-message-transcript' watermark in the footer.
|
|
185
|
-
* @default true
|
|
186
|
-
*/
|
|
187
|
-
watermark: boolean;
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Defines the structure for storing discovered mentions (users, roles, channels) during transcript creation.
|
|
191
|
-
* Uses Maps for efficient lookups.
|
|
192
|
-
*/
|
|
193
|
-
export interface MapMentions {
|
|
194
|
-
channels: Map<string, JsonMessageMentionsChannels>;
|
|
195
|
-
roles: Map<string, JsonMessageMentionsRoles>;
|
|
196
|
-
users: Map<string, JsonMessageMentionsUsers>;
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* A string template type for representing a MIME type (e.g., 'image/png', 'application/json').
|
|
200
|
-
*/
|
|
201
|
-
export type MimeType = `${string}/${string}`;
|
|
202
|
-
/**
|
|
203
|
-
* Base options applicable to all CDN providers.
|
|
204
|
-
*/
|
|
205
|
-
export type CDNBase = Partial<{
|
|
206
|
-
/**
|
|
207
|
-
* Whether to upload audio files to the CDN.
|
|
208
|
-
* @default true
|
|
209
|
-
*/
|
|
210
|
-
includeAudio: boolean;
|
|
211
|
-
/**
|
|
212
|
-
* Whether to upload image files (excluding GIFs) to the CDN.
|
|
213
|
-
* @default true
|
|
214
|
-
*/
|
|
215
|
-
includeImage: boolean;
|
|
216
|
-
/**
|
|
217
|
-
* Whether to upload video files (and GIFs) to the CDN.
|
|
218
|
-
* @default true
|
|
219
|
-
*/
|
|
220
|
-
includeVideo: boolean;
|
|
221
|
-
/**
|
|
222
|
-
* Whether to upload any other file types to the CDN.
|
|
223
|
-
* @default true
|
|
224
|
-
*/
|
|
225
|
-
includeOthers: boolean;
|
|
226
|
-
}>;
|
|
227
|
-
/**
|
|
228
|
-
* A discriminated union of all possible CDN configurations.
|
|
229
|
-
*/
|
|
230
|
-
export type CDNOptions = (CDNBase & CDNOptionsCustom<any>) | (CDNBase & CDNOptionsCloudinary) | (CDNBase & CDNOptionsUploadcare);
|
|
231
|
-
/**
|
|
232
|
-
* Configuration for using a custom, user-provided CDN resolver function.
|
|
233
|
-
*/
|
|
234
|
-
export type CDNOptionsCustom<T = unknown> = {
|
|
235
|
-
/** Specifies the use of a custom CDN resolver. */
|
|
236
|
-
provider: "CUSTOM";
|
|
237
|
-
/**
|
|
238
|
-
* An async function that takes a URL and returns a new URL.
|
|
239
|
-
* @param url The original Discord asset URL.
|
|
240
|
-
* @param contentType The MIME type of the asset.
|
|
241
|
-
* @param customData Any additional data you want to pass to your resolver.
|
|
242
|
-
* @returns The new URL of the asset on your CDN.
|
|
243
|
-
*/
|
|
244
|
-
resolver: (url: string, contentType: MimeType | null, customData: T) => Promise<string> | string;
|
|
245
|
-
/**
|
|
246
|
-
* Any custom data you wish to make available within your resolver function.
|
|
247
|
-
*/
|
|
248
|
-
customData: T;
|
|
249
|
-
};
|
|
250
|
-
/**
|
|
251
|
-
* Configuration for using Cloudinary as the CDN.
|
|
252
|
-
*/
|
|
253
|
-
export type CDNOptionsCloudinary = {
|
|
254
|
-
/**
|
|
255
|
-
* Specifies the use of the built-in Cloudinary provider.
|
|
256
|
-
*/
|
|
257
|
-
provider: "CLOUDINARY";
|
|
258
|
-
/**
|
|
259
|
-
* Your Cloudinary cloud name.
|
|
260
|
-
*/
|
|
261
|
-
cloudName: string;
|
|
262
|
-
/**
|
|
263
|
-
* Your Cloudinary API key.
|
|
264
|
-
* */
|
|
265
|
-
apiKey: string;
|
|
266
|
-
/**
|
|
267
|
-
* Your Cloudinary API secret.
|
|
268
|
-
*/
|
|
269
|
-
apiSecret: string;
|
|
270
|
-
};
|
|
271
|
-
/**
|
|
272
|
-
* Configuration for using Uploadcare as the CDN.
|
|
273
|
-
*/
|
|
274
|
-
export type CDNOptionsUploadcare = {
|
|
275
|
-
/**
|
|
276
|
-
* Specifies the use of the built-in Uploadcare provider.
|
|
277
|
-
*/
|
|
278
|
-
provider: "UPLOADCARE";
|
|
279
|
-
/**
|
|
280
|
-
* Your Uploadcare public key.
|
|
281
|
-
*/
|
|
282
|
-
publicKey: string;
|
|
283
|
-
/**
|
|
284
|
-
* Your Uploadcare CDN domain.
|
|
285
|
-
* Example: "aaa111aaa1.ucarecd.net".
|
|
286
|
-
* DO NOT INCLUDE https://
|
|
287
|
-
*/
|
|
288
|
-
cdnDomain: string;
|
|
289
|
-
};
|
|
290
|
-
/**
|
|
291
|
-
* Result from dns.lookup
|
|
292
|
-
*/
|
|
293
|
-
export type LookupResult = {
|
|
294
|
-
address: string;
|
|
295
|
-
family: 4 | 6;
|
|
296
|
-
};
|
|
297
|
-
export interface safeUrlReturn {
|
|
298
|
-
safe: boolean;
|
|
299
|
-
safeIps: string[];
|
|
300
|
-
url: string;
|
|
301
|
-
}
|
|
302
|
-
export type FetchMessagesContext = {
|
|
303
|
-
channel: TextBasedChannel;
|
|
304
|
-
options: TranscriptOptionsBase;
|
|
305
|
-
transcriptState: TranscriptState;
|
|
306
|
-
lastMessageId: string | undefined;
|
|
307
|
-
};
|
|
308
|
-
export type TranscriptState = {
|
|
309
|
-
authors: Map<string, JsonAuthor>;
|
|
310
|
-
mentions: MapMentions;
|
|
311
|
-
};
|
|
312
|
-
export type ReturnDiscordParser = [
|
|
313
|
-
json: Json,
|
|
314
|
-
maps: Maps
|
|
315
|
-
];
|
|
316
|
-
export type MapAuthors = Map<string, JsonAuthor>;
|
|
317
|
-
export type MapCache = Map<string, Promise<string>>;
|
|
318
|
-
export type Maps = {
|
|
319
|
-
authors: MapAuthors;
|
|
320
|
-
mentions: MapMentions;
|
|
321
|
-
urlCache: MapCache;
|
|
322
|
-
};
|
|
File without changes
|