Coder Social home page Coder Social logo

marcrock22 / discord-html-transcripts Goto Github PK

View Code? Open in Web Editor NEW

This project forked from evilg-mc/discord-html-transcripts

0.0 0.0 0.0 313 KB

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

Home Page: http://npmjs.org/package/discord-html-transcripts

License: Apache License 2.0

TypeScript 100.00%

discord-html-transcripts's Introduction

discord-html-transcripts

Discord npm 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

This module is designed to work with discord.js v14/v15 only. If you need v13 support, roll back to v2.X.X

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

๐Ÿ‘‹ Support

Please do not DM me requesting support with this package, I will not respond.
Instead, please open a thread on this server.

๐Ÿ–จ๏ธ Example Output

output

๐Ÿ“ Usage

Example usage using the built in message fetcher.

const discordTranscripts = require('discord-html-transcripts');
// or (if using typescript) import * as discordTranscripts from 'discord-html-transcripts';

const channel = message.channel; // or however you get your TextChannel

// Must be awaited
const attachment = await discordTranscripts.createTranscript(channel);

channel.send({
  files: [attachment],
});

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

const discordTranscripts = require('discord-html-transcripts');
// or (if using typescript) import * as discordTranscripts from 'discord-html-transcripts';

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

// Must be awaited
const attachment = await discordTranscripts.generateFromMessages(messages, channel);

channel.send({
  files: [attachment],
});

โš™๏ธ 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 attachment = await discordTranscripts.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<Channel | null>,
      resolveUser: (userId: string) => Awaitable<User | null>,
      resolveRole: (roleId: string) => Awaitable<Role | 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 attachment = await discordTranscripts.generateFromMessages(messages, channel, {
  // Same as createTranscript, except no limit
});

๐Ÿค Enjoy the package?

Give it a star โญ and/or support me on ko-fi

discord-html-transcripts's People

Contributors

itzderock avatar snyk-bot avatar imranbarbhuiya avatar kurstch avatar evilg-mc avatar serenmodz21 avatar eejit43 avatar jiralite avatar geekcornergh avatar lonoxx avatar marcrock22 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.