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

dsc.archive

v0.2.1

Published

A powerful Discord message archiving and export library supporting HTML, JSON, TXT, and more formats.

Readme

dsc.archive (Beta v0.2.0)

🧪 This library is currently in beta, its functions may change radically between releases.

A library that allows you to fetch and archive messages from a Discord channel using discord.js.

The goal of the project is to be able to export messages into various formats, such as HTML, JSON, and TXT, so that it can help create transcripts for tickets.

How to install it?

To install it, go to the folder of your Node.js project where you would like to use the library and run the following command in the terminal:

npm install dsc.archive

Compatibility: This library is compatible with all discord.js v14 versions. However, it's recommended to use the latest v14 release.

Quick setup guide

If you want to quickly try out the library or simply understand how it works, this is the right section for you:

  1. if you don't already have it, install Node.js;
  2. create a folder and open it in a terminal;
  3. run in the terminal:
npm init -y
npm i dsc.archive
  1. create a file called index.js and paste this code into it:
const { Client } = require('discord.js');
const { fetchMessages } = require("dsc.archive");

const client = new Client({ intents: [] });

client.login("YOUR_BOT_TOKEN").then(async () => {
    const channel = await client.channels.fetch("CHANNEL_ID");
    const result = await fetchMessages(channel, 1);
    console.log(result);
    
    process.exit(0);
});
  1. replace:
    • YOUR_BOT_TOKEN with the token of the Discord bot you want to test the library with (create an application if you don't already have one): https://discord.com/developers/applications/,
    • CHANNEL_ID with the ID of a Discord channel your bot has access to;
  2. make sure that the bot has the Message Content Intent enabled and the permission to view and read message history in the channel;
  3. run in the terminal:
node .

Keep reading below to learn how to use all the available features.

How to use it?

fetchMessages()

Currently, the only function in the library is fetchMessages, which allows you to fetch messages from a Discord text-based channel, filter them, and return them in a FetchedMessages object:

const { fetchMessages } = require('dsc.archive');

fetchMessages(channel, amount?, fields?, options?);

channel must be a Discord text-based channel;

amount must be an integer between 1 and Infinity. The default value is 100;

fields can be true (all fields will be returned), undefined (default fields will be returned), or a non-empty object. You can see the current default fields here: DefaultFields. To see the updated full list of every field available, visit: https://discord.js.org/docs/packages/discord.js/main/Message:Class.

options can be true (all options will be returned), false (none of the options will be returned) or a non-empty object to select which option should be returned. You can see the option list here: Options and the current default options here: DefaultOptions.

The field filtering system works according to a level-based whitelist/blacklist system. If no false fields are present in a level, it will be whitelisted, displaying only the fields marked as true and/or the nested objects selected at that level.

Here's an example of the FetchedMessages structure:

const result = await fetchMessages(channel, Infinity, true, true);

console.log(result);

It will return something similar to this:

FetchedMessages {
  messages: [Messages],
  guild: [Guild],
  channel: [TextChannel],
  authors: [Authors],
  interactions: [Interactions],
  webhooks: [Webhooks],
  fetchTimestamp: 1786039623635,
}

For an explanation of each of these properties, see FetchedMessages.

For messages, authors, interactions and webhooks, if the array or map has more than 5 entries, it will be replaced by [Messages], [Authors], [Interactions] and [Webhooks], to improve readability. To access the full array/map:

result.messages.raw
result.authors.raw
result.interactions.raw
result.webhooks.raw

guild and channel will always be replaced by [Guild] and [VARIOUS_TYPES_OF_CHANNEL]. To access them you can just do:

result.guild
result.channel

I added some custom functions to help you manage the result, especially when working with a lot of data:

result.size //Alias of `result.messages.length`
result.length //Alias of `result.messages.length`
result.messages.raw
result.messages.get('MESSAGE_ID') //Even though it's not a map, I thought this could be a useful shortcut
result.messages.first(NUMBER) //Get the first message(s) in the array
result.messages.last(NUMBER) //Get the last message(s) in the array
result.authors.raw
result.authors.first(NUMBER) //Get the first author(s) in the map
result.authors.last(NUMBER) //Get the last author(s) in the map
result.interactions.raw
result.interactions.first(NUMBER) //Get the first author(s) that sent messages associated with interactions in the map
result.interactions.last(NUMBER) //Get the last author(s) that sent messages associated with interactions in the map
result.webhooks.raw
result.webhooks.first(NUMBER) //Get the first webhooks(s) in the map
result.webhooks.last(NUMBER) //Get the last webhooks(s) in the map

Roadmap

  • [x] Fetch messages and filter them
  • [x] Fix some filtering bugs
  • [x] Improve fetchMessages
  • [ ] Export fetched messages as JSON
  • [ ] Export fetched messages as TXT
  • [ ] Export fetched messages as HTML

AI Disclaimer

I used AIs like Github Copilot and ChatGPT mainly to speed up programming and solve problems I couldn't identify. I then modified the code generated by the AIs to best fit my code without problems.