command()
Popii / command
Function: command()
Section titled “Function: command()”command<
T>(definition):T
Defined in: define/command.ts:47
Defines a slash command, text command, or context menu action.
Drop the file anywhere under src/commands/ and Popii registers it automatically.
Nested folders become subcommand groups: src/commands/config/set.ts → /config set.
Type Parameters
Section titled “Type Parameters”T extends PopiiCommandDefinition<any, any, PopiiLocals & Record<string, any>>
Parameters
Section titled “Parameters”definition
Section titled “definition”T
Returns
Section titled “Returns”T
Examples
Section titled “Examples”import { command } from "popii";
export default command({ name: "ping", description: "Replies with Pong!", async do(pop) { await pop.reply(`Pong! ${pop.client.discord.ws.ping}ms`); }});import { command } from "popii";import { ApplicationCommandOptionType } from "discord.js";
export default command({ name: "greet", description: "Greet a user", cooldown: { ms: 5000, scope: "user" }, options: [{ name: "user", description: "Who to greet", type: ApplicationCommandOptionType.User, required: true, }], async do(pop) { const target = pop.options.getUser("user")!; await pop.reply(`Hello, ${target}!`); }});