Skip to content

command()

Popii


Popii / 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.

T extends PopiiCommandDefinition<any, any, PopiiLocals & Record<string, any>>

T

T

src/commands/ping.ts
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}!`);
}
});