Getting Started

Auto-imports

Use glyria.js utilities anywhere without writing a single import statement.

What are auto-imports?

In a standard TypeScript project, you need to manually import every function or class you use:

import { GlyriaCommand } from "@glyria/bot"
import { EmbedV2Builder } from "@glyria/bot"
import { GlyriaClient } from "@glyria/bot"

glyria.js eliminates this entirely. Every framework utility is automatically available as a global — no imports needed anywhere in your project.

// no imports — it just works
export default new GlyriaCommand()
  .setName("ping")
  .setDescription("Pong!")
  .execute(async (ctx) => {
    await ctx.reply({ content: "Pong!" })
  })

How it works

glyria.js uses two mechanisms working together:

Runtime injection — when your bot starts, glyria.js injects all utilities into globalThis. Every file executed after that has access to them without importing.

Type declarations — glyria.js generates a .glyria/imports.d.ts file that tells TypeScript about the globals. This gives you full autocompletion and type checking in your IDE.

Available globals

Framework

GlobalDescription
GlyriaClientThe Discord bot client
GlyriaCommandSlash command builder
GlyriaUserCommandUser context-menu command builder
GlyriaMessageCommandMessage context-menu command builder
GlyriaEventEvent listener builder
EmbedV2BuilderEmbed V2 builder
GlyriaBusEvent bus
globalBusShared framework event bus singleton
createReplyableContextReplyable context helper
useCommandsCommand registry accessor
defineGlyriaConfigConfig helper
loggerStyled terminal logger
hexToNumberHex color to number utility
Eventsdiscord.js Events enum

discord.js

The entire discord.js library is available under the djs namespace — no imports needed:

djs.PermissionsBitField.Flags.BanMembers
djs.GatewayIntentBits.Guilds
djs.ButtonStyle.Primary
// ... everything discord.js exports

User globals

Any function exported from src/utils/, src/composables/, or src/index.ts is also auto-imported globally.

// src/utils/useDatabase.ts
export const useDatabase = () => {
  return {
    find: (id: string) => { /* ... */ },
    save: (data: any) => { /* ... */ },
  }
}
// src/commands/ping.ts — no import needed
export default new GlyriaCommand()
  .setName("ping")
  .execute(async (ctx) => {
    const db = useDatabase()
    const user = await db.find(ctx.user.id)
  })

Custom folders

By default, src/utils/ and src/composables/ are scanned. You can add your own folders in glyria.config.ts:

export default defineGlyriaConfig({
  dev: {
    autoImportDirs: ['utils', 'composables', 'helpers', 'lib']
  }
})

Module globals

Modules declared in glyria.config.ts also expose their exports as globals, under a PascalCase namespace derived from the package name.

// glyria.config.ts
export default defineGlyriaConfig({
  modules: ["@glyria/timers"]
})
// src/commands/remind.ts — no import needed
Timers.createJob(() => {
  console.log("runs every minute")
}, "* * * * *")
PackageNamespace
@glyria/timersTimers.*
@glyria/economyEconomy.*
@glyria/moderationModeration.*
The namespace is always the package name without the scope, in PascalCase. @glyria/timersTimers, @glyria/some-featureSomeFeature.

Regenerating auto-imports

Auto-imports are regenerated automatically in dev mode. If you add a new utility in production, run:

npx glyria generate
For autocompletion to work, make sure your tsconfig.json includes the .glyria/ folder:
{
  "include": ["src/**/*", ".glyria/**/*"]
}
The .glyria/imports.d.ts file is auto-generated and will be overwritten on every glyria generate or glyria dev. Never edit it manually.
Copyright © 2026