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
| Method | Returns | Description |
|---|---|---|
.setName(name) | this | Set the command name |
.setDescription(desc) | this | Set the command description |
.setPermissions(perms) | this | Restrict the command to specific permissions |
.setMetaData(meta) | this | Attach custom metadata to the command |
.addStringOption(fn) | this | Add a string option |
.addBooleanOption(fn) | this | Add a boolean option |
.addIntegerOption(fn) | this | Add an integer option |
.addNumberOption(fn) | this | Add a number option |
.addUserOption(fn) | this | Add a user option |
.addRoleOption(fn) | this | Add a role option |
.addSubCommand(fn) | this | Add a subcommand |
.addSubCommandGroup(fn) | this | Add a subcommand group |
.execute(handler) | this | Set 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
| Method | Returns | Description |
|---|---|---|
.setName(name) | this | Set the option name |
.setDescription(desc) | this | Set the option description |
.setRequired(bool) | this | Mark 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
| Method | Returns | Description |
|---|---|---|
.setName(name) | this | Set the subcommand name |
.setDescription(desc) | this | Set the subcommand description |
.addStringOption(fn) | this | Add a string option |
.addBooleanOption(fn) | this | Add a boolean option |
.addIntegerOption(fn) | this | Add an integer option |
.addNumberOption(fn) | this | Add a number option |
.addUserOption(fn) | this | Add a user option |
.addRoleOption(fn) | this | Add a role option |
.execute(handler) | this | Set 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
| Method | Returns | Description |
|---|---|---|
.setName(name) | this | Set the group name |
.setDescription(desc) | this | Set the group description |
.addSubCommand(fn) | this | Add 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,
})
})
)
)

