Skip to main content

Data Types

You can import any of these types directly from the package:

import type { TranscriptData, DiscordMessage, DiscordPoll } from "@getoeteter/discord-transcripts";

TranscriptData​

This is what you pass to generateTranscriptHtml:

interface TranscriptData {
guild?: DiscordGuild;
channel: DiscordChannel;
messages: DiscordMessage[];
roles?: Record<string, DiscordRole>; // For mention coloring
channels?: Record<string, DiscordChannel>; // For channel mention names
memberRoles?: Record<string, string[]>; // User ID → role IDs
generatedAt?: string; // ISO timestamp
totalMessages?: number; // Override message count display
}

DiscordGuild​

interface DiscordGuild {
id: string;
name: string;
icon?: string | null; // CDN hash or full https:// URL
}

DiscordChannel​

interface DiscordChannel {
id: string;
name: string;
type: number; // 0 = Text, 2 = Voice, 5 = Announcement, etc.
topic?: string | null;
}

DiscordRole​

interface DiscordRole {
id: string;
name: string;
color: number; // Integer color (0 = no color)
}

DiscordMessage​

interface DiscordMessage {
id: string;
type: DiscordMessageType;
content: string;
author: DiscordUser;
timestamp: string; // ISO timestamp
editedTimestamp?: string | null;
mentions?: DiscordMention[];
attachments?: DiscordAttachment[];
embeds?: DiscordEmbed[];
reactions?: DiscordReaction[];
pinned?: boolean;
webhookId?: string | null;
messageReference?: DiscordMessageReference | null;
referencedMessage?: DiscordMessage | null;
thread?: DiscordThread | null;
components?: DiscordComponent[];
stickers?: DiscordSticker[];
poll?: DiscordPoll;
interaction?: DiscordInteraction;
voiceMessage?: DiscordVoiceMessage;
messageSnapshots?: DiscordMessageSnapshot[]; // Forwarded content
}

Message Types​

Use the DiscordMessageType enum rather than raw numbers. System message types are rendered as a one-line notice; any other type renders as a normal message.

ValueNameDescription
0DefaultRegular message
1RecipientAddRecipient added to a group DM
2RecipientRemoveRecipient removed from a group DM
3CallCall started
4ChannelNameChangeChannel renamed
5ChannelIconChangeChannel icon changed
6ChannelPinnedMessageMessage pinned
7UserJoinMember joined
8GuildBoostServer boosted
9GuildBoostTier1Boost reached level 1
10GuildBoostTier2Boost reached level 2
11GuildBoostTier3Boost reached level 3
12ChannelFollowAddChannel follow added
14GuildDiscoveryDisqualifiedRemoved from Server Discovery
15GuildDiscoveryRequalifiedRelisted in Server Discovery
16GuildDiscoveryGracePeriodInitialWarningDiscovery activity warning (1 week)
17GuildDiscoveryGracePeriodFinalWarningDiscovery activity warning (3 weeks)
18ThreadCreatedThread started
19ReplyReply to a message
20ChatInputCommandSlash command response
21ThreadStarterMessageFirst message of a thread
22GuildInviteReminderInvite reminder
23ContextMenuCommandContext menu command response
24AutoModerationActionAutoMod blocked a message
25RoleSubscriptionPurchaseRole subscription purchase
26InteractionPremiumUpsellPremium upsell
27StageStartStage event started
28StageEndStage event ended
29StageSpeakerNew Stage speaker
31StageTopicStage topic changed
32GuildApplicationPremiumSubscriptionApp premium subscription
36GuildIncidentAlertModeEnabledSecurity actions enabled
37GuildIncidentAlertModeDisabledSecurity actions disabled
38GuildIncidentReportRaidRaid reported
39GuildIncidentReportFalseAlarmFalse alarm reported
46PollResultPoll closed, with the result

DiscordUser​

interface DiscordUser {
id: string;
username: string;
discriminator?: string;
globalName?: string | null;
avatar?: string | null; // CDN hash or full https:// URL
bot?: boolean;
}
tip

The avatar field accepts either a Discord CDN hash (e.g. "a_1234abcd") or a direct URL (e.g. "https://cdn.discordapp.com/avatars/..."). The renderer detects which format is used automatically.


DiscordEmbed​

interface DiscordEmbed {
title?: string;
type?: string; // "rich", "image", "gifv", "video", "link"
description?: string;
url?: string;
timestamp?: string;
color?: number; // Integer color (e.g. 0x5865f2)
footer?: { text: string; iconUrl?: string };
image?: { url: string; width?: number; height?: number };
thumbnail?: { url: string; width?: number; height?: number };
video?: { url?: string; proxyUrl?: string; width?: number; height?: number };
provider?: { name?: string; url?: string };
author?: { name: string; url?: string; iconUrl?: string };
fields?: { name: string; value: string; inline?: boolean }[];
}

DiscordAttachment​

