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-express

v0.0.0-a1

Published

DiscordJS reimagined: seamlessly integrate slash and message commands with the pluggable, middleware-based Discord bot framework inspiried by ExpressJS.

Downloads

305

Readme

Discord Express

Node.js CI

DiscordJS reimagined: seamlessly integrate slash and message commands with the pluggable, middleware-based Discord bot framework inspiried by ExpressJS.

Discord-express delivers the promise of "express" in 3 ways:

  1. Express inspiried

    Discord-express is inspiried by Express, so if you have used Express before, you will already be quite familliar.

  2. Expressive

    Write code that's easier to understand with reuseable, pluggable middleware, and an alternative slash command builder that doesn't feel as cluncky and verbose as the default builder.

  3. The express route

    Write DRYer (don't repeat yourself) code and don't WET (write everything twice) yourself! Take advantage of discord-express's seamsless slash and message command integration, and get rid of your boilerplate code.

Never use Discord bot boilerplate template again

Discord-express takes care of that for you, so you can just install and get going with your business instead of trying to figure out someone elses template.

Why?

When slash commands came around, I knew I would eventually have to migrate. But if I wanted to keep message commands around, there was no good way of going about it. I was also getting tired of all the boilerplate needed for a Discord bot. There's tons of elaborate templates on Github just to get a bot started. But if you look at an express app, there isn't nearly as much boilerplate. Why can't there be a solution then?

How?

There is still boilerplate associated with creating a bot. This will get you started.

Requirements: node >= 16.6

More comprehensive examples are available at examples

Javascript:

npm i discord.js discord-express dotenv
yarn add discord.js discord-express dotenv
pnpm add discord.js discord-express dotenv

Typescript:

npm i @types/node
yarn add @types/node
pnpm add @types/node
import {Client, builtins, createCommands, middleware} from "discord-express"
import dotenv from "dotenv"

dotenv.config()

/** @type {import("discord-express").Commands} */
const commands = {
    help: builtins.help.command,
}

const client = new Client({
    intents: ["GUILD_MESSAGES", "GUILDS"],
    authToken: process.env.TOKEN,
})

client.registerCommands(createCommands(commands), process.env.CLIENT_ID)
client.initExpress()

client.use(...middleware.recommended())
client.use(middleware.messageCommandParser({prefix: "~"}))
client.command("help", builtins.help.handler({commands}))

client.on("ready", () => {
    console.log("ready")
})

And that's it! You're ready to get started.