nyx Typedoc
    Preparing search index...

    Documentation

    nyx Logo


    A Discord bot framework that stays out of your way.

    CI Built with Typescript Discord Invite

    nyx handles application commands, components, events, schedules and plugins on top of discord.js or @discordjs/core, through the gateway or over HTTP with @nyx-discord/http. It's built to be the Discord layer of your app, not your whole app.

    • Everything is replaceable. Every part (command manager, resolver, deployer, event dispatcher, error handler...) is an interface with a default implementation. To change how something works, plug in your own, with no forking, or monkey-patching.
    • It doesn't take over your app. nyx doesn't own your process, storage, logging or error reporting. Your services keep the business logic, making your code testable and maintainable.
    • Same API on discord.js and @discordjs/core. Pick the library you want; filters, middlewares, events, schedules and plugins work the same on both.
    • Gateway or HTTP. With @nyx-discord/http you can make a bot receive interactions and webhook events over HTTP, mounted on any server or runtime (node:http, Express, Fastify, Hono, Workers, Bun, Deno, Next.js), with no gateway connection.
    • Commands that handle their own components. Buttons, select menus and modals sent by a command come back to that command, with extra data encoded in the customId for you.
    • Type-safe events and metadata. Event buses are typed by their events, and metadata is read and written through typed fields.
    • No global state. Run several bots in one process, and reuse the same command instances across them.
    • Docs for humans and agents. A guide with typechecked examples, and an agent skill so AI tools write correct nyx code.
    npm i @nyx-discord/djs discord.js
    
    import { AbstractStandaloneCommand, Bot } from '@nyx-discord/djs';
    import { Client, GatewayIntentBits, SlashCommandBuilder, type ChatInputCommandInteraction } from 'discord.js';

    class PingCommand extends AbstractStandaloneCommand {
    protected readonly data = new SlashCommandBuilder().setName('ping').setDescription('Pong!').toJSON();

    public async execute(interaction: ChatInputCommandInteraction) {
    await interaction.reply('Pong!');
    }
    }

    const bot = Bot.create(() => ({
    token: process.env['DISCORD_TOKEN']!,
    client: new Client({ intents: [GatewayIntentBits.Guilds] }),
    logger: console,
    deployCommands: true,
    }));

    await bot.getCommandManager().addCommands(new PingCommand());
    await bot.start();
    • Guide: how to use nyx, and how to replace its internals.
    • API reference: every class, interface and type.
    • Agent skill: npx skills add nyx-discord/nyx installs the nyx skill into Claude Code, Cursor, Codex and others. It covers nyx's conventions and typechecked examples for both adapters.
    • llms.txt: point your agent at llms.txt, an index of every guide page, or at llms-full.txt for all of it in one file.
    • Markdown pages: add .md to any guide URL, e.g. /use/commands.md.