API Reference

GlyriaClient

The main Discord bot client.

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

OptionTypeRequiredDescription
intentsBitFieldResolvable<GatewayIntentsString, number>Discord gateway intents
The bot token is loaded automatically from the TOKEN variable in your .env. Never pass it manually.

Properties

PropertyTypeDescription
busGlyriaBus<GlyriaEvents>Internal event bus
commandsManagerCommandManagerManages command loading and registration
eventsManagerEventManagerManages event loading and registration

Methods

login()

await client.login()

Starts the bot. Internally:

  1. Loads and registers all event files from src/events/
  2. Connects to Discord
  3. Loads and registers all command files from src/commands/
  4. 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}`)
})
PayloadTypeDescription
clientGlyriaClientThe 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:

  1. Destroys the discord.js connection
  2. Sets the bot offline on Discord
  3. Exits the process cleanly

No extra code needed.

Hot reload

In dev mode (glyria dev), GlyriaClient listens for IPC messages from the CLI watcher:

MessageAction
hotreload:commandsReloads all commands without restarting
hotreload:eventsReloads all events without restarting
hotreload:configReloads 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.

Copyright © 2026