@djs-commands/core
v2.0.1
Published
Modern Discord.js command handler — dispatcher, definitions, validators, plugins
Maintainers
Readme
@djs-commands/core
Modern Discord.js command handler — TypeScript-first, Components V2 native, with pluggable persistence.
📘 Full documentation: https://djscommands.deoxy.dev
Install
bun add @djs-commands/core discord.js
# or: pnpm / npm / yarndiscord.js@^14.26 is a peer dependency.
Quick start
import { Client, GatewayIntentBits } from "discord.js";
import { createCommandHandler, defineCommand } from "@djs-commands/core";
const ping = defineCommand({
name: "ping",
description: "Replies with pong",
run: async ({ reply }) => {
await reply("pong");
},
});
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
const handler = createCommandHandler({ client, commands: [ping] });
await handler.ready;
await client.login(process.env.DISCORD_TOKEN);Prefer scaffolding? Run npx create-djs-commands my-bot and you're online in under a minute.
What's in the box
defineCommand— typed slash + legacy prefix commands with sharedCommandRunContext. Docs →- Validators — built-in
ownerOnly/guildOnly/channels/permissions/roles, plus customValidatorfunctions. Docs → - Cooldowns — four scopes (
perUser/perGuild/perUserPerGuild/global); pluggableCacheAdapterfor distributed setups. Docs → - Plugins — bundle commands and lifecycle hooks;
setup/teardownawaited at boot. Docs → - Storage — generic
Storageadapter contract drivesguild_prefix,disabled_commands,channel_locksframework models, plus your own. Docs → - Components V2 — function-form builders (
button,container,section,modal, …); pair with@djs-commands/jsxfor JSX. Docs → - fs-autoloader —
commandDirautoloads files; hot reloads in dev.
Companion packages
| Package | Purpose |
|---|---|
| @djs-commands/jsx | Components V2 JSX runtime |
| @djs-commands/adapter-drizzle | Drizzle/Postgres Storage |
| @djs-commands/adapter-prisma | Prisma Storage |
| @djs-commands/adapter-mongoose | Mongoose Storage (v1 continuity path) |
| @djs-commands/adapter-redis | Redis CacheAdapter for distributed cooldowns |
| create-djs-commands | npx create-djs-commands scaffolding tool |
Migrating from v1?
@d3oxy/[email protected] is preserved at the v1-final-commit git tag and is no longer maintained. Every v1 API has a v2 equivalent — see the v1 → v2 migration guide.
