npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

discord2html

v1.0.4

Published

Generate styled HTML transcripts from Discord channel message history. Fork of discord-html-transcripts with bug fixes, Components V2 support, and dual CJS/ESM output.

Readme

discord2html

Generate styled HTML transcripts from Discord channel message history. Processes Discord-flavored markdown, embeds, attachments, reactions, threads, and Discord Components V2.

discord2html is a maintained fork of discord-html-transcripts. This fork fixes the critical v3.3.0 bug, adds full Discord Components V2 support, and modernizes the package for current Discord.js and Node.js versions.


What's different from the original

  • Bug fix: v3.3.0 introduced a stray ; after the <style> JSX tag that prevented all custom CSS from loading, breaking the visual rendering of every Components V2 message. Fixed.
  • Components V2: Select menu option emojis now render as images (not raw URL strings). Premium button style handled. All unknown component types degrade gracefully to null instead of throwing.
  • Modern markdown: Headings (#, ##, ###) and subtext (-#) are now rendered as styled HTML instead of falling through to plain text — important for Components V2 messages that rely on them.
  • Footer branding: New branding option ({ text, url?, color? }) renders your brand in the transcript footer, optionally as a clickable link.
  • CJS interop fix: discord-markdown-parser's parse is now imported as a named export. The previous default import resolved to the whole module.exports object under ESM, causing a runtime parse is not a function error.
  • Dual CJS/ESM output: Package now ships both dist/index.js (CJS) and dist/index.mjs (ESM) with matching .d.ts / .d.mts type declarations. The exports field is set correctly.
  • Dependency fix: debug was in devDependencies but is used in production code — moved to dependencies.
  • Bundled React (self-contained): React, ReactDOM and @derockdev/discord-components-* are bundled into the dist at build time. The package renders with React 19 (react-dom/static), but @derockdev/discord-components-react peer-requires React ≤18 — so a naïve install left two React copies in the tree, and elements created under React 18 failed to render under React 19 with "Objects are not valid as a React child". Bundling resolves every import React to a single React 19 instance baked into the package, so consumers never need to install React or add overrides — only discord.js. The ESM build injects a createRequire shim so the bundled CJS react-dom server can load Node built-ins (util, stream, …) without the "Dynamic require of X is not supported" error.
  • Modernized: TypeScript target updated to ES2020. React updated to 19.2.4. Build pipeline switched from raw tsc to tsup.

Installation

npm install discord2html

Peer dependency: discord.js v14 or v15


Quick start

import * as discord2html from 'discord2html';
// or: const discord2html = require('discord2html');

// Using the built-in message fetcher
const transcript = await discord2html.createTranscript(channel);
channel.send({ files: [transcript] });

// Using your own message array/collection
const transcript = await discord2html.generateFromMessages(messages, channel);
channel.send({ files: [transcript] });

API reference

createTranscript(channel, options?)

Fetches all messages from a TextBasedChannel and generates an HTML transcript.

| Parameter | Type | Description | |-----------|------|-------------| | channel | TextBasedChannel | The channel to fetch messages from | | options | CreateTranscriptOptions | Optional configuration (see below) |

Returns Promise<AttachmentBuilder> by default, or Promise<Buffer> / Promise<string> based on returnType.

generateFromMessages(messages, channel, options?)

Generates an HTML transcript from a provided message collection or array.

| Parameter | Type | Description | |-----------|------|-------------| | messages | Message[] \| Collection<string, Message> | Messages to render | | channel | Channel | Used for the header (guild name, channel name, icon) | | options | GenerateFromMessagesOptions | Optional configuration (see below) |

Options

All options are optional.

{
  // createTranscript only:
  limit: number;           // Max messages to fetch. -1 fetches all. Default: all
  filter: (msg) => bool;  // Filter function applied before rendering

  // both functions:
  returnType: ExportReturnType; // 'attachment' | 'buffer' | 'string'. Default: 'attachment'
  filename: string;             // Attachment filename. Default: 'transcript-{channel-id}.html'
  saveImages: boolean;          // Download images and inline as base64. Default: false
  poweredBy: boolean;           // Show "Powered by discord2html" footer. Default: true
  footerText: string;           // Footer text. Use {number} and {s}. Default: 'Exported {number} message{s}.'
  favicon: 'guild' | string;    // 'guild' uses the server icon, or pass a URL. Default: 'guild'
  hydrate: boolean;             // Server-side hydrate the HTML. Default: false

  callbacks: {
    resolveChannel: (id: string) => Awaitable<Channel | null>;
    resolveUser:    (id: string) => Awaitable<User | null>;
    resolveRole:    (id: string) => Awaitable<Role | null>;
    resolveImageSrc: (attachment: APIAttachment, message: APIMessage) => Awaitable<string | null | undefined>;
  };
}

ExportReturnType (enum)

import { ExportReturnType } from 'discord2html';

ExportReturnType.Attachment  // returns AttachmentBuilder (default)
ExportReturnType.Buffer      // returns Buffer
ExportReturnType.String      // returns string

TranscriptImageDownloader

Builder for the resolveImageSrc callback. Downloads and optionally compresses images inline.

import { TranscriptImageDownloader } from 'discord2html';

callbacks: {
  resolveImageSrc: new TranscriptImageDownloader()
    .withMaxSize(5120)            // Skip images over 5 MB
    .withCompression(40, true)    // 40% quality, convert to WebP (requires `sharp`)
    .build(),
}

TypeScript

The package ships .d.ts and .d.mts type declarations. No @types/discord2html package is needed.

import type { CreateTranscriptOptions, GenerateFromMessagesOptions, ExportReturnType } from 'discord2html';

License

Apache-2.0. Original work by Derock. Fork maintained by José Hernanes.