Skip to content
Functioncustom-idv0.2.7

prefixOf

Recover the stable prefix from a wire by stripping its layout hash.

Route on this. The prefix survives a shape change. A click on a component built before the change still reaches the same place, where decode refuses it. Returns an empty string for a wire too short to carry a hash.

prefixOf(wire: string): string
const Approve = new CustomId('approve').snowflake('userId');

// 'approve', whatever fields the definition carries today
prefixOf(Approve.encode({ userId: '123' }));

// route a raw interaction on it
const handler = handlers.get(prefixOf(interaction.customId));

wire

wire: string

The customId string from the interaction.