API Reference

GlyriaCommand

The slash command builder.

Overview

GlyriaCommand is the builder used to define Discord slash commands. Every file in src/commands/ should export a GlyriaCommand instance as default.

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

GlyriaCommand

Methods

MethodReturnsDescription
.setName(name)thisSet the command name
.setDescription(desc)thisSet the command description
.setPermissions(perms)thisRestrict the command to specific permissions
.setMetaData(meta)thisAttach custom metadata to the command
.addStringOption(fn)thisAdd a string option
.addBooleanOption(fn)thisAdd a boolean option
.addIntegerOption(fn)thisAdd an integer option
.addNumberOption(fn)thisAdd a number option
.addUserOption(fn)thisAdd a user option
.addRoleOption(fn)thisAdd a role option
.addSubCommand(fn)thisAdd a subcommand
.addSubCommandGroup(fn)thisAdd a subcommand group
.execute(handler)thisSet the command handler

.setPermissions()

Restricts the command to members with specific Discord permissions. Accepts a bigint, number, or string.

export default new GlyriaCommand()
  .setName("ban")
  .setDescription("Ban a user")
  .setPermissions(djs.PermissionsBitField.Flags.BanMembers)
  .execute(async (ctx) => {
    // only members with BanMembers permission can use this
  })

.setMetaData()

Attaches custom metadata to the command. Accepts any key-value object — Glyria stores it as-is and never interprets it.

export default new GlyriaCommand()
  .setName("ban")
  .setDescription("Ban a user")
  .setMetaData({
    category: "moderation",
    cooldown: 5000,
    premium: false,
    guildOnly: true,
  })
  .execute(async (ctx) => {
    // your logic here
  })

Metadata is accessible at runtime via useCommands():

const commands = useCommands()
// [
//   { name: "ban", description: "Ban a user", meta: { category: "moderation", cooldown: 5000, ... } },
//   { name: "ping", description: "Pong!", meta: {} },
// ]
useCommands() is available globally — no import needed. The registry is populated automatically when the bot starts.

.execute()

Sets the command handler. Receives a ChatInputCommandInteraction.

export default new GlyriaCommand()
  .setName("ping")
  .setDescription("Pong!")
  .execute(async (ctx) => {
    await ctx.reply({
      content: "Pong!",
      flags: djs.MessageFlags.Ephemeral,
    })
  })

CommandOption

Passed as argument in every add*Option callback.

Methods

MethodReturnsDescription
.setName(name)thisSet the option name
.setDescription(desc)thisSet the option description
.setRequired(bool)thisMark the option as required

Example

.addStringOption((option) =>
  option
    .setName("reason")
    .setDescription("Reason of the ban")
    .setRequired(false)
)

GlyriaSubCommand

Passed as argument in .addSubCommand() callbacks.

Methods

MethodReturnsDescription
.setName(name)thisSet the subcommand name
.setDescription(desc)thisSet the subcommand description
.addStringOption(fn)thisAdd a string option
.addBooleanOption(fn)thisAdd a boolean option
.addIntegerOption(fn)thisAdd an integer option
.addNumberOption(fn)thisAdd a number option
.addUserOption(fn)thisAdd a user option
.addRoleOption(fn)thisAdd a role option
.execute(handler)thisSet the subcommand handler

Example

.addSubCommand((cmd) =>
  cmd
    .setName("ban")
    .setDescription("Ban a user")
    .addUserOption((option) =>
      option.setName("user").setDescription("User to ban").setRequired(true)
    )
    .execute(async (ctx) => {
      await ctx.reply({
        content: "User banned.",
        flags: djs.MessageFlags.Ephemeral,
      })
    })
)

GlyriaSubCommandGroup

Passed as argument in .addSubCommandGroup() callbacks.

Methods

MethodReturnsDescription
.setName(name)thisSet the group name
.setDescription(desc)thisSet the group description
.addSubCommand(fn)thisAdd a subcommand to the group

Example

.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) => {
          await ctx.reply({
            content: "Logs configuration updated.",
            flags: djs.MessageFlags.Ephemeral,
          })
        })
    )
)
Copyright © 2026