Start
Getting started with nyx
First Start
A minimum version of Node.js 18 is required to run, though we recommend latest LTS. Although they should work, nyx is not tested on other runtimes, such as Deno or Bun.
We also recommend using a formatter like Prettier and a linter like ESLint or TypeScript ESLint.
Installing
npm i @nyx-discord/djs discord.jsCreating a Client
You'll need a client, which will depend on the adapter you're using. It can be any client, as long as it's not logged in or destroyed.
import { , } from 'discord.js';
const = new ({ : [.] });Creating a Bot
Next up, we'll create a new instance of Bot. This is the main entry point of the framework, and it will handle the lifecycle
of your bot, including loading commands, managing events, and more.
Create one with Bot.create(), which takes a function that gets passed the currently constructing bot
instance, and should return the options that you want for the bot.
import { , type } from '@nyx-discord/djs';
const = .((: ) => ({
: 'TOKEN',
,
: , // Can be your own logger, see the NyxLogger docs
: true, // Whether to deploy commands to Discord on start
}));Starting the Bot
Finally, to start it, simply call .start(). This will log in the client, set up event listeners, and get everything ready:
await .();If the start errors, it'll reject the promise, and the bot will enter in a BotStatusEnum.Killed state, meaning it won't
be able to be used anymore. You can create a new bot instance and start it again, but you cannot recover the previous one.
To get a bot's status at any time, you can use Bot#getStatus().
Next Steps
Last updated on
