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 🙏

© 2024 – Pkg Stats / Ryan Hefner

discord-mainscript

v1.0.0

Published

A good formatted html transcript generator.

Downloads

5

Readme

discord-html-transcripts

Discord HTML mainscript is a node.js module to generate nice looking HTML transcripts. Processes discord markdown like bold, italics, ~~strikethroughs~~, and much more! Nicely formats attachments and embeds.

This module can format the following things like:

  • Discord flavored markdown
    • Allows for complex markdown syntax to be parsed properly
  • 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

📝 Usage

Example usage using the built in message fetcher.

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

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-mainscript');
// or (if using typescript) import * as discordTranscripts from 'discord-html-mainscript';

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],
});
//if you prefer, you can also send the html file to your own dashboard page! to do this you need to us fs so:
const fs = require('fs').promises;
let channel = interaction.channel
        let test = await mainscript.createTranscript(channel, {
            limit: -1,
            returnType: 'string',
            returnBuffer: false,
            fileName: `${channel.name}`,
            minify: true,
            saveImages: true,
            useCDN: true,
        })

await fs.writeFile(process.cdv() + `some place you want to create your file to...`, test).catch(err => console.log(err));
//if you need any help how you can do this all. You can always add me on discord: tonymelony#5793 :)

⚙️ 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) (! NOTE IT WILL INCREASE FILE SIZE !)
    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-mainscript" footer
});

Providing your own messages

const attachment = await discordTranscripts.generateFromMessages(messages, channel, {
  // Same as createTranscript, but no limit
});

🤝 Hope you will enjoy the package? Love By Tonymelony