discord.js++

spearkit

A developer-experience-first Discord library. Everything discord.js gives you, plus ergonomic, fully type-safe events, slash commands and interactive components.

npm install spearkit discord.js

Drop-in for discord.js

Every discord.js export is re-exported from spearkit. Change one import and your bot keeps working — then adopt the niceties at your own pace.

Fully type-safe

No any, no unknown. Option values, custom-id params and modal fields are all inferred from your definitions.

Co-located handlers

A command's options and handler, a button's look and click logic, a modal's fields and submit — each lives in one place.

Zero boilerplate routing

No interactionCreate switch. spearkit routes commands, autocomplete, buttons, selects and modals for you.

A bot, in a few lines

import { SpearClient, Intents, command, option, button } from "spearkit";

const client = new SpearClient({ intents: Intents.default });

const greet = command({
  name: "greet",
  description: "Greet someone",
  options: { who: option.user({ description: "Who", required: true }) },
  run: (ctx) => ctx.reply(`Hello ${ctx.options.who}!`), // who: User
});

const ping = button({
  id: "ping:{n}",
  label: "Ping",
  run: (ctx) => ctx.update(`pong #${ctx.params.n}`), // n: string
});

client.register(greet, ping);
await client.start(process.env.DISCORD_TOKEN);
await client.deployCommands({ guildId: process.env.GUILD_ID });

Read the getting started guide or browse the guides.