@brynjolf/commands
v0.0.1
Published
A clean, easy, and agnostic Discord slash command handler.
Downloads
9
Maintainers
Readme
Brynjolf Commands
Easily create, register, and handle Discord slash commands. This system is library-agnostic, allowing you to use nearly the exact same command-handling code for the Discord API as you would for a library such as Discord.js. Built-in support is provided for API interactions and Discord.js interactions via Adapters.
Features
- 📚 Library-agnostic, can support various libraries and the Discord API
- 🔧 Built-in adapters for Discord API and Discord.js
- 🪶 Lightweight
- 🍰 Easy to use
- 🧩 Fully documented
- 🪆 No heavily nested object literals
- 👥 Registration does not require any additional dependencies
- 🛜 Can register commands with or without handling them
- 🧠 Built with Typescript, providing great IDE intellisense
Get Started
- Create a Discord client with your preferred library or with Discord API requests
- Install Brynjolf Commands with
npm install @brynjolf/commands
- Run the quick example below, or skip the tutorial and dive right in
Quick Example
This is a basic example for Discord.js. When using the Discord API or another library, swap Adapter.DJS
for Adapter.API
. When you don't need command handling and only need registration, use Adapter.REGISTER_ONLY
with an empty execute()
method.
import { Command, commands, Adapter } from "@brynjolf/commands"
// Create command
new Command("ping", "Returns a pong!")
.adapter(Adapter.DJS)
.execute(i => {
i.reply("Pong!");
});
// Register commands
commands.setToken(TOKEN, APPLICATION_ID, OPTIONAL_GUILD_ID);
commands.registerAll();
// Discord.js code to handle Brynjolf commands
client.on("interactionCreate", i => {
if (!i.isChatInputCommand()) return;
commands.execute(i.commandName, i);
});
Docs
Detailed examples do not exist yet, but will be added soon.
Primary Features →
Typescript Types →
Examples →