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 { command } from "@glyria/bot"
import { embedV2 } 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 command()
  .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
commandSlash command builder
embedV2Embed V2 builder
defineConfigConfig helper

discord.js

GlobalDescription
GatewayIntentBitsDiscord gateway intents

User globals

Any function exported from src/utils/ or src/composables/ is also auto-imported.

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

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