GlyriaClient
Overview
GlyriaClient extends discord.js's Client and adds glyria.js features on top — automatic command/event loading, hot reload support, graceful shutdown, and a built-in event bus.
const client = new GlyriaClient({
intents: [GatewayIntentBits.Guilds]
})
await client.login()
Constructor
new GlyriaClient(options: GlyriaClientOptions)
GlyriaClientOptions
| Option | Type | Required | Description |
|---|---|---|---|
intents | BitFieldResolvable<GatewayIntentsString, number> | ✅ | Discord gateway intents |
TOKEN variable in your .env. Never pass it manually.Properties
| Property | Type | Description |
|---|---|---|
bus | GlyriaBus<GlyriaEvents> | Internal event bus |
commandsManager | CommandManager | Manages command loading and registration |
eventsManager | EventManager | Manages event loading and registration |
Methods
login()
await client.login()
Starts the bot. Internally:
- Loads and registers all event files from
src/events/ - Connects to Discord
- Loads and registers all command files from
src/commands/ - Listens for hot reload messages in dev mode
Returns a Promise<string> — the token used to log in.
Events
Every discord.js event is bridged onto client.bus, so you can listen to any Events.* value through the bus — going through Glyria's middleware layer instead of the raw discord.js emitter.
client.bus.on(Events.MessageCreate, (message) => {
// runs through user and module middleware
})
client.bus.on(...) goes through middleware; client.on(...) bypasses it. Prefer client.bus unless you specifically need the raw emitter.Bot ready
To run code once the bot is fully logged in and ready, listen to the botReady event on the global bus:
globalBus.on("botReady", (client) => {
console.log(`Ready as ${client.user?.tag}`)
})
| Payload | Type | Description |
|---|---|---|
client | GlyriaClient | The ready client instance |
globalBus is available globally — no import needed. See GlyriaBus › globalBus.Graceful shutdown
GlyriaClient listens for SIGINT and SIGTERM automatically. When either signal is received, it:
- Destroys the discord.js connection
- Sets the bot offline on Discord
- Exits the process cleanly
No extra code needed.
Hot reload
In dev mode (glyria dev), GlyriaClient listens for IPC messages from the CLI watcher:
| Message | Action |
|---|---|
hotreload:commands | Reloads all commands without restarting |
hotreload:events | Reloads all events without restarting |
hotreload:config | Reloads glyria.config.ts without restarting |
This is handled automatically — no configuration needed.
Inheritance
GlyriaClient extends discord.js's Client. All discord.js properties and methods are available:
client.guilds.cache
client.users.fetch(userId)
client.channels.fetch(channelId)
// ...
Refer to the discord.js documentation for the full API.

