API Reference
GlyriaMessageCommand
The message context menu command builder.
Overview
GlyriaMessageCommand is the builder used to define Discord message context menu commands. They appear when right-clicking on a message, under the Apps section.
export default new GlyriaMessageCommand()
.setName("Translate")
.execute(async (ctx) => {
const message = ctx.targetMessage
await ctx.reply({
content: `Translating: "${message.content}"`,
flags: djs.MessageFlags.Ephemeral,
})
})
GlyriaMessageCommand is available globally — no import needed.GlyriaMessageCommand
Methods
| Method | Returns | Description |
|---|---|---|
.setName(name) | this | Set the command name |
.setPermissions(perms) | this | Restrict the command to specific permissions |
.setMetaData(meta) | this | Attach custom metadata to the command |
.execute(handler) | this | Set the command handler |
Message context menu commands do not support descriptions, options, or subcommands — these are Discord API limitations.
.setPermissions()
Restricts the command to members with specific Discord permissions. Accepts a bigint, number, or string.
export default new GlyriaMessageCommand()
.setName("Delete message")
.setPermissions(djs.PermissionsBitField.Flags.ManageMessages)
.execute(async (ctx) => {
// only members with ManageMessages 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 GlyriaMessageCommand()
.setName("Translate")
.setMetaData({
category: "utility",
cooldown: 5000,
})
.execute(async (ctx) => {
// your logic here
})
Metadata is accessible at runtime via useCommands():
const commands = useCommands()
// [
// { name: "Translate", description: "", meta: { category: "utility", cooldown: 5000 } },
// ]
useCommands() is available globally — no import needed. The registry is populated automatically when the bot starts..execute()
Sets the command handler. Receives a MessageContextMenuCommandInteraction — the targeted message is available via ctx.targetMessage.
export default new GlyriaMessageCommand()
.setName("Translate")
.execute(async (ctx) => {
const message = ctx.targetMessage
await ctx.reply({
content: `Translating: "${message.content}"`,
flags: djs.MessageFlags.Ephemeral,
})
})

