Guide

Commands

Create and organize slash commands with GlyriaCommand.

Overview

Commands in glyria.js are file-based. Every file in src/commands/ is automatically loaded and registered on Discord at startup — no manual registration needed.

Each command file exports a GlyriaCommand instance as default:

// src/commands/ping.ts
export default new GlyriaCommand()
  .setName("ping")
  .setDescription("Pong!")
  .execute(async (ctx) => {
    await ctx.reply({ content: "Pong!" })
  })
GlyriaCommand is available globally — no import needed.

Options

Add typed options to your command with the add*Option methods:

export default new GlyriaCommand()
  .setName("hello")
  .setDescription("Say hello to someone")
  .addUserOption((option) =>
    option
      .setName("user")
      .setDescription("The user to greet")
      .setRequired(true)
  )
  .addStringOption((option) =>
    option
      .setName("message")
      .setDescription("A custom message")
      .setRequired(false)
  )
  .execute(async (ctx) => {
    await ctx.reply({ content: "Hello!" })
  })

Available option types

MethodType
addStringOptionText input
addIntegerOptionInteger number
addNumberOptionDecimal number
addBooleanOptionTrue / False
addUserOptionDiscord user
addRoleOptionDiscord role

Each option exposes:

MethodDescription
.setName(name)Option name (lowercase, no spaces)
.setDescription(desc)Option description
.setRequired(bool)Whether the option is required

Subcommands

Group related actions under a single command with .addSubCommand():

export default new GlyriaCommand()
  .setName("moderation")
  .setDescription("Moderation commands")
  .addSubCommand((cmd) =>
    cmd
      .setName("ban")
      .setDescription("Ban a user")
      .addUserOption((option) =>
        option
          .setName("user")
          .setDescription("User to ban")
          .setRequired(true)
      )
      .addStringOption((option) =>
        option
          .setName("reason")
          .setDescription("Reason of the ban")
          .setRequired(false)
      )
      .execute(async (ctx) => {
        // handle ban
      })
  )
  .execute(async (ctx) => {
    // handle base command
  })

Subcommand groups

For deeper organization, group subcommands with .addSubCommandGroup():

export default new GlyriaCommand()
  .setName("moderation")
  .setDescription("Moderation commands")
  .addSubCommand((cmd) =>
    cmd
      .setName("ban")
      .setDescription("Ban a user")
      .addUserOption((option) =>
        option
          .setName("user")
          .setDescription("User to ban")
          .setRequired(true)
      )
      .addStringOption((option) =>
        option
          .setName("reason")
          .setDescription("Reason of the ban")
          .setRequired(false)
      )
      .execute((ctx) => {
        console.log("ban command")
      })
  )
  .addSubCommandGroup((group) =>
    group
      .setName("config")
      .setDescription("Configuration commands")
      .addSubCommand((cmd) =>
        cmd
          .setName("logs")
          .setDescription("Configure logs")
          .addBooleanOption((option) =>
            option
              .setName("enabled")
              .setDescription("Enable logs")
              .setRequired(true)
          )
          .execute(async (ctx) => {
            const embed = new EmbedV2Builder()
              .container({ accentColor: 0x5865F2 })
                .textDisplay("Logs configuration updated!")
                .separator({ spacing: "large" })
                .section()
                  .textDisplay("Disable logs")
                  .buttonAccessory({ label: "Disable", style: "link", url: "https://discord.com" })
                .end()
                .actionRow()
                  .button({ label: "Enable", style: "link", url: "https://discord.com" })
                .end()
              .end()
              .build()

            await ctx.reply({ ...embed })
          })
      )
  )
  .execute((ctx) => {
    ctx.reply({ content: "Moderation command executed!" })
  })

This generates the following Discord command structure:

/moderation ban <user> [reason]
/moderation config logs <enabled>

Organizing files

Subfolders inside src/commands/ are for organization only — every file at any depth is loaded automatically.

src/commands/
  ping.ts
  moderation/
    ban.ts
    kick.ts
  config/
    advanced/
      logs.ts
Keep one GlyriaCommand per file. Use subcommands and subcommand groups to group related actions.
Copyright © 2026