Skip to content
Spraxium

Primary navigation

A framework forDiscord bots

Build a TypeScript bot on discord.js. As the project grows, Spraxium gives each feature a module and lets commands share the services and permissions they need.

Code editor preview showing a Spraxium bot project
src/main.ts
1import { IntentPreset, SpraxiumFactory } from '@spraxium/core';
2import { EnvValidator } from '@spraxium/env';
3import { Logger } from '@spraxium/logger';
4import { AppEnv } from './app.env';
5import { AppModule } from './app.module';
6
7async function main() {
8 const logger = new Logger('Main');
9 const environment = EnvValidator.validate(AppEnv);
10
11 const app = await SpraxiumFactory.create({ token: environment.token });
12 app.useModule(AppModule);
13 app.provide(AppEnv, environment);
14 app.intents(IntentPreset.Standard);
15
16 logger.info('Starting application...');
17 await app.listen();
18}
19
20main();
  • Keep a feature’s commands, listeners and services together. The moderation module gives you a place to start when a rule changes.

  • When two modules need the same server preferences, one can export the provider and the other can import it.

  • Set up connections and other resources when the bot starts. Use the shutdown hook to release them again.

  • A command and a context menu can share a guard when they check the same permission.

  • Your editor can show a command’s options and the services a handler takes, even as the types change.

  • Give the handler a test service so you can see what a command does with data you control.

Interactions

Slash commands

The command class describes its name and options. Its handler uses the module’s services to respond, giving the behavior of the command a place of its own.

  • Declare options with @SlashOption.
  • Inject the services your handler needs.
  • Attach reusable checks with @UseGuards().
  • Register commands when the bot starts.
src/modules/slash/commands/ban.command.ts
1import { SlashCommand, SlashOption } from '@spraxium/common';
2import { PermissionFlagsBits } from 'discord.js';
3
4@SlashCommand({
5 name: 'ban',
6 description: 'Ban a member from the server.',
7 defaultMemberPermissions: PermissionFlagsBits.BanMembers,
8})
9export class BanCommand {
10 @SlashOption.User('target', {
11 description: 'The member to ban',
12 required: true,
13 })
14 @SlashOption.String('reason', {
15 description: 'Reason for the ban',
16 required: false,
17 })
18 build() {}
19}

Examples

What you can build

A moderation bot and a notification bot need different things. These examples show where the packages fit.

Moderation bots

Keep the moderation commands in one module and share a guard for the permission checks they have in common.

Connect a dashboard

A dashboard can call the bot over RPC to look up permissions or run a moderation action. The handler can use the same service as the Discord commands.

Events between services

A Node.js service can report that a task is finished. @spraxium/signal checks the signature before the event reaches the bot.

Recurring tasks

Use @spraxium/schedule for a weekly digest or to clear old records. The job starts once the bot is ready.

Multilingual communities

Keep translations in @spraxium/i18n. Servers choose a language, and the handler keeps using the same keys.

Startup and diagnostics

Check required values at startup with @spraxium/env, then use @spraxium/logger to trace problems that show up after deployment.

Discord UI

Buttons, menus and embeds

Define a button, menu or embed in TypeScript, then reuse the class in different replies. The examples show what to set on each component.

Read the component docs
src/modules/moderation/schemas/buttons.ts
1import { Button, LinkButton } from '@spraxium/components';
2
3@Button({
4 customId: 'mod:ban-confirm',
5 label: 'Confirm Ban',
6 style: 'danger',
7 emoji: '🔨',
8})
9export class BanConfirmButton {}
10
11@Button({
12 customId: 'mod:ban-cancel',
13 label: 'Cancel',
14 style: 'secondary',
15})
16export class BanCancelButton {}
17
18@LinkButton({
19 label: 'View User',
20 url: 'https://discord.com/users/...',
21 emoji: '🔗',
22})
23export class ViewUserButton {}

Forms

Discord modals

Define the fields and their rules on the modal class. Spraxium checks the submitted values before passing them to the handler.

Read the modal docs
1import {
2 ModalCache,
3 ModalComponent,
4 ModalInput,
5 ModalValidate,
6 minWords,
7 minLength,
8} from '@spraxium/components';
9
10@ModalCache({ ttl: 300 })
11@ModalComponent({ id: 'report', title: 'Report an issue' })
12export class ReportModal {
13 @ModalValidate([minWords(5)])
14 @ModalInput({
15 label: 'What happened?',
16 style: 'paragraph',
17 required: true,
18 maxLength: 1000,
19 })
20 description!: string;
21
22 @ModalValidate([minLength(3)])
23 @ModalInput({
24 label: 'Evidence link',
25 placeholder: 'https://…',
26 })
27 evidence!: string;
28}

