Skip to Content
nyx logonyx guide

Commands Overview

Reading time:2 min read

Commands are how your bot responds to user interactions.

About prefix/message content commands

Nyx only supports application commands. It doesn't and won't support message content commands (like !ping).

If you really need such functionality, you can implement it yourself using the messageCreate event, but this isn't advised. Application commands improve DX and UX significantly, and don't require a privileged intent to work.

Quick example

Let's create a simple ping command:

import { , type  } from 'discord.js';
import {  } from '@nyx-discord/djs';

class  extends  {
  protected readonly  = new ()
    .('ping')
    .('Replies with Pong!')
    .();

  public async (: ) {
    await .('Pong!');
  }
}

// Register the command
await .().(new ());

That's it! Your bot now has a /ping command that replies with "Pong!" when used.

The framework doesn't store any state in the instance, so you can reuse it across multiple bot instances without any problems.

Command deployment

For commands to be deployed at Discord, you must either pass deployCommands: true when creating the bot, or deploy them manually.

import {  } from '@nyx-discord/djs';

const  = .(() => ({
  // ... other options
  : true,
}));

Then, when starting the bot, it will automatically deploy them.

You can also deploy manually:

This will throw if you passed deployCommands: true or already called it before.
await .().();

Add or deploy first?

If you add a command after commands have already been deployed, the framework will have to make an API call to register it.

This is not recommended due to ratelimits, so it's best to add all the commands before deploying (you can add commands before starting the bot).

Command types

Commands are categorized into several types, depending on their purposes:

Click on each card to learn more about that type.

On this page