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

GlyriaClient extends discord.js's ClientEvents with one additional event:

glyria:ready

Emitted when the bot is fully ready — after commands and events are loaded.

client.bus.on("glyria:ready", ({ uptime, shardId }) => {
  console.log(`Ready on shard ${shardId}, uptime: ${uptime}ms`)
})
PayloadTypeDescription
uptimenumberTime since login in milliseconds
shardIdnumberCurrent shard ID

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