Database setup

Set up your database from the CLI

The CLI prepares the database module and connection for Prisma, TypeORM, Mongoose and Drizzle. Pick one to see the command and generated files.

Spraxium

SKILLS FOR AGENTS

Point your agent to the right example

Give the agent the instructions for the task at hand, such as registering a slash command or wiring an RPC client into NestJS. Each skill links to the docs and the source that shows where the code belongs.

Browse skills
Agent chat

This example shows an agent receiving a task, selecting a Spraxium skill and adding the corresponding Markdown file to the project.

Add a slash command that shows a server’s rules.

Added spraxium-slash-commands.md.

Call my Discord bot from a NestJS service using RPC.

Added spraxium-rpc.md.

Set up a new TypeScript bot using the Spraxium template.

Added spraxium.md.

Project files
spraxium-slash-commands.md
spraxium-rpc.md
spraxium.md
main.ts
package.json

npm

Spraxium packages

Core and common run your bot and organize its commands. Once you need translations, scheduled jobs or configuration, add the package to the modules you already use.

Example comparison

What changes as a bot grows

The first command takes a little setup. Shared services, ticket workflows, and moderation rules add work as the bot grows. The chart follows that setup through deployment.

  • Spraxium
  • Sapphire
  • discord.js

Estimated setup effort (0–100)

Setup estimates for a ticket and moderation bot with five commands, shared services, and permission checks. The ticket and moderation points are interpolated between Services and Deployment.

Discord ecosystem

Compare Discord frameworks

All five handle Discord commands and buttons. They differ in how you organize handlers, apply permissions, and connect the bot to a backend.

Scroll sideways to see the other frameworks.

Documented by the projectUnlisted in official docs

From beta testers

What developers say about Spraxium

  • “I've tried discord.js, Necord, even raw REST calls. Nothing comes close. Spraxium is the first framework that actually feels like it was designed for large bots. Necord couples too hard with discord.js internals and bleeds that complexity everywhere. With Spraxium, each feature finally has a real home.”

    Smoker

    Bot developer · beta tester

  • “The DI container alone is worth the switch. I used to wire services manually through a global object and pray nothing broke on reload. Now I declare providers once and the framework handles the rest. My bot's startup time actually got faster once I stopped doing it wrong.”

    reizoX

    Full-stack developer · beta tester

  • “Guards changed everything for me. I had permission checks copy-pasted across 40 handlers. Now I have three guard classes and they just work: on slash commands, context menus, everything. Even though this is an early version, the architecture is already more solid than anything else available for discord.js today.”

    imnotgabriel

    Community bot maintainer · beta tester

  • “The module system is what sets it apart. I can drop the moderation module into a new bot with zero changes. It brings its own providers, handlers, and guards. The consuming app barely needs to know it exists. I've never been able to do that with any other discord.js abstraction.”

    vortexen

    Bot developer · beta tester

From Spacelaxy

Why we built Spraxium

With each new bot at Spacelaxy, we had to decide where to read configuration, when to load services and how to find the code that answered an event.

We took what worked in the bots we already ran. Modules declared their services, and handlers had those services ready by the time an interaction came in.

That became Spraxium. The getting started guide takes you through the same setup, from creating a project to running your first command in Discord.

Henry Thierry
Henry Thierry
Spraxium creator · Spacelaxy

Development

Project progress

See what has shipped and what the team is working on for upcoming versions.

View the roadmap

Completed

38
  • Skills for coding agents in beta
  • Versioned docs and expanded RPC tutorials
  • Framework 0.10.0 release review
  • HTTP migration guides and deprecation
  • RPC protocol, client, and adapter for 0.10.0
  • Mobile menu, keyboard navigation, and cached GitHub stars
  • Homepage with a framework comparison, chart, packages, and FAQ
  • Docs navigation, search, articles, and release notes
  • Documentation in three languages
  • 0.9.1: update notices for stable and preview builds

In progress

3
  • Spraxium 1.0 preview
  • Testing utilities and Vitest helpers
  • Example bot projects

Planned

6
  • @spraxium/dashboard web interface
  • Plugin registry
  • Voice state decorators
  • New CLI project templates
  • Rate limit decorators
  • @spraxium/cache for distributed caching

Documentation

The getting started guide goes from a TypeScript project to your first slash command. When the bot is running, you can add another command to the same module.

Getting started

Frequently asked questions

Spraxium is an open-source TypeScript framework for Discord bots. It lets you keep the commands, listeners, and services for a feature in the same module as your bot grows.