> For the complete documentation index, see [llms.txt](https://cjays-organization.gitbook.io/nexora.ts/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cjays-organization.gitbook.io/nexora.ts/framework/nexora.md).

# Nexora

Main bot class — wires Discord client, command/event discovery, DI container, cache, scheduler, and logging.

**Package:** `@nexora.ts/core`

## Create & start

```ts
import config from '../nexora.config.js';
import { Nexora } from '@nexora.ts/core';
import { createDevServer } from '@nexora.ts/dev-server';

const bot = new Nexora({
  config,
  commandsPath: './commands/**/*.ts',
  eventsPath: './events/**/*.ts',
});

const studio = createDevServer(bot, { port: 3920, studioPort: 3002 });
await studio.start();
await bot.start();

process.on('SIGINT', async () => {
  await studio.stop();
  await bot.stop();
  process.exit(0);
});
```

## Important properties

| Property              | Description                                                  |
| --------------------- | ------------------------------------------------------------ |
| `bot.client`          | discord.js `Client`                                          |
| `bot.logger`          | Nexora `Logger` (pretty console by default)                  |
| `bot.container`       | DI `Container`                                               |
| `bot.commandRegistry` | Registered slash / message commands                          |
| `bot.eventRegistry`   | Registered event handlers                                    |
| `bot.eventBus`        | Framework hooks (`COMMAND_EXECUTED`, …)                      |
| `bot.cache`           | In-memory cache                                              |
| `bot.scheduler`       | Cron / interval / delayed jobs                               |
| `bot.lifecycle`       | `'idle' \| 'starting' \| 'ready' \| 'stopping' \| 'stopped'` |

## Options

```ts
new Nexora({
  config,                    // from defineConfig()
  commandsPath: './commands/**/*.ts',
  eventsPath: './events/**/*.ts',
  clientOptions: {
    // optional discord.js ClientOptions overrides
  },
  // Optional error boundary
  onError: ({ error, source, command }) => {
    console.error(`[${source}]`, command, error);
  },
  errorMessage: 'Etwas ist schiefgelaufen. Bitte später erneut versuchen.',
});
```

Or chain after construction:

```ts
bot
  .onError(async (ctx) => { /* Sentry / webhook */ })
  .setErrorMessage('Something went wrong.');
```

On ready, Nexora prints a **startup banner** (commands/events count, Studio URL when live).

## Related

* [Configuration](/nexora.ts/getting-started/configuration.md)
* [SlashCommand](/nexora.ts/framework/slash-command.md)
* [Logger](/nexora.ts/framework/logger.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://cjays-organization.gitbook.io/nexora.ts/framework/nexora.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