interface DiscordAttachment {
id: string;
filename: string;
description?: string | null;
contentType?: string | null; // MIME type
size: number; // Bytes
url: string;
width?: number | null;
height?: number | null;
spoiler?: boolean;
}

How attachments look depends on the content type:

  • Images (image/*) - shown inline with optional spoiler blur
  • Video (video/*) - embedded <video> player
  • Audio (audio/*) - embedded <audio> player
  • Anything else - download link with file size

DiscordPoll​

interface DiscordPoll {
question: DiscordPollMedia;
answers: DiscordPollAnswer[];
allowMultiselect?: boolean;
expiry?: string; // ISO timestamp
isFinalized?: boolean;
}

interface DiscordPollAnswer {
answerId: number;
pollMedia: DiscordPollMedia;
count?: number; // Vote count
}

interface DiscordPollMedia {
text?: string;
emoji?: DiscordEmoji;
}

See Polls feature for rendering details.


DiscordInteraction​

interface DiscordInteraction {
name: string; // Slash command or context menu name
user: DiscordUser; // User who triggered it
}

See Slash Command Context for rendering details.


DiscordMessageSnapshot​

The content of a forwarded message.

interface DiscordMessageSnapshot {
content?: string;
timestamp?: string; // ISO timestamp of the original message
attachments?: DiscordAttachment[];
embeds?: DiscordEmbed[];
stickers?: DiscordSticker[];
}

See Forwarded Messages for rendering details.


DiscordVoiceMessage​

interface DiscordVoiceMessage {
duration: number; // Seconds
waveform?: string; // Base64-encoded waveform data
}

See Voice Messages for rendering details.


DiscordComponent​

interface DiscordComponent {
type: number;
style?: number; // Button style (1-5)
label?: string;
emoji?: DiscordEmoji;
customId?: string;
url?: string;
disabled?: boolean;
components?: DiscordComponent[]; // Children
content?: string; // V2 TextDisplay/Label
accentColor?: number; // V2 Container border color
spoiler?: boolean;
accessory?: DiscordComponentAccessory;
items?: DiscordMediaGalleryItem[];
file?: { url: string; contentType?: string };
spacing?: number; // Separator: 1 = small, 2 = large
divider?: boolean;
media?: { url: string };
description?: string;
}

Component Types​

V1 Components:

TypeNameDescription
1ActionRowContainer for buttons/selects
2ButtonClickable button
3StringSelectDropdown select menu
5UserSelectUser picker
6RoleSelectRole picker
7MentionableSelectMentionable picker
8ChannelSelectChannel picker

V2 Components:

TypeNameDescription
9SectionSection with optional accessory
10TextDisplayRich text display
11ThumbnailSmall image
12MediaGalleryImage grid
13FileFile display
14SeparatorDivider line
17ContainerBordered container
18LabelSimple text label

DiscordThread​

interface DiscordThread {
id: string;
name: string;
messageCount?: number;
messages?: DiscordMessage[]; // For inline expansion (expandThreads option)
}

DiscordReaction​

interface DiscordReaction {
emoji: DiscordEmoji;
count: number;
}

interface DiscordEmoji {
id?: string | null; // null/undefined for Unicode emoji
name: string; // Unicode char or custom emoji name
animated?: boolean;
}

DiscordSticker​

interface DiscordSticker {
id: string;
name: string;
formatType: number; // 1 = PNG, 2 = APNG, 3 = Lottie, 4 = GIF
url?: string; // Direct URL to sticker image
}

TranscriptOptions​

Configuration options passed to generateTranscriptHtml() or createTranscript().

interface TranscriptOptions {
theme?: "light" | "dark";
showReactions?: boolean;
showAvatars?: boolean;
showTimestamps?: boolean;
showRoleColors?: boolean;
showEmbeds?: boolean;
showAttachments?: boolean;
showThreads?: boolean;
showHeader?: boolean;
customCss?: string;
faviconUrl?: string;
dateFormat?: "relative" | "absolute" | "both";
maxImageWidth?: number;
fontFamily?: string;
compact?: boolean;
pageTitle?: string;
locale?: string;
timeZone?: string;
enableThemeToggle?: boolean;
enableSearch?: boolean;
enableDateNav?: boolean;
showUserStats?: boolean;
enableCopyButton?: boolean;
collapsibleEmbeds?: boolean;
enableLightbox?: boolean;
includeJson?: boolean;
messagesPerPage?: number;
customRenderers?: Record<number, (component: DiscordComponent) => string>;
expandThreads?: boolean;
embedMedia?: boolean;
/** @internal Populated by resolveMediaUrls(), do not set manually */
_resolvedMedia?: Map<string, string>;
}

See Options Reference for detailed descriptions of each option.


TranscriptData​

Input data structure for generateTranscriptHtml().

interface TranscriptData {
guild?: DiscordGuild;
channel: DiscordChannel;
messages: DiscordMessage[];
roles?: Record<string, DiscordRole>;
channels?: Record<string, DiscordChannel>;
memberRoles?: Record<string, string[]>;
generatedAt?: string;
totalMessages?: number;
}