Custom ID System
Honocord uses a path-based custom ID system for components and modals:
prefix/component/path?param1/param2/param3The custom ID is split into two parts:
- Path: The part before the
?, split by/. The first item is the prefix used for matching handlers. The rest form the component path. - Parameters: The part after the
?, split by/. These are additional parameters you can use in your handler.
You must mind the limit of 100 characters for custom_ids imposed by Discord.
Example:
import { ComponentHandler, ButtonBuilder, parseCustomId } from "honocord";
new ButtonBuilder().setCustomId("report/user?123456789").setLabel("Report User");
// Handler matches by prefixconst reportHandler = new ComponentHandler("report").addHandler(async (interaction) => { const { component, firstParam, compPath } = parseCustomId(interaction.custom_id); // component = "user" // firstParam = "123456789" // compPath = ["report", "user"]});This enables:
- Prefix matching - One handler for multiple related components
- Parameter passing - Pass data through custom IDs
- Hierarchical organization - Structure your component logic