
@nyx-discord/base is the foundation of nyx. It holds the interfaces every
nyx component follows, plus default implementations of them, without depending on any Discord library.
Building a bot? You don't need to install this package directly. Install the adapter for your library, which re-exports everything from here:
| If your bot... | Install |
|---|---|
| Uses discord.js | @nyx-discord/djs |
| Uses @discordjs/core | @nyx-discord/djs-core |
| Receives interactions over HTTP | @nyx-discord/http |
Every part of nyx (command manager, resolver, deployer, event dispatcher, error handler...) is an interface with a default implementation, so you can replace any of them with your own. You can tell them apart by their names:
| Name | Meaning |
|---|---|
No prefix (CommandManager) |
An interface: what a component does, and what the rest of nyx expects. |
Abstract* (AbstractSchedule) |
Needs to be extended to be used, like your own commands, subscribers and schedules. |
Basic* (BasicEventBus) |
A complete, simple implementation. Use it directly, or extend it. |
Default* (DefaultCommandManager) |
The implementation the bot uses internally. Extend it and inject your version. |
Base* (BaseCommand) |
A library-agnostic foundation that the adapters build on. |
| Import | Contains |
|---|---|
@nyx-discord/base |
Everything. |
@nyx-discord/base/types |
Only the interfaces. |
@nyx-discord/base/defaults |
Only the implementations. |
If you're writing a plugin or library for nyx, depend on @nyx-discord/base instead of an adapter, so it works with all
of them. Importing from @nyx-discord/base/types makes it impossible to accidentally depend on an implementation:
import type { NyxBot, NyxPlugin } from '@nyx-discord/base/types';
export class MyPlugin implements NyxPlugin {
public static readonly Id = Symbol('my-plugin');
public async onRegister(bot: NyxBot) {
// add commands, subscribers and schedules to the bot
}
public async onUnregister(bot: NyxBot) {
// remove them
}
public getData() {
return { name: 'my-plugin', version: '1.0.0', description: 'Does something useful' };
}
public getId() {
return MyPlugin.Id;
}
}
npx skills add nyx-discord/nyx.