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

command-ts

v0.0.2

Published

A package for handling discord.js commands with TypeScript.

Readme

command-ts

Discord GitHub Action NPM Version NPM Downloads NPM Unpacked Size NPM License

A package for handling discord.js commands with TypeScript

Installation

To install command-ts, run one of the following commands based on your preferred package manager:

NPM

npm install command-ts

PNPM

pnpm add command-ts

Yarn

yarn add command-ts

Usage

import { handler } from "command-ts"
import { Client, GatewayIntentBits } from "discord.js"

const client = new Client({
    intents: [GatewayIntentBits.Guilds]
})

handler({
    client,
    debug: true, // Enable debug logging
    command: "./commands", // Path to commands folder
    event: "./events", // Path to events folder
    button: "./buttons", // Path to button handlers
    modal: "./modals", // Path to modal handlers
    selectmenu: "./selectmenus" // Path to select menu handlers
})

client.login("YOUR_TOKEN")

Command Structure

Create a command file in your commands folder:

import { Command } from "command-ts"

export const command: Command = {
    data: {
        name: "ping",
        description: "Replies with pong!"
    },
    run: async (interaction) => {
        await interaction.reply("Pong!")
    }
}

API Documentation

Handler Options

The handler function accepts an options object with the following properties:

type Options = {
    client: Client // Discord.js client instance (required)
    debug?: boolean // Enable debug logging
    event?: string | EventMap // Path to events folder or event map
    command?: string | CommandMap // Path to commands folder or command map
    button?: string | ButtonMap // Path to button handlers or button map
    modal?: string | ModalMap // Path to modal handlers or modal map
    selectmenu?: SelectMenu | string // Path to select menu handlers or select menu config
    middleware?: Middleware | Middleware[] // Command middleware functions
}

Command Types

Commands must implement the Command Types:

type Command = {
    data: RESTPostAPIApplicationCommandsJSONBody // Command registration data
    autocomplete?: (interaction: AutocompleteInteraction) => any // Optional autocomplete handler
    run: (interaction: ChatInputCommandInteraction | ContextMenuCommandInteraction) => any
}

SelectMenu Types

The SelectMenu configuration supports different menu types:

type SelectMenu = {
    StringSelectMenu?: string | ((interaction: StringSelectMenuInteraction) => any)
    UserSelectMenu?: string | ((interaction: UserSelectMenuInteraction) => any)
    RoleSelectMenu?: string | ((interaction: RoleSelectMenuInteraction) => any)
    MentionableSelectMenu?: string | ((interaction: MentionableSelectMenuInteraction) => any)
    ChannelSelectMenu?: string | ((interaction: ChannelSelectMenuInteraction) => any)
}

Middleware

Middleware functions can be used to add custom logic before command execution:

type Middleware = (command: Command, interaction: CommandInteraction, stop: (reason?: string) => void) => any

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the Apache-2.0 License. See the LICENSE file for details.