一键导入
new-component
Scaffold a persistent button, modal, or select-menu handler in app/components. Use when asked to handle a component interaction by customId.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Scaffold a persistent button, modal, or select-menu handler in app/components. Use when asked to handle a component interaction by customId.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Scaffold a new slash command in app/commands. Use when asked to add or create a slash command, a subcommand, or an autocomplete option.
Scaffold a right-click context-menu command (on a user or message) in app/context. Use when asked to add a context-menu or right-click command.
Scaffold a gateway event handler in app/events. Use when asked to react to a Discord event like GuildMemberAdd, MessageCreate, or Ready.
Scaffold a new text (prefix) command in app/prefixes, e.g. ".ping". Use when asked to add a message-based or prefix command.
Scaffold an HTTP API route in app/routes on the Elysia server. Use when asked to add an HTTP endpoint, REST route, or webhook receiver.
Scaffold a scheduled task (cron or interval) in app/tasks. Use when asked to run something periodically, on a timer, or on a schedule.
| name | new-component |
| description | Scaffold a persistent button, modal, or select-menu handler in app/components. Use when asked to handle a component interaction by customId. |
.agents/context.md (Components section) if not already loaded.app/components/<name>.ts.@Register(id). The decorator is @Register (not @Component) because Component is the base-class name.import { MessageFlags } from "discord.js";
import type { ButtonInteraction } from "discord.js";
import { Register, ButtonComponent } from "engine";
@Register("vote")
export default class Vote extends ButtonComponent {
async execute(interaction: ButtonInteraction) {
const [, direction, owner_id] = interaction.customId.split(":");
if (interaction.user.id !== owner_id) {
await interaction.reply({ content: "This button is not for you.", flags: MessageFlags.Ephemeral });
return;
}
await interaction.reply(`You voted ${direction}.`);
}
}
ButtonComponent, ModalComponent, SelectComponent (any select), or the typed StringSelectComponent / UserSelectComponent / RoleSelectComponent / ChannelSelectComponent / MentionableSelectComponent. The base fixes the execute interaction type.
Dispatch routes on the segment before the first :, so a button with customId "vote:up:<userId>" still reaches the vote handler. A persistent component has no built-in invoker lock: encode the allowed user id in the customId and reject other clickers, as above. Do not use @Register for short-lived flows that helpers/pagination, helpers/panel, helpers/dialog, or helpers/form already cover; those enforce their own per-user lock via collectors.
@Register accepts cooldown, cooldown_scope, and guards exactly like commands; denials reply ephemerally before execute.InteractionCreate router; engine/dispatch.ts routes by customId.Run bun run typecheck and bun run lint. Handlers are live on next boot; no deploy step.