Packages
Explore the packages that make up nyx
Which package do I need?
You only need to install one: the adapter that matches how your bot connects to Discord.
| If your bot... | Install |
|---|---|
| Uses discord.js | @nyx-discord/djs |
| Uses @discordjs/core | @nyx-discord/djs-core |
| Only handles HTTP payloads instead of the gateway (e.g. on a serverless platform) | @nyx-discord/http |
Under the hood, every adapter is built over @nyx-discord/base, which has the interfaces every component follows,
plus some default implementations of them. The adapters add the missing parts that connect to your Discord library.
Every component depends on interfaces rather than on the default implementations, so you can replace any of them with your own. You can later check the Extend section for how.
Interfaces and implementations
@nyx-discord/base contains two kinds of objects, which you can tell apart by their names.
Interfaces have no prefix, like SubCommand or CommandManager. They describe what a component does, and are what the rest of the framework expects.
Implementations have a prefix that tells you how to use them:
| Prefix | Meaning | Example |
|---|---|---|
Abstract | Needs to be extended to be used. You'll extend these to create your own commands, subscribers, schedules, etc. | AbstractSchedule |
Basic | A complete, simple implementation. Use it directly, or extend it to customize it. | BasicEventBus |
Default | The implementation the bot uses internally. To customize it, extend it and inject your version. | DefaultCommandManager |
Base | A Discord-library-agnostic foundation that the adapters build on. You won't use these directly. | BaseCommand |
For example, your adapter's AbstractStandaloneCommand builds on BaseStandaloneCommand, adding the types of your Discord library. Extend the adapter's version, not the Base one.
When you want to specify a type, prefer the interfaces, e.g. consume(cmd: SubCommand) instead
of consume(cmd: AbstractSubCommand). That way your code works with any implementation, following
Dependency inversion.
Building something for nyx
If you're developing something for nyx itself, such as a plugin, you can depend on @nyx-discord/base instead of an
adapter, so your component works across all of them.
@nyx-discord/base also lets you import each kind of object separately:
| Import | Contains |
|---|---|
@nyx-discord/base | Everything. |
@nyx-discord/base/types | Only the interfaces. |
@nyx-discord/base/defaults | Only the implementations. |
Importing your types from @nyx-discord/base/types makes it impossible to accidentally depend on an implementation.
