Skip to content

CIRCE / DOCUMENTATION

Command groups

Nested subcommands such as /config roles add with defineCommandGroup and defineSubcommand.

Documentation menu
On this page

Under src/command-groups/, folder depth is the routed path, up to Discord’s two levels (group, subgroup, subcommand). Each folder has a _group.ts; the _ prefix keeps it from registering as a leaf.

command-groups/
└── config/
    ├── _group.ts       # /config
    └── roles/
        ├── _group.ts   # /config roles
        ├── add.ts      # /config roles add
        └── remove.ts   # /config roles remove

defineCommandGroup

defineCommandGroup({ name, description, guards?, metadata? });
// src/command-groups/admin/_group.ts
import { defineCommandGroup, hasPermission } from "@sxnnyside/circe";
import { PermissionFlagsBits } from "discord.js";

export default defineCommandGroup({
  name: "admin",
  description: "Server administration.",
  guards: [hasPermission(PermissionFlagsBits.Administrator)],
});

defineSubcommand

defineSubcommand({ builder: SlashCommandSubcommandBuilder, execute(ctx), guards?, metadata? });
// src/command-groups/admin/kick.ts
import { defineSubcommand, hasPermission } from "@sxnnyside/circe";
import { PermissionFlagsBits, SlashCommandSubcommandBuilder } from "discord.js";

export default defineSubcommand({
  builder: new SlashCommandSubcommandBuilder().setName("kick").setDescription("Kick a member"),
  guards: [hasPermission(PermissionFlagsBits.KickMembers)],
  async execute({ interaction }) { /* … */ },
});

Group guards run before the guards of the subcommands under them. execute receives the same command context.