Skip to content
GitHub

Route

interface in meocord/common Since 4.1.0

interface Route<T extends string = string>

A component's customId pattern with a typed build, as route makes it.

Pass it to @Command in place of the pattern's text, and build the customIds that reach its handler.

Members

pattern

readonly pattern: T

The pattern, as written.

build

build(
  ...values: [RouteParams<T>] extends [never] ? [] : [values: RouteValues<T>]
): string

A customId this route matches, with each param's value in its segment. / and % in a value are encoded, and the handler receives the value as it was given.

Parameters

NameTypeDescription
...values[RouteParams<T>] extends [never] ? [] : [values: RouteValues<T>]

Returns

string

Throws

  • TypeError for a missing, empty or unknown value or one not of its param's type, and RangeError for an id over 100 characters.

toString

toString(): T

The pattern, so a route reads as its pattern in a template string.

Returns

T

See also