Skip to content

EvilG-MC/discord-html-transcripts

 
 

Repository files navigation

discord-html-transcripts

A modified version of: discord-html-transcripts With the only purpose to make this works with Seyfert

GitHub package.json version GitHub Repo stars

Discord HTML Transcripts is a node.js module to generate nice looking HTML transcripts. Processes discord markdown like bold, italics, strikethroughs, and more. Nicely formats attachments and embeds. Built in XSS protection, preventing users from inserting arbitrary html tags.

This module can format the following:

  • Discord flavored markdown
  • Embeds
  • System messages
    • Join messages
    • Message Pins
    • Boost messages
  • Slash commands
    • Will show the name of the command in the same style as Discord
  • Buttons
  • Reactions
  • Attachments
    • Images, videos, audio, and generic files
  • Replies
  • Mentions
  • Threads

Styles from @derockdev/discord-components.
Behind the scenes, this package uses React SSR to generate a static site.

πŸ‘‹ Support

At the moment, create a issue To get support or create a pull request to add new features.

πŸ–¨οΈ Example Output

output

πŸ“ Usage

Example usage using the built in message fetcher.

import { createTranscript } from 'discord-html-transcripts';

const channel = ctx.channel(); // or however you get your text channel
if (!channel?.isTextGuild()) return;

// Must be awaited
const transcript = await createTranscript(channel);

await channel.messages.write({ files: [transcript] });

Or if you prefer, you can pass in your own messages.

import { createTranscript } from 'discord-html-transcripts';

const messages = someWayToGetMessages(); // Must be Message[]
const channel = someWayToGetChannel(); // Used for ticket name, guild icon, and guild name

// Must be awaited
const transcript = await generateFromMessages(messages, channel);

await channel.messages.write({ files: [transcript] });

βš™οΈ Configuration

Both methods of generating a transcript allow for an option object as the last parameter.
All configuration options are optional!

Built in Message Fetcher

const transcript = await createTranscript(channel, {
    limit: -1, // Max amount of messages to fetch. `-1` recursively fetches.
    returnType: 'attachment', // Valid options: 'buffer' | 'string' | 'attachment' Default: 'attachment' OR use the enum ExportReturnType
    filename: 'transcript.html', // Only valid with returnType is 'attachment'. Name of attachment.
    saveImages: false, // Download all images and include the image data in the HTML (allows viewing the image even after it has been deleted) (! WILL INCREASE FILE SIZE !)
    footerText: "Exported {number} message{s}", // Change text at footer, don't forget to put {number} to show how much messages got exported, and {s} for plural
    callbacks: {
      // register custom callbacks for the following:
      resolveChannel: (channelId: string) => Awaitable<AllChannels | null>,
      resolveUser: (userId: string) => Awaitable<User | null>,
      resolveRole: (roleId: string) => Awaitable<GuildRole | null>
    },
    poweredBy: true, // Whether to include the "Powered by discord-html-transcripts" footer
    hydrate: true // Whether to hydrate the html server-side
});

Providing your own messages

const transcript = await generateFromMessages(messages, channel, {
  // Same as createTranscript, except no limit
});

🀝 Enjoy the package?

Give it a star ⭐ and/or support the original author on ko-fi

About

A node.js library for generating nicely formatted HTML transcripts with discord.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%