Context menus
A context menu command shows in the Apps menu when the user right-clicks a user or a message. It has no options and no description.
import { bot, contextMenu } from 'botflare';
const avatar = contextMenu('user', { name: 'Show avatar' }, (c) => c.reply(`${c.target.username}`, { ephemeral: true }),);
const words = contextMenu('message', { name: 'Count words' }, (c) => c.reply(`${c.target.content.split(/\s+/).filter(Boolean).length} words`, { ephemeral: true }),);
export default bot({ commands: [avatar, words] });- Add context menus to
commands, next to the slash commands, and runnpx botflare syncagain. c.targetis the user or the message that the user clicked.- The handler has
reply,defer,modaland the follow-up calls. - A context menu takes
permissions,contexts,installsandlocaleslike a command.localestakes anameonly.
A context menu and a slash command can have the same name. botflare keeps them apart.