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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@eliware/discord

v1.1.2

Published

A modular, extensible Discord app framework for Node.js with slash command, localization, and event-driven support.

Readme

eliware.org

@eliware/discord npm versionlicensebuild status

A modular, extensible Discord app framework for Node.js, with built-in support for slash commands, localization, and event-driven architecture.


Table of Contents

Features

  • Simple, opinionated Discord app setup for Node.js
  • Slash command registration and handler auto-loading
  • Event handler auto-loading for all Discord Gateway events
  • Built-in localization system with easy locale file management
  • TypeScript type definitions included
  • Dependency injection and testability for all major components
  • Logging and error handling hooks
  • Extensible and modular directory structure

Installation

npm install @eliware/discord

Usage

ESM Example

import 'dotenv/config';
import log from '@eliware/log';
import path from '@eliware/path';
import { createDiscord } from '@eliware/discord';

try {
  await createDiscord({
    log,
    rootDir: path(import.meta),
    intents: { MessageContent: true }
  });
} catch (err) {
    log.error('Failed to start app:', err);
}

CommonJS Example

require('dotenv/config');
const log = require('@eliware/log').default;
const path = require('@eliware/path').default;
const { createDiscord } = require('@eliware/discord');

(async () => {
  try {
    await createDiscord({
      log,
      rootDir: path(__filename),
      intents: { MessageContent: true }
    });
  } catch (err) {
    log.error('Failed to start app:', err);
  }
})();

API

createDiscord(options): Promise<Client>

Creates and logs in a Discord client, auto-registers commands, loads event handlers, and sets up localization.

Options:

  • client_id (string): Discord application client ID (required)
  • token (string): Discord bot token (required)
  • log (Logger): Logger instance (optional)
  • rootDir (string): Root directory for events, commands, and locales (default: autodetect)
  • localesDir (string): Directory for locale files (default: <rootDir>/locales)
  • commandsDir (string): Directory for command definitions and handlers (default: <rootDir>/commands)
  • eventsDir (string): Directory for event handlers (default: <rootDir>/events)
  • intents (object): Discord Gateway Intents (default: Guilds and GuildMessages enabled)
  • partials (array): Discord.js partials (default: ['MESSAGE', 'CHANNEL', 'REACTION'])
  • clientOptions (object): Additional Discord.js client options
  • ClientClass (constructor): Custom Discord.js Client class (for testing)
  • setupEventsFn, setupCommandsFn, registerCommandsFn, setupLocalesFn: Dependency injection for advanced use/testing
  • context (object): Additional arbitrary data to be injected into all event and command handlers

Returns: A logged-in Discord.js Client instance.

splitMsg(msg, maxLength = 2000): string[]

Splits a message into chunks of up to maxLength characters, attempting to split at newlines or periods for readability.

  • msg (string): The message to split
  • maxLength (number, optional): The maximum length of each chunk (default: 2000)
  • Returns: An array of message chunks, each no longer than maxLength.

Command and Event Structure

  • Commands:
    • Place .json files in the commands/ directory for each command definition (see commands/help.json for structure).
    • Place a .mjs file with the same name for the command handler (see commands/help.mjs).
  • Events:
    • Place .mjs files in the events/ directory, named after Discord Gateway events (e.g., ready.mjs, messageCreate.mjs).

Localization

  • Place locale files in the locales/ directory (e.g., en-US.json, es-ES.json).
  • Each file should be a flat key-value JSON object for that locale.

TypeScript

Type definitions are included and cover all public APIs and options:

import type { CreateDiscordOptions } from '@eliware/discord';

declare function createDiscord(options?: CreateDiscordOptions): Promise<Client>;

Support

For help, questions, or to chat with the author and community, visit:

Discordeliware.org

eliware.org on Discord

License

MIT © 2025 Eli Sterling, eliware.org

Links