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 |
.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 |
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) => {
// handle ban
})
)
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) => {
// handle logs config
})
)
)

