discord-embed-router 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -6,18 +6,14 @@ type State<L, P extends ParamData = ParamData> = MatchResult<P> & {
6
6
  locals?: L | undefined;
7
7
  query: URLSearchParams;
8
8
  };
9
- type RouteResponse = InteractionEditReplyOptions;
10
- type RouteHandler<L, P extends ParamData = ParamData> = (interaction: Interaction, state: State<L, P>) => Promise<RouteResponse> | RouteResponse;
9
+ type RouteResponse = InteractionEditReplyOptions | undefined;
10
+ type RouteHandler<M extends Method, L, P extends ParamData = ParamData> = (interaction: Interaction, state: State<L, P>) => M extends "GET" ? Promise<RouteResponse> | RouteResponse : Promise<RouteResponse | undefined> | RouteResponse | undefined;
11
11
  type Method = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
12
- type CompiledRoute<L, P extends ParamData = ParamData> = {
12
+ type CompiledRoute<M extends Method, L, P extends ParamData = ParamData> = {
13
13
  method: Method;
14
14
  path: Path[];
15
15
  matchFunction: MatchFunction<P>;
16
- handler: RouteHandler<L, P>;
17
- };
18
- type ResolvedRoute<L, P extends ParamData = ParamData> = {
19
- state: State<L, P>;
20
- handler: RouteHandler<L, P>;
16
+ handler: RouteHandler<M, L, P>;
21
17
  };
22
18
 
23
19
  type TakeIdentifier<T extends string, Name extends string = ""> = T extends `${infer Char}${infer Rest}` ? Char extends "/" | ":" | "*" | "{" | "}" ? [Name, T] : TakeIdentifier<Rest, `${Name}${Char}`> : [Name, T];
@@ -50,35 +46,35 @@ declare class EmbedRouter<L> {
50
46
  * @param routePath path to match with
51
47
  * @param handler function that generates the message when a path is matched
52
48
  */
53
- get<P extends Path = Path>(routePath: P | P[], handler: RouteHandler<L, ExtractParams<P>>): void;
49
+ get<P extends Path = Path>(routePath: P | P[], handler: RouteHandler<"GET", L, ExtractParams<P>>): void;
54
50
  /**
55
51
  * Registers a path with the router
56
52
  *
57
53
  * @param routePath path to match with
58
54
  * @param handler function that generates the message when a path is matched
59
55
  */
60
- post<P extends Path = Path>(routePath: P | P[], handler: RouteHandler<L, ExtractParams<P>>): void;
56
+ post<P extends Path = Path>(routePath: P | P[], handler: RouteHandler<"POST", L, ExtractParams<P>>): void;
61
57
  /**
62
58
  * Registers a path with the router
63
59
  *
64
60
  * @param routePath path to match with
65
61
  * @param handler function that generates the message when a path is matched
66
62
  */
67
- put<P extends Path = Path>(routePath: P | P[], handler: RouteHandler<L, ExtractParams<P>>): void;
63
+ put<P extends Path = Path>(routePath: P | P[], handler: RouteHandler<"PUT", L, ExtractParams<P>>): void;
68
64
  /**
69
65
  * Registers a path with the router
70
66
  *
71
67
  * @param routePath path to match with
72
68
  * @param handler function that generates the message when a path is matched
73
69
  */
74
- patch<P extends Path = Path>(routePath: P | P[], handler: RouteHandler<L, ExtractParams<P>>): void;
70
+ patch<P extends Path = Path>(routePath: P | P[], handler: RouteHandler<"PATCH", L, ExtractParams<P>>): void;
75
71
  /**
76
72
  * Registers a path with the router
77
73
  *
78
74
  * @param routePath path to match with
79
75
  * @param handler function that generates the message when a path is matched
80
76
  */
81
- delete<P extends Path = Path>(routePath: P | P[], handler: RouteHandler<L, ExtractParams<P>>): void;
77
+ delete<P extends Path = Path>(routePath: P | P[], handler: RouteHandler<"DELETE", L, ExtractParams<P>>): void;
82
78
  /**
83
79
  * Adds a subrouter to the router
84
80
  *
@@ -93,12 +89,13 @@ declare class EmbedRouter<L> {
93
89
  */
94
90
  listener(interaction: ButtonInteraction | AnySelectMenuInteraction, locals?: L | undefined): Promise<void>;
95
91
  /**
96
- * Connect or update an interaction message to a path
92
+ * Replies to or editReplies to an interaction based on the route output
97
93
  *
98
94
  * @param interaction interaction to connect to
99
95
  * @param path path to route the interaction to
100
96
  * @param method method to send to route
101
- * @param flags optional discord flags to send with message (only allowed on first reply)
97
+ * @param flags discord flags to send with message (optional, only allowed on first reply)
98
+ * @param locals additional info to pass in to page through state.local (optional)
102
99
  */
103
100
  dispatch<P extends Path = Path>({ interaction, method, path, flags, locals, }: {
104
101
  interaction: Interaction;
@@ -329,4 +326,4 @@ declare class RouteUserSelectMenuBuilder<L> extends UserSelectMenuBuilder {
329
326
  setPattern<P extends Path>(path: P): this;
330
327
  }
331
328
 
332
- export { type CompiledRoute, EmbedRouter, type Method, type ResolvedRoute, RouteButtonBuilder, RouteChannelSelectMenuBuilder, type RouteHandler, type RouteResponse, RouteRoleSelectMenuBuilder, RouteStringSelectMenuBuilder, RouteStringSelectMenuOptionBuilder, RouteUserSelectMenuBuilder, type State };
329
+ export { type CompiledRoute, EmbedRouter, type Method, RouteButtonBuilder, RouteChannelSelectMenuBuilder, type RouteHandler, type RouteResponse, RouteRoleSelectMenuBuilder, RouteStringSelectMenuBuilder, RouteStringSelectMenuOptionBuilder, RouteUserSelectMenuBuilder, type State };
package/dist/index.d.ts CHANGED
@@ -6,18 +6,14 @@ type State<L, P extends ParamData = ParamData> = MatchResult<P> & {
6
6
  locals?: L | undefined;
7
7
  query: URLSearchParams;
8
8
  };
9
- type RouteResponse = InteractionEditReplyOptions;
10
- type RouteHandler<L, P extends ParamData = ParamData> = (interaction: Interaction, state: State<L, P>) => Promise<RouteResponse> | RouteResponse;
9
+ type RouteResponse = InteractionEditReplyOptions | undefined;
10
+ type RouteHandler<M extends Method, L, P extends ParamData = ParamData> = (interaction: Interaction, state: State<L, P>) => M extends "GET" ? Promise<RouteResponse> | RouteResponse : Promise<RouteResponse | undefined> | RouteResponse | undefined;
11
11
  type Method = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
12
- type CompiledRoute<L, P extends ParamData = ParamData> = {
12
+ type CompiledRoute<M extends Method, L, P extends ParamData = ParamData> = {
13
13
  method: Method;
14
14
  path: Path[];
15
15
  matchFunction: MatchFunction<P>;
16
- handler: RouteHandler<L, P>;
17
- };
18
- type ResolvedRoute<L, P extends ParamData = ParamData> = {
19
- state: State<L, P>;
20
- handler: RouteHandler<L, P>;
16
+ handler: RouteHandler<M, L, P>;
21
17
  };
22
18
 
23
19
  type TakeIdentifier<T extends string, Name extends string = ""> = T extends `${infer Char}${infer Rest}` ? Char extends "/" | ":" | "*" | "{" | "}" ? [Name, T] : TakeIdentifier<Rest, `${Name}${Char}`> : [Name, T];
@@ -50,35 +46,35 @@ declare class EmbedRouter<L> {
50
46
  * @param routePath path to match with
51
47
  * @param handler function that generates the message when a path is matched
52
48
  */
53
- get<P extends Path = Path>(routePath: P | P[], handler: RouteHandler<L, ExtractParams<P>>): void;
49
+ get<P extends Path = Path>(routePath: P | P[], handler: RouteHandler<"GET", L, ExtractParams<P>>): void;
54
50
  /**
55
51
  * Registers a path with the router
56
52
  *
57
53
  * @param routePath path to match with
58
54
  * @param handler function that generates the message when a path is matched
59
55
  */
60
- post<P extends Path = Path>(routePath: P | P[], handler: RouteHandler<L, ExtractParams<P>>): void;
56
+ post<P extends Path = Path>(routePath: P | P[], handler: RouteHandler<"POST", L, ExtractParams<P>>): void;
61
57
  /**
62
58
  * Registers a path with the router
63
59
  *
64
60
  * @param routePath path to match with
65
61
  * @param handler function that generates the message when a path is matched
66
62
  */
67
- put<P extends Path = Path>(routePath: P | P[], handler: RouteHandler<L, ExtractParams<P>>): void;
63
+ put<P extends Path = Path>(routePath: P | P[], handler: RouteHandler<"PUT", L, ExtractParams<P>>): void;
68
64
  /**
69
65
  * Registers a path with the router
70
66
  *
71
67
  * @param routePath path to match with
72
68
  * @param handler function that generates the message when a path is matched
73
69
  */
74
- patch<P extends Path = Path>(routePath: P | P[], handler: RouteHandler<L, ExtractParams<P>>): void;
70
+ patch<P extends Path = Path>(routePath: P | P[], handler: RouteHandler<"PATCH", L, ExtractParams<P>>): void;
75
71
  /**
76
72
  * Registers a path with the router
77
73
  *
78
74
  * @param routePath path to match with
79
75
  * @param handler function that generates the message when a path is matched
80
76
  */
81
- delete<P extends Path = Path>(routePath: P | P[], handler: RouteHandler<L, ExtractParams<P>>): void;
77
+ delete<P extends Path = Path>(routePath: P | P[], handler: RouteHandler<"DELETE", L, ExtractParams<P>>): void;
82
78
  /**
83
79
  * Adds a subrouter to the router
84
80
  *
@@ -93,12 +89,13 @@ declare class EmbedRouter<L> {
93
89
  */
94
90
  listener(interaction: ButtonInteraction | AnySelectMenuInteraction, locals?: L | undefined): Promise<void>;
95
91
  /**
96
- * Connect or update an interaction message to a path
92
+ * Replies to or editReplies to an interaction based on the route output
97
93
  *
98
94
  * @param interaction interaction to connect to
99
95
  * @param path path to route the interaction to
100
96
  * @param method method to send to route
101
- * @param flags optional discord flags to send with message (only allowed on first reply)
97
+ * @param flags discord flags to send with message (optional, only allowed on first reply)
98
+ * @param locals additional info to pass in to page through state.local (optional)
102
99
  */
103
100
  dispatch<P extends Path = Path>({ interaction, method, path, flags, locals, }: {
104
101
  interaction: Interaction;
@@ -329,4 +326,4 @@ declare class RouteUserSelectMenuBuilder<L> extends UserSelectMenuBuilder {
329
326
  setPattern<P extends Path>(path: P): this;
330
327
  }
331
328
 
332
- export { type CompiledRoute, EmbedRouter, type Method, type ResolvedRoute, RouteButtonBuilder, RouteChannelSelectMenuBuilder, type RouteHandler, type RouteResponse, RouteRoleSelectMenuBuilder, RouteStringSelectMenuBuilder, RouteStringSelectMenuOptionBuilder, RouteUserSelectMenuBuilder, type State };
329
+ export { type CompiledRoute, EmbedRouter, type Method, RouteButtonBuilder, RouteChannelSelectMenuBuilder, type RouteHandler, type RouteResponse, RouteRoleSelectMenuBuilder, RouteStringSelectMenuBuilder, RouteStringSelectMenuOptionBuilder, RouteUserSelectMenuBuilder, type State };
package/dist/index.js CHANGED
@@ -272,12 +272,13 @@ var EmbedRouter = class _EmbedRouter {
272
272
  this.dispatch({ interaction, method: res.method, path: res.path, locals });
273
273
  }
274
274
  /**
275
- * Connect or update an interaction message to a path
275
+ * Replies to or editReplies to an interaction based on the route output
276
276
  *
277
277
  * @param interaction interaction to connect to
278
278
  * @param path path to route the interaction to
279
279
  * @param method method to send to route
280
- * @param flags optional discord flags to send with message (only allowed on first reply)
280
+ * @param flags discord flags to send with message (optional, only allowed on first reply)
281
+ * @param locals additional info to pass in to page through state.local (optional)
281
282
  */
282
283
  async dispatch({
283
284
  interaction,
@@ -288,19 +289,26 @@ var EmbedRouter = class _EmbedRouter {
288
289
  }) {
289
290
  if (interaction.isAutocomplete())
290
291
  throw new Error("Autocomplete Interactions aren't supported");
291
- const resolvedRoute = this.#resolve(method, pathToString(path2, false));
292
- if (!resolvedRoute)
293
- throw new Error(`No route found for ${pathToString(path2, false)}`);
294
- const routeResponse = await resolvedRoute.handler(interaction, {
295
- ...resolvedRoute.state,
292
+ const routeResponse = await this.#resolve({
293
+ interaction,
294
+ method,
295
+ path: path2,
296
296
  locals
297
297
  });
298
+ if (routeResponse === false)
299
+ throw new Error(`No route found for ${pathToString(path2, false)}`);
298
300
  if (interaction.replied || interaction.deferred) {
299
301
  if (flags)
300
302
  throw new Error(
301
303
  "You can only set flags for interactions that haven't been replied to"
302
304
  );
303
- await interaction.editReply(routeResponse);
305
+ if (routeResponse) await interaction.editReply(routeResponse);
306
+ } else if (!routeResponse) {
307
+ if ("deferUpdate" in interaction) {
308
+ await interaction.deferUpdate();
309
+ } else {
310
+ await interaction.deferReply();
311
+ }
304
312
  } else if ("update" in interaction) {
305
313
  if (flags)
306
314
  throw new Error(
@@ -314,19 +322,31 @@ var EmbedRouter = class _EmbedRouter {
314
322
  });
315
323
  }
316
324
  }
317
- #resolve(method, routePath) {
318
- const url = new URL(routePath, BASE_URL);
325
+ /**
326
+ * Resolves a route to the associated message (DOES NOT UPDATE MESSAGE)
327
+ *
328
+ * @param interaction interaction to connect to
329
+ * @param path path to route the interaction to
330
+ * @param method method to send to route
331
+ * @param locals additional info to pass in to page through state.local (optional)
332
+ * @returns discord message associated with route OR false
333
+ */
334
+ async #resolve({
335
+ interaction,
336
+ method = "GET",
337
+ path: path2,
338
+ locals
339
+ }) {
340
+ const url = new URL(pathToString(path2, false), BASE_URL);
319
341
  for (const route of this.#routes.get(method) ?? []) {
320
342
  const result = route.matchFunction(url.pathname);
321
343
  if (result) {
322
- return {
323
- state: {
324
- ...result,
325
- query: url.searchParams,
326
- embedRouter: this
327
- },
328
- handler: route.handler
329
- };
344
+ return await route.handler(interaction, {
345
+ ...result,
346
+ query: url.searchParams,
347
+ embedRouter: this,
348
+ locals
349
+ });
330
350
  }
331
351
  }
332
352
  return false;
@@ -354,7 +374,7 @@ var encodePath = ({
354
374
 
355
375
  // src/types/componentBuilders.ts
356
376
  var isSetOptions = (u) => {
357
- return typeof u === "object" && u !== null && (!("method" in u) || "method" in u && typeof u.method === "string" || u.method === void 0) && "path" in u && typeof u.path === "string" && (!("query" in u) || "query" in u && typeof u.query in ["object", "string"] || u.query === void 0);
377
+ return typeof u === "object" && u !== null && (!("method" in u) || "method" in u && typeof u.method === "string" || u.method === void 0) && "path" in u && typeof u.path === "string" && (!("query" in u) || "query" in u && ["object", "string"].includes(typeof u.query) || u.query === void 0);
358
378
  };
359
379
 
360
380
  // src/componentBuilders/RouteButtonBuilder.ts
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/EmbedRouter.ts","../src/consts.ts","../src/helpers/pathToString.ts","../src/helpers/decodePath.ts","../src/componentBuilders/RouteButtonBuilder.ts","../src/helpers/encodePath.ts","../src/types/componentBuilders.ts","../src/componentBuilders/RouteStringSelectMenuBuilder.ts","../src/componentBuilders/RouteStringMenuOptionBuilder.ts","../src/componentBuilders/RouteChannelSelectMenuBuilder.ts","../src/componentBuilders/RouteRoleSelectMenuBuilder.ts","../src/componentBuilders/RouteUserSelectMenuBuilder.ts"],"sourcesContent":["export { EmbedRouter } from \"./EmbedRouter\";\n\nexport { RouteButtonBuilder } from \"./componentBuilders/RouteButtonBuilder\";\nexport { RouteStringSelectMenuBuilder } from \"./componentBuilders/RouteStringSelectMenuBuilder\";\nexport { RouteStringSelectMenuOptionBuilder } from \"./componentBuilders/RouteStringMenuOptionBuilder\";\nexport { RouteChannelSelectMenuBuilder } from \"./componentBuilders/RouteChannelSelectMenuBuilder\";\nexport { RouteRoleSelectMenuBuilder } from \"./componentBuilders/RouteRoleSelectMenuBuilder\";\nexport { RouteUserSelectMenuBuilder } from \"./componentBuilders/RouteUserSelectMenuBuilder\";\n\nexport type * from \"./types/routes\";\n","import path from \"node:path\";\nimport { createHash } from \"node:crypto\";\nimport { match, Path } from \"path-to-regexp\";\nimport type {\n\tCompiledRoute,\n\tMethod,\n\tResolvedRoute,\n\tRouteHandler,\n\tState,\n} from \"./types/routes\";\nimport type { ExtractParams } from \"./types/ExtractParams\";\nimport {\n\tAnySelectMenuInteraction,\n\tButtonInteraction,\n\tInteraction,\n\tInteractionReplyOptions,\n} from \"discord.js\";\nimport { BASE_URL, ID_PREFIX, PUA_RANGE, PUA_START } from \"./consts\";\nimport { pathToString } from \"./helpers/pathToString\";\nimport { decodePath } from \"./helpers/decodePath\";\n\nexport class EmbedRouter<L> {\n\t// identifier -> embedRouter\n\tstatic #usedIdentifiers = new Map<string, EmbedRouter<unknown>>();\n\n\t// Name used to generate prefixes\n\t#name = \"\";\n\t// Prefix for customIds of RouteButtonBuilders\n\t#idPrefix: string;\n\t#identifier: string = \"\";\n\tpublic getIdPrefix() {\n\t\treturn `${this.#idPrefix}${this.#identifier}`;\n\t}\n\n\t// All added routes\n\t#routes: Map<Method, CompiledRoute<L>[]> = new Map();\n\n\t/**\n\t *\n\t * @param name the name to give the router. ensures buttons stay connected across restarts\n\t * @param idPrefix the prefix for RouteButtonBuilder customIds\n\t */\n\tconstructor({\n\t\tname = \"\",\n\t\tidPrefix = ID_PREFIX,\n\t}: {\n\t\tname?: string | undefined;\n\t\tidPrefix?: string | undefined;\n\t} = {}) {\n\t\tif (EmbedRouter.#usedIdentifiers.size >= PUA_RANGE) {\n\t\t\tthrow new Error(`You can not have more than ${PUA_RANGE} routers`);\n\t\t}\n\t\tif (idPrefix.includes(\"/\")) {\n\t\t\tthrow new Error(`Prefix can't contain \"/\": ${idPrefix}`);\n\t\t}\n\t\tthis.#idPrefix = idPrefix;\n\t\tthis.#name = name;\n\t\tthis.#updateIdentifier();\n\t}\n\n\t#updateIdentifier() {\n\t\t// Private Use Area: Unicode Characters not from any language\n\t\tconst hash = createHash(\"sha256\").update(this.#name).digest();\n\t\tlet raw = hash.readUint32BE(0);\n\t\tlet char: string;\n\t\tconst nameCollisions = [];\n\t\t// find next available identifier\n\t\twhile (true) {\n\t\t\tconst codepoint = PUA_START + (raw++ % PUA_RANGE);\n\t\t\tchar = String.fromCodePoint(codepoint);\n\n\t\t\tconst collisionRouter = EmbedRouter.#usedIdentifiers.get(char);\n\t\t\tif (collisionRouter === undefined) break; // no collisions\n\n\t\t\tif (this.#name.length > 0 && collisionRouter.#name.length === 0) {\n\t\t\t\t// evict old name; usedIdentifier is still taken\n\t\t\t\tcollisionRouter.#updateIdentifier();\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tnameCollisions.push(collisionRouter);\n\t\t}\n\t\tEmbedRouter.#usedIdentifiers.set(char, this as EmbedRouter<unknown>);\n\n\t\tif (nameCollisions.length > 0 && this.#name.length > 0) {\n\t\t\tprocess.emitWarning(\n\t\t\t\t`EmbedRouter identifier collision for name \"${this.#name}\" with ${nameCollisions.map((c) => `\"${c.#name}\"`).join(\", \")}`,\n\t\t\t\t\"EmbedRouterWarning\",\n\t\t\t);\n\t\t}\n\t\tthis.#identifier = char;\n\t}\n\n\t#addRoute<P extends Path = Path>(\n\t\tmethod: Method,\n\t\troutePath: P | P[],\n\t\thandler: RouteHandler<L, ExtractParams<P>>,\n\t) {\n\t\tconst methodRoutes = this.#routes.get(method) ?? [];\n\t\tmethodRoutes.push({\n\t\t\tmethod,\n\t\t\tpath: Array.isArray(routePath) ? routePath : [routePath],\n\t\t\tmatchFunction: match(routePath),\n\t\t\thandler: handler as RouteHandler<L>,\n\t\t});\n\t\tthis.#routes.set(method, methodRoutes);\n\t}\n\n\t/**\n\t * Registers a path with the router\n\t *\n\t * @param routePath path to match with\n\t * @param handler function that generates the message when a path is matched\n\t */\n\tpublic get<P extends Path = Path>(\n\t\troutePath: P | P[],\n\t\thandler: RouteHandler<L, ExtractParams<P>>,\n\t) {\n\t\tthis.#addRoute(\"GET\", routePath, handler);\n\t}\n\n\t/**\n\t * Registers a path with the router\n\t *\n\t * @param routePath path to match with\n\t * @param handler function that generates the message when a path is matched\n\t */\n\tpublic post<P extends Path = Path>(\n\t\troutePath: P | P[],\n\t\thandler: RouteHandler<L, ExtractParams<P>>,\n\t) {\n\t\tthis.#addRoute(\"POST\", routePath, handler);\n\t}\n\n\t/**\n\t * Registers a path with the router\n\t *\n\t * @param routePath path to match with\n\t * @param handler function that generates the message when a path is matched\n\t */\n\tpublic put<P extends Path = Path>(\n\t\troutePath: P | P[],\n\t\thandler: RouteHandler<L, ExtractParams<P>>,\n\t) {\n\t\tthis.#addRoute(\"PUT\", routePath, handler);\n\t}\n\n\t/**\n\t * Registers a path with the router\n\t *\n\t * @param routePath path to match with\n\t * @param handler function that generates the message when a path is matched\n\t */\n\tpublic patch<P extends Path = Path>(\n\t\troutePath: P | P[],\n\t\thandler: RouteHandler<L, ExtractParams<P>>,\n\t) {\n\t\tthis.#addRoute(\"PATCH\", routePath, handler);\n\t}\n\n\t/**\n\t * Registers a path with the router\n\t *\n\t * @param routePath path to match with\n\t * @param handler function that generates the message when a path is matched\n\t */\n\tpublic delete<P extends Path = Path>(\n\t\troutePath: P | P[],\n\t\thandler: RouteHandler<L, ExtractParams<P>>,\n\t) {\n\t\tthis.#addRoute(\"DELETE\", routePath, handler);\n\t}\n\n\t/**\n\t * Adds a subrouter to the router\n\t *\n\t * @param routePath path of the router\n\t * @param embedRouter router to add at the path\n\t */\n\tpublic use<P extends Path = Path>(routePath: P, embedRouter: EmbedRouter<L>) {\n\t\tconst pathString = pathToString(routePath);\n\t\tfor (const [method, routes] of embedRouter.#routes) {\n\t\t\tfor (const route of routes) {\n\t\t\t\tthis.#addRoute(\n\t\t\t\t\tmethod,\n\t\t\t\t\troute.path.map((p) => path.posix.join(pathString, pathToString(p))),\n\t\t\t\t\troute.handler,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Must be attached to \"interactionCreate\" event for RouteButtonBuilder to work\n\t *\n\t * @param interaction interactions from \"interactionCreate\" (filter for ButtonInteractions)\n\t */\n\tpublic async listener(\n\t\tinteraction: ButtonInteraction | AnySelectMenuInteraction,\n\t\tlocals?: L | undefined,\n\t) {\n\t\tconst res = decodePath({ idPrefix: this.getIdPrefix(), interaction });\n\t\tif (!res)\n\t\t\tthrow new Error(`Invalid component found: id ${interaction.customId}`);\n\n\t\tthis.dispatch({ interaction, method: res.method, path: res.path, locals });\n\t}\n\n\t/**\n\t * Connect or update an interaction message to a path\n\t *\n\t * @param interaction interaction to connect to\n\t * @param path path to route the interaction to\n\t * @param method method to send to route\n\t * @param flags optional discord flags to send with message (only allowed on first reply)\n\t */\n\tpublic async dispatch<P extends Path = Path>({\n\t\tinteraction,\n\t\tmethod = \"GET\",\n\t\tpath,\n\t\tflags,\n\t\tlocals,\n\t}: {\n\t\tinteraction: Interaction;\n\t\tmethod?: Method;\n\t\tpath: P;\n\t\tflags?: InteractionReplyOptions[\"flags\"] | undefined;\n\t\tlocals?: L | undefined;\n\t}) {\n\t\tif (interaction.isAutocomplete())\n\t\t\tthrow new Error(\"Autocomplete Interactions aren't supported\");\n\n\t\t// don't check validity because url params are considered invalid\n\t\tconst resolvedRoute = this.#resolve(method, pathToString(path, false));\n\t\tif (!resolvedRoute)\n\t\t\tthrow new Error(`No route found for ${pathToString(path, false)}`);\n\n\t\tconst routeResponse = await resolvedRoute.handler(interaction, {\n\t\t\t...resolvedRoute.state,\n\t\t\tlocals,\n\t\t});\n\n\t\tif (interaction.replied || interaction.deferred) {\n\t\t\tif (flags)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"You can only set flags for interactions that haven't been replied to\",\n\t\t\t\t);\n\t\t\tawait interaction.editReply(routeResponse);\n\t\t} else if (\"update\" in interaction) {\n\t\t\tif (flags)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"You can only set flags for interactions that haven't been replied to\",\n\t\t\t\t);\n\t\t\tawait interaction.update(routeResponse);\n\t\t} else {\n\t\t\tinteraction.reply({\n\t\t\t\t...(routeResponse as InteractionReplyOptions),\n\t\t\t\tflags,\n\t\t\t});\n\t\t}\n\t}\n\n\t#resolve<P extends string>(\n\t\tmethod: Method,\n\t\troutePath: P,\n\t): ResolvedRoute<L, ExtractParams<P>> | false {\n\t\tconst url = new URL(routePath, BASE_URL);\n\t\tfor (const route of this.#routes.get(method) ?? []) {\n\t\t\tconst result = route.matchFunction(url.pathname);\n\t\t\tif (result) {\n\t\t\t\treturn {\n\t\t\t\t\tstate: {\n\t\t\t\t\t\t...(result as State<L, ExtractParams<P>>),\n\t\t\t\t\t\tquery: url.searchParams,\n\t\t\t\t\t\tembedRouter: this,\n\t\t\t\t\t},\n\t\t\t\t\thandler: route.handler,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n}\n","import { Method } from \"./types/routes\";\n\nexport const ID_PREFIX = \"der\";\nexport const METHOD_TO_ENCODING: Record<Method, string> = {\n\tGET: \"G\",\n\tPOST: \"P\",\n\tPUT: \"U\",\n\tPATCH: \"A\",\n\tDELETE: \"D\",\n};\nexport const ENCODING_TO_METHOD: Record<string, Method> = {\n\tG: \"GET\",\n\tP: \"POST\",\n\tU: \"PUT\",\n\tA: \"PATCH\",\n\tD: \"DELETE\",\n};\n// base url is never sent; only used for processing locally\nexport const BASE_URL = \"discord://embed.router\";\n\nexport const PUA_START = 0xe000;\nexport const PUA_END = 0xf8ff;\nexport const PUA_RANGE = PUA_END - PUA_START + 1;\n","import { parse, Path, stringify, TokenData } from \"path-to-regexp\";\n\nexport const pathToString = <P extends Path>(\n\tpath: P,\n\tcheckValidity = true,\n): string => {\n\tif (checkValidity) {\n\t\treturn stringify(path instanceof TokenData ? path : parse(path));\n\t}\n\treturn typeof path === \"string\" ? path : stringify(path);\n};\n","import { compile, Path } from \"path-to-regexp\";\nimport { AnySelectMenuInteraction, ButtonInteraction } from \"discord.js\";\nimport { BASE_URL, ENCODING_TO_METHOD } from \"../consts\";\nimport { Method } from \"../types/routes\";\n\nexport const decodePath = ({\n\tidPrefix,\n\tinteraction,\n}: {\n\tidPrefix: string;\n\tinteraction: ButtonInteraction | AnySelectMenuInteraction;\n}): { method: Method; path: Path } | false => {\n\tconst customId = interaction.customId;\n\tif (!customId.startsWith(idPrefix)) return false;\n\n\tif (interaction.isButton()) {\n\t\treturn parseMethodAndPath(customId.slice(idPrefix.length));\n\t} else if (interaction.isAnySelectMenu()) {\n\t\tif (interaction.values.length === 0) return false;\n\t\tconst res = parseMethodAndPath(customId.slice(idPrefix.length));\n\t\tif (!res) return false;\n\n\t\tconst { method, path } = res;\n\t\treturn {\n\t\t\tmethod,\n\t\t\tpath: fillParams(path, {\n\t\t\t\t[interaction.isStringSelectMenu()\n\t\t\t\t\t? \"to\"\n\t\t\t\t\t: interaction.isChannelSelectMenu()\n\t\t\t\t\t\t? \"channelId\"\n\t\t\t\t\t\t: interaction.isRoleSelectMenu()\n\t\t\t\t\t\t\t? \"roleId\"\n\t\t\t\t\t\t\t: \"userId\"]: interaction.values[0]!.split(\"/\").slice(1),\n\t\t\t}),\n\t\t};\n\t}\n\n\treturn false;\n};\n\nexport const parseMethodAndPath = (\n\tpathWithMethod: string,\n): { method: Method; path: string } | false => {\n\t// path always start with \"/\"\n\tconst firstSlash = pathWithMethod.indexOf(\"/\");\n\t// invalid customId\n\tif (firstSlash <= 0) return false;\n\n\tconst method = ENCODING_TO_METHOD[pathWithMethod.slice(0, firstSlash)];\n\tif (method === undefined) return false;\n\treturn {\n\t\tmethod,\n\t\tpath: pathWithMethod.slice(firstSlash),\n\t};\n};\n\nconst fillParams = (\n\tpath: string,\n\tparams: Partial<Record<string, string | string[]>> = {},\n): string => {\n\tconst url = new URL(path, BASE_URL);\n\tconst toPath = compile(url.pathname);\n\n\turl.pathname = toPath(params);\n\tfor (const [key, value] of url.searchParams) {\n\t\tif (value.startsWith(\":\") && key.slice(1) in params) {\n\t\t\tconst paramValue = params?.[key.slice(1)];\n\t\t\tif (paramValue) {\n\t\t\t\turl.searchParams.set(\n\t\t\t\t\tkey,\n\t\t\t\t\tArray.isArray(paramValue) ? paramValue.join(\"/\") : paramValue,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\turl.searchParams.delete(key);\n\t\t\t}\n\t\t}\n\t}\n\treturn `${url.pathname}${url.search}`;\n};\n","import { APIButtonComponent, ButtonBuilder } from \"discord.js\";\nimport { Path } from \"path-to-regexp\";\nimport { EmbedRouter } from \"../EmbedRouter\";\nimport { encodePath } from \"../helpers/encodePath\";\nimport { isSetOptions, SetOptions } from \"../types/componentBuilders\";\n\nexport class RouteButtonBuilder<L> extends ButtonBuilder {\n\t#embedRouter: EmbedRouter<L>;\n\n\t/**\n\t *\n\t * @param embedRouter the router you want to route with\n\t * @param data the data to construct a component out of\n\t */\n\tconstructor(\n\t\tembedRouter: EmbedRouter<L>,\n\t\tdata?: Omit<Partial<APIButtonComponent>, \"custom_id\" | \"url\"> | undefined,\n\t) {\n\t\tsuper(data);\n\n\t\tthis.#embedRouter = embedRouter;\n\t}\n\n\t/**\n\t * Not supported for RouteButtonBuilder\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride setURL(): this {\n\t\tthrow new Error(\"setURL is not supported on RouteButtonBuilder\");\n\t}\n\n\t/**\n\t * Not supported for RouteButtonBuilder (use setTo)\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride setCustomId(): this {\n\t\tthrow new Error(\"setCustomId is not supported on RouteButtonBuilder\");\n\t}\n\n\t/**\n\t * Sets the path to route to when clicked\n\t *\n\t * @param path the path to route to\n\t * @param query any query parameters you want to add\n\t * @param method method to send to route\n\t */\n\tpublic setTo<P extends Path>({ method, path, query }: SetOptions<P>): this;\n\t/**\n\t * Sets the path to route to when clicked\n\t *\n\t * @param path the path to route to\n\t */\n\tpublic setTo<P extends Path>(path: P): this;\n\n\tpublic setTo<P extends Path>(arg: P | SetOptions<P>) {\n\t\tconst {\n\t\t\tmethod = \"GET\",\n\t\t\tpath,\n\t\t\tquery,\n\t\t} = isSetOptions(arg) ? arg : { path: arg };\n\t\tsuper.setCustomId(\n\t\t\tencodePath({\n\t\t\t\tidPrefix: this.#embedRouter.getIdPrefix(),\n\t\t\t\tmethod,\n\t\t\t\tpath,\n\t\t\t\tquery,\n\t\t\t}),\n\t\t);\n\n\t\treturn this;\n\t}\n}\n","import { Path } from \"path-to-regexp\";\nimport { BASE_URL, METHOD_TO_ENCODING } from \"../consts\";\nimport { pathToString } from \"./pathToString\";\nimport { Method } from \"../types/routes\";\n\nexport const encodePath = ({\n\tidPrefix,\n\tmethod,\n\tpath,\n\tquery,\n}: {\n\tidPrefix: string;\n\tmethod: Method;\n\tpath: Path;\n\tquery?: ConstructorParameters<typeof URLSearchParams>[0] | undefined;\n}) => {\n\tconst url = new URL(pathToString(path), BASE_URL);\n\tif (query) {\n\t\tfor (const [key, value] of new URLSearchParams(query)) {\n\t\t\turl.searchParams.set(key, value);\n\t\t}\n\t}\n\treturn `${idPrefix}${METHOD_TO_ENCODING[method]}${url.pathname}${url.search}`;\n};\n","import { Path } from \"path-to-regexp\";\nimport { Method } from \"./routes\";\n\nexport type SetOptions<P extends Path> = {\n\tmethod?: Method;\n\tpath: P;\n\tquery?: ConstructorParameters<typeof URLSearchParams>[0] | undefined;\n};\n\nexport const isSetOptions = <P extends Path>(\n\tu: unknown,\n): u is SetOptions<P> => {\n\treturn (\n\t\ttypeof u === \"object\" &&\n\t\tu !== null &&\n\t\t(!(\"method\" in u) ||\n\t\t\t(\"method\" in u && typeof u.method === \"string\") ||\n\t\t\tu.method === undefined) &&\n\t\t\"path\" in u &&\n\t\ttypeof u.path === \"string\" &&\n\t\t(!(\"query\" in u) ||\n\t\t\t(\"query\" in u && (typeof u.query) in [\"object\", \"string\"]) ||\n\t\t\tu.query === undefined)\n\t);\n};\n","import {\n\tAPIStringSelectComponent,\n\tnormalizeArray,\n\tRestOrArray,\n\tStringSelectMenuBuilder,\n\tStringSelectMenuComponentData,\n} from \"discord.js\";\nimport { Path } from \"path-to-regexp\";\nimport { RouteStringSelectMenuOptionBuilder } from \"./RouteStringMenuOptionBuilder\";\nimport { EmbedRouter } from \"../EmbedRouter\";\nimport { encodePath } from \"../helpers/encodePath\";\nimport { isSetOptions, SetOptions } from \"../types/componentBuilders\";\n\nexport class RouteStringSelectMenuBuilder<L> extends StringSelectMenuBuilder {\n\t#embedRouter: EmbedRouter<L>;\n\n\t/**\n\t *\n\t * @param embedRouter the router you want to route with\n\t * @param path the path to redirect to, :to or *to in path will be replaced with the selected user's id\n\t * @param query any query parameters you want to add, :to will be replaced with the selected user's id\n\t * @param data the data to construct a component out of\n\t */\n\tconstructor(\n\t\tembedRouter: EmbedRouter<L>,\n\t\tdata?:\n\t\t\t| Partial<StringSelectMenuComponentData | APIStringSelectComponent>\n\t\t\t| undefined,\n\t) {\n\t\tsuper(data);\n\n\t\tthis.#embedRouter = embedRouter;\n\n\t\tsuper.setCustomId(\n\t\t\tencodePath({\n\t\t\t\tidPrefix: this.#embedRouter.getIdPrefix(),\n\t\t\t\tmethod: \"GET\",\n\t\t\t\tpath: \"/*to\",\n\t\t\t}),\n\t\t);\n\t}\n\n\t/**\n\t * Not supported for RouteStringSelectMenuBuilder (customId set from embedRouter)\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride setCustomId(): this {\n\t\tthrow new Error(\n\t\t\t\"setCustomId is not supported on RouteStringSelectMenuBuilder\",\n\t\t);\n\t}\n\n\t/**\n\t * Not supported for RouteStringSelectMenuBuilder (use addTos)\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride addOptions(): this {\n\t\tthrow new Error(\n\t\t\t\"addOptions is not supported on RouteStringSelectMenuBuilder\",\n\t\t);\n\t}\n\n\t/**\n\t * Not supported for RouteStringSelectMenuBuilder (use setTos)\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride setOptions(): this {\n\t\tthrow new Error(\n\t\t\t\"setOptions is not supported on RouteStringSelectMenuBuilder\",\n\t\t);\n\t}\n\n\t/**\n\t * Adds route select menu options to builder\n\t *\n\t * @param tos the list of route select menu options\n\t */\n\tpublic addTos(\n\t\t...tos: RestOrArray<\n\t\t\t| RouteStringSelectMenuOptionBuilder\n\t\t\t| ConstructorParameters<typeof RouteStringSelectMenuOptionBuilder>[0]\n\t\t>\n\t): this {\n\t\tconst resolved = normalizeArray(tos);\n\t\tsuper.addOptions(\n\t\t\tresolved.map((o) =>\n\t\t\t\to instanceof RouteStringSelectMenuOptionBuilder\n\t\t\t\t\t? o\n\t\t\t\t\t: new RouteStringSelectMenuOptionBuilder(o),\n\t\t\t),\n\t\t);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets route select menu options to builder\n\t *\n\t * @param tos the list of route select menu options\n\t */\n\tpublic setTos(\n\t\t...tos: RestOrArray<\n\t\t\t| RouteStringSelectMenuOptionBuilder\n\t\t\t| ConstructorParameters<typeof RouteStringSelectMenuOptionBuilder>[0]\n\t\t>\n\t): this {\n\t\tconst resolved = normalizeArray(tos);\n\t\tsuper.setOptions(\n\t\t\tresolved.map((o) =>\n\t\t\t\to instanceof RouteStringSelectMenuOptionBuilder\n\t\t\t\t\t? o\n\t\t\t\t\t: new RouteStringSelectMenuOptionBuilder(o),\n\t\t\t),\n\t\t);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the pattern to redirect to (Required)\n\t *\n\t * @param path the path to redirect to, :to or *to in path will be replaced with the selected user's id\n\t * @param query any query parameters you want to add, :to will be replaced with the selected user's id\n\t * @param method method to send to route\n\t */\n\tpublic setPattern<P extends Path>({\n\t\tmethod,\n\t\tpath,\n\t\tquery,\n\t}: SetOptions<P>): this;\n\t/**\n\t * Sets the path to route to when clicked\n\t *\n\t * @param path the path to route to\n\t */\n\tpublic setPattern<P extends Path>(path: P): this;\n\n\tpublic setPattern<P extends Path>(arg: P | SetOptions<P>) {\n\t\tconst {\n\t\t\tmethod = \"GET\",\n\t\t\tpath,\n\t\t\tquery,\n\t\t} = isSetOptions(arg) ? arg : { path: arg };\n\t\tsuper.setCustomId(\n\t\t\tencodePath({\n\t\t\t\tidPrefix: this.#embedRouter.getIdPrefix(),\n\t\t\t\tmethod,\n\t\t\t\tpath,\n\t\t\t\tquery,\n\t\t\t}),\n\t\t);\n\n\t\treturn this;\n\t}\n}\n","import { StringSelectMenuOptionBuilder } from \"discord.js\";\nimport { Path } from \"path-to-regexp\";\nimport { encodePath } from \"../helpers/encodePath\";\nimport { isSetOptions, SetOptions } from \"../types/componentBuilders\";\n\nexport class RouteStringSelectMenuOptionBuilder extends StringSelectMenuOptionBuilder {\n\t/**\n\t * Not supported for RouteStringSelectMenuOptionBuilder (use setTo)\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride setValue(): this {\n\t\tthrow new Error(\n\t\t\t\"setValue is not supported on RouteStringSelectMenuOptionBuilder\",\n\t\t);\n\t}\n\n\t/**\n\t * Sets the path to route to when clicked\n\t *\n\t * @param path the path to route to\n\t * @param query any query parameters you want to add\n\t * @param method method to send to route\n\t */\n\tpublic setTo<P extends Path>({ method, path, query }: SetOptions<P>): this;\n\t/**\n\t * Sets the path to route to when clicked\n\t *\n\t * @param path the path to route to\n\t */\n\tpublic setTo<P extends Path>(path: P): this;\n\n\tpublic setTo<P extends Path>(arg: P | SetOptions<P>) {\n\t\tconst {\n\t\t\tmethod = \"GET\",\n\t\t\tpath,\n\t\t\tquery,\n\t\t} = isSetOptions(arg) ? arg : { path: arg };\n\t\tsuper.setValue(\n\t\t\tencodePath({\n\t\t\t\tidPrefix: \"\",\n\t\t\t\tmethod,\n\t\t\t\tpath,\n\t\t\t\tquery,\n\t\t\t}),\n\t\t);\n\n\t\treturn this;\n\t}\n}\n","import {\n\tAPIChannelSelectComponent,\n\tChannelSelectMenuBuilder,\n\tChannelSelectMenuComponentData,\n} from \"discord.js\";\nimport { EmbedRouter } from \"../EmbedRouter\";\nimport { Path } from \"path-to-regexp\";\nimport { encodePath } from \"../helpers/encodePath\";\nimport { isSetOptions, SetOptions } from \"../types/componentBuilders\";\n\nexport class RouteChannelSelectMenuBuilder<L> extends ChannelSelectMenuBuilder {\n\t#embedRouter: EmbedRouter<L>;\n\n\t/**\n\t *\n\t * @param embedRouter the router you want to route with\n\t * @param data the data to construct a component out of\n\t */\n\tconstructor(\n\t\tembedRouter: EmbedRouter<L>,\n\t\tdata?:\n\t\t\t| Partial<ChannelSelectMenuComponentData | APIChannelSelectComponent>\n\t\t\t| undefined,\n\t) {\n\t\tsuper(data);\n\n\t\tthis.#embedRouter = embedRouter;\n\t}\n\n\t/**\n\t * Not supported for RouteChannelSelectMenuBuilder (customId set from embedRouter)\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride setCustomId(): this {\n\t\tthrow new Error(\n\t\t\t\"setCustomId is not supported on RouteChannelSelectMenuBuilder\",\n\t\t);\n\t}\n\n\t/**\n\t * Sets the pattern to redirect to (Required)\n\t *\n\t * @param path the path to redirect to, :channelId in path will be replaced with the selected user's id\n\t * @param query any query parameters you want to add, :channelId will be replaced with the selected user's id\n\t * @param method method to send to route\n\t */\n\tpublic setPattern<P extends Path>({\n\t\tmethod,\n\t\tpath,\n\t\tquery,\n\t}: SetOptions<P>): this;\n\t/**\n\t * Sets the path to route to when clicked\n\t *\n\t * @param path the path to route to\n\t */\n\tpublic setPattern<P extends Path>(path: P): this;\n\n\tpublic setPattern<P extends Path>(arg: P | SetOptions<P>) {\n\t\tconst {\n\t\t\tmethod = \"GET\",\n\t\t\tpath,\n\t\t\tquery,\n\t\t} = isSetOptions(arg) ? arg : { path: arg };\n\t\tsuper.setCustomId(\n\t\t\tencodePath({\n\t\t\t\tidPrefix: this.#embedRouter.getIdPrefix(),\n\t\t\t\tmethod,\n\t\t\t\tpath,\n\t\t\t\tquery,\n\t\t\t}),\n\t\t);\n\n\t\treturn this;\n\t}\n}\n","import {\n\tAPIRoleSelectComponent,\n\tRoleSelectMenuBuilder,\n\tRoleSelectMenuComponentData,\n} from \"discord.js\";\nimport { EmbedRouter } from \"../EmbedRouter\";\nimport { Path } from \"path-to-regexp\";\nimport { encodePath } from \"../helpers/encodePath\";\nimport { isSetOptions, SetOptions } from \"../types/componentBuilders\";\n\nexport class RouteRoleSelectMenuBuilder<L> extends RoleSelectMenuBuilder {\n\t#embedRouter: EmbedRouter<L>;\n\n\t/**\n\t *\n\t * @param embedRouter the router you want to route with\n\t * @param data the data to construct a component out of\n\t */\n\tconstructor(\n\t\tembedRouter: EmbedRouter<L>,\n\t\tdata?:\n\t\t\tPartial<RoleSelectMenuComponentData | APIRoleSelectComponent> | undefined,\n\t) {\n\t\tsuper(data);\n\n\t\tthis.#embedRouter = embedRouter;\n\t}\n\n\t/**\n\t * Not supported for RouteRoleSelectMenuBuilder (customId set from embedRouter)\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride setCustomId(): this {\n\t\tthrow new Error(\n\t\t\t\"setCustomId is not supported on RouteRoleSelectMenuBuilder\",\n\t\t);\n\t}\n\n\t/**\n\t * Sets the pattern to redirect to (Required)\n\t *\n\t * @param path the path to redirect to, :roleId in path will be replaced with the selected user's id\n\t * @param query any query parameters you want to add, :roleId will be replaced with the selected user's id\n\t * @param method method to send to route\n\t */\n\tpublic setPattern<P extends Path>({\n\t\tmethod,\n\t\tpath,\n\t\tquery,\n\t}: SetOptions<P>): this;\n\t/**\n\t * Sets the path to route to when clicked\n\t *\n\t * @param path the path to route to\n\t */\n\tpublic setPattern<P extends Path>(path: P): this;\n\n\tpublic setPattern<P extends Path>(arg: P | SetOptions<P>) {\n\t\tconst {\n\t\t\tmethod = \"GET\",\n\t\t\tpath,\n\t\t\tquery,\n\t\t} = isSetOptions(arg) ? arg : { path: arg };\n\t\tsuper.setCustomId(\n\t\t\tencodePath({\n\t\t\t\tidPrefix: this.#embedRouter.getIdPrefix(),\n\t\t\t\tmethod,\n\t\t\t\tpath,\n\t\t\t\tquery,\n\t\t\t}),\n\t\t);\n\n\t\treturn this;\n\t}\n}\n","import {\n\tAPIUserSelectComponent,\n\tUserSelectMenuBuilder,\n\tUserSelectMenuComponentData,\n} from \"discord.js\";\nimport { EmbedRouter } from \"../EmbedRouter\";\nimport { Path } from \"path-to-regexp\";\nimport { encodePath } from \"../helpers/encodePath\";\nimport { isSetOptions, SetOptions } from \"../types/componentBuilders\";\n\nexport class RouteUserSelectMenuBuilder<L> extends UserSelectMenuBuilder {\n\t#embedRouter: EmbedRouter<L>;\n\n\t/**\n\t *\n\t * @param embedRouter the router you want to route with\n\t * @param data the data to construct a component out of\n\t */\n\tconstructor(\n\t\tembedRouter: EmbedRouter<L>,\n\t\tdata?:\n\t\t\tPartial<UserSelectMenuComponentData | APIUserSelectComponent> | undefined,\n\t) {\n\t\tsuper(data);\n\n\t\tthis.#embedRouter = embedRouter;\n\t}\n\n\t/**\n\t * Not supported for RouteUserSelectMenuBuilder (customId set from embedRouter)\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride setCustomId(): this {\n\t\tthrow new Error(\n\t\t\t\"setCustomId is not supported on RouteUserSelectMenuBuilder\",\n\t\t);\n\t}\n\n\t/**\n\t * Sets the pattern to redirect to (Required)\n\t *\n\t * @param path the path to redirect to, :userId in path will be replaced with the selected user's id\n\t * @param query any query parameters you want to add, :userId will be replaced with the selected user's id\n\t * @param method method to send to route\n\t */\n\tpublic setPattern<P extends Path>({\n\t\tmethod,\n\t\tpath,\n\t\tquery,\n\t}: SetOptions<P>): this;\n\t/**\n\t * Sets the path to route to when clicked\n\t *\n\t * @param path the path to route to\n\t */\n\tpublic setPattern<P extends Path>(path: P): this;\n\n\tpublic setPattern<P extends Path>(arg: P | SetOptions<P>) {\n\t\tconst {\n\t\t\tmethod = \"GET\",\n\t\t\tpath,\n\t\t\tquery,\n\t\t} = isSetOptions(arg) ? arg : { path: arg };\n\t\tsuper.setCustomId(\n\t\t\tencodePath({\n\t\t\t\tidPref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,WAA2B,KAAwB;AACzD,UAAM;AAAA,MACL,SAAS;AAAA,MACT,MAAAC;AAAA,MACA;AAAA,IACD,IAAI,aAAa,GAAG,IAAI,MAAM,EAAE,MAAM,IAAI;AAC1C,UAAM;AAAA,MACL,WAAW;AAAA,QACV,UAAU,KAAK,aAAa,YAAY;AAAA,QACxC;AAAA,QACA,MAAAA;AAAA,QACA;AAAA,MACD,CAAC;AAAA,IACF;AAEA,WAAO;AAAA,EACR;AACD;","names":["import_path_to_regexp","path","import_path_to_regexp","path","path","path","path","import_discord","import_discord","path","path","import_discord","path","import_discord","path","import_discord","path"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/EmbedRouter.ts","../src/consts.ts","../src/helpers/pathToString.ts","../src/helpers/decodePath.ts","../src/componentBuilders/RouteButtonBuilder.ts","../src/helpers/encodePath.ts","../src/types/componentBuilders.ts","../src/componentBuilders/RouteStringSelectMenuBuilder.ts","../src/componentBuilders/RouteStringMenuOptionBuilder.ts","../src/componentBuilders/RouteChannelSelectMenuBuilder.ts","../src/componentBuilders/RouteRoleSelectMenuBuilder.ts","../src/componentBuilders/RouteUserSelectMenuBuilder.ts"],"sourcesContent":["export { EmbedRouter } from \"./EmbedRouter\";\n\nexport { RouteButtonBuilder } from \"./componentBuilders/RouteButtonBuilder\";\nexport { RouteStringSelectMenuBuilder } from \"./componentBuilders/RouteStringSelectMenuBuilder\";\nexport { RouteStringSelectMenuOptionBuilder } from \"./componentBuilders/RouteStringMenuOptionBuilder\";\nexport { RouteChannelSelectMenuBuilder } from \"./componentBuilders/RouteChannelSelectMenuBuilder\";\nexport { RouteRoleSelectMenuBuilder } from \"./componentBuilders/RouteRoleSelectMenuBuilder\";\nexport { RouteUserSelectMenuBuilder } from \"./componentBuilders/RouteUserSelectMenuBuilder\";\n\nexport type * from \"./types/routes\";\n","import path from \"node:path\";\nimport { createHash } from \"node:crypto\";\nimport { match, MatchResult, Path } from \"path-to-regexp\";\nimport type {\n\tCompiledRoute,\n\tMethod,\n\tRouteHandler,\n\tRouteResponse,\n} from \"./types/routes\";\nimport type { ExtractParams } from \"./types/ExtractParams\";\nimport {\n\tAnySelectMenuInteraction,\n\tButtonInteraction,\n\tInteraction,\n\tInteractionReplyOptions,\n} from \"discord.js\";\nimport { BASE_URL, ID_PREFIX, PUA_RANGE, PUA_START } from \"./consts\";\nimport { pathToString } from \"./helpers/pathToString\";\nimport { decodePath } from \"./helpers/decodePath\";\n\nexport class EmbedRouter<L> {\n\t// identifier -> embedRouter\n\tstatic #usedIdentifiers = new Map<string, EmbedRouter<unknown>>();\n\n\t// Name used to generate prefixes\n\t#name = \"\";\n\t// Prefix for customIds of RouteButtonBuilders\n\t#idPrefix: string;\n\t#identifier: string = \"\";\n\tpublic getIdPrefix() {\n\t\treturn `${this.#idPrefix}${this.#identifier}`;\n\t}\n\n\t// All added routes\n\t#routes: Map<Method, CompiledRoute<Method, L>[]> = new Map();\n\n\t/**\n\t *\n\t * @param name the name to give the router. ensures buttons stay connected across restarts\n\t * @param idPrefix the prefix for RouteButtonBuilder customIds\n\t */\n\tconstructor({\n\t\tname = \"\",\n\t\tidPrefix = ID_PREFIX,\n\t}: {\n\t\tname?: string | undefined;\n\t\tidPrefix?: string | undefined;\n\t} = {}) {\n\t\tif (EmbedRouter.#usedIdentifiers.size >= PUA_RANGE) {\n\t\t\tthrow new Error(`You can not have more than ${PUA_RANGE} routers`);\n\t\t}\n\t\tif (idPrefix.includes(\"/\")) {\n\t\t\tthrow new Error(`Prefix can't contain \"/\": ${idPrefix}`);\n\t\t}\n\t\tthis.#idPrefix = idPrefix;\n\t\tthis.#name = name;\n\t\tthis.#updateIdentifier();\n\t}\n\n\t#updateIdentifier() {\n\t\t// Private Use Area: Unicode Characters not from any language\n\t\tconst hash = createHash(\"sha256\").update(this.#name).digest();\n\t\tlet raw = hash.readUint32BE(0);\n\t\tlet char: string;\n\t\tconst nameCollisions = [];\n\t\t// find next available identifier\n\t\twhile (true) {\n\t\t\tconst codepoint = PUA_START + (raw++ % PUA_RANGE);\n\t\t\tchar = String.fromCodePoint(codepoint);\n\n\t\t\tconst collisionRouter = EmbedRouter.#usedIdentifiers.get(char);\n\t\t\tif (collisionRouter === undefined) break; // no collisions\n\n\t\t\tif (this.#name.length > 0 && collisionRouter.#name.length === 0) {\n\t\t\t\t// evict old name; usedIdentifier is still taken\n\t\t\t\tcollisionRouter.#updateIdentifier();\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tnameCollisions.push(collisionRouter);\n\t\t}\n\t\tEmbedRouter.#usedIdentifiers.set(char, this as EmbedRouter<unknown>);\n\n\t\tif (nameCollisions.length > 0 && this.#name.length > 0) {\n\t\t\tprocess.emitWarning(\n\t\t\t\t`EmbedRouter identifier collision for name \"${this.#name}\" with ${nameCollisions.map((c) => `\"${c.#name}\"`).join(\", \")}`,\n\t\t\t\t\"EmbedRouterWarning\",\n\t\t\t);\n\t\t}\n\t\tthis.#identifier = char;\n\t}\n\n\t#addRoute<M extends Method, P extends Path = Path>(\n\t\tmethod: M,\n\t\troutePath: P | P[],\n\t\thandler: RouteHandler<M, L, ExtractParams<P>>,\n\t) {\n\t\tconst methodRoutes = this.#routes.get(method) ?? [];\n\t\tmethodRoutes.push({\n\t\t\tmethod,\n\t\t\tpath: Array.isArray(routePath) ? routePath : [routePath],\n\t\t\tmatchFunction: match(routePath),\n\t\t\thandler: handler as RouteHandler<M, L>,\n\t\t});\n\t\tthis.#routes.set(method, methodRoutes);\n\t}\n\n\t/**\n\t * Registers a path with the router\n\t *\n\t * @param routePath path to match with\n\t * @param handler function that generates the message when a path is matched\n\t */\n\tpublic get<P extends Path = Path>(\n\t\troutePath: P | P[],\n\t\thandler: RouteHandler<\"GET\", L, ExtractParams<P>>,\n\t) {\n\t\tthis.#addRoute(\"GET\", routePath, handler);\n\t}\n\n\t/**\n\t * Registers a path with the router\n\t *\n\t * @param routePath path to match with\n\t * @param handler function that generates the message when a path is matched\n\t */\n\tpublic post<P extends Path = Path>(\n\t\troutePath: P | P[],\n\t\thandler: RouteHandler<\"POST\", L, ExtractParams<P>>,\n\t) {\n\t\tthis.#addRoute(\"POST\", routePath, handler);\n\t}\n\n\t/**\n\t * Registers a path with the router\n\t *\n\t * @param routePath path to match with\n\t * @param handler function that generates the message when a path is matched\n\t */\n\tpublic put<P extends Path = Path>(\n\t\troutePath: P | P[],\n\t\thandler: RouteHandler<\"PUT\", L, ExtractParams<P>>,\n\t) {\n\t\tthis.#addRoute(\"PUT\", routePath, handler);\n\t}\n\n\t/**\n\t * Registers a path with the router\n\t *\n\t * @param routePath path to match with\n\t * @param handler function that generates the message when a path is matched\n\t */\n\tpublic patch<P extends Path = Path>(\n\t\troutePath: P | P[],\n\t\thandler: RouteHandler<\"PATCH\", L, ExtractParams<P>>,\n\t) {\n\t\tthis.#addRoute(\"PATCH\", routePath, handler);\n\t}\n\n\t/**\n\t * Registers a path with the router\n\t *\n\t * @param routePath path to match with\n\t * @param handler function that generates the message when a path is matched\n\t */\n\tpublic delete<P extends Path = Path>(\n\t\troutePath: P | P[],\n\t\thandler: RouteHandler<\"DELETE\", L, ExtractParams<P>>,\n\t) {\n\t\tthis.#addRoute(\"DELETE\", routePath, handler);\n\t}\n\n\t/**\n\t * Adds a subrouter to the router\n\t *\n\t * @param routePath path of the router\n\t * @param embedRouter router to add at the path\n\t */\n\tpublic use<P extends Path = Path>(routePath: P, embedRouter: EmbedRouter<L>) {\n\t\tconst pathString = pathToString(routePath);\n\t\tfor (const [method, routes] of embedRouter.#routes) {\n\t\t\tfor (const route of routes) {\n\t\t\t\tthis.#addRoute(\n\t\t\t\t\tmethod,\n\t\t\t\t\troute.path.map((p) => path.posix.join(pathString, pathToString(p))),\n\t\t\t\t\troute.handler,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Must be attached to \"interactionCreate\" event for RouteButtonBuilder to work\n\t *\n\t * @param interaction interactions from \"interactionCreate\" (filter for ButtonInteractions)\n\t */\n\tpublic async listener(\n\t\tinteraction: ButtonInteraction | AnySelectMenuInteraction,\n\t\tlocals?: L | undefined,\n\t) {\n\t\tconst res = decodePath({ idPrefix: this.getIdPrefix(), interaction });\n\t\tif (!res)\n\t\t\tthrow new Error(`Invalid component found: id ${interaction.customId}`);\n\n\t\tthis.dispatch({ interaction, method: res.method, path: res.path, locals });\n\t}\n\n\t/**\n\t * Replies to or editReplies to an interaction based on the route output\n\t *\n\t * @param interaction interaction to connect to\n\t * @param path path to route the interaction to\n\t * @param method method to send to route\n\t * @param flags discord flags to send with message (optional, only allowed on first reply)\n\t * @param locals additional info to pass in to page through state.local (optional)\n\t */\n\tpublic async dispatch<P extends Path = Path>({\n\t\tinteraction,\n\t\tmethod = \"GET\",\n\t\tpath,\n\t\tflags,\n\t\tlocals,\n\t}: {\n\t\tinteraction: Interaction;\n\t\tmethod?: Method;\n\t\tpath: P;\n\t\tflags?: InteractionReplyOptions[\"flags\"] | undefined;\n\t\tlocals?: L | undefined;\n\t}) {\n\t\tif (interaction.isAutocomplete())\n\t\t\tthrow new Error(\"Autocomplete Interactions aren't supported\");\n\n\t\t// don't check validity because url params are considered invalid\n\t\tconst routeResponse = await this.#resolve({\n\t\t\tinteraction,\n\t\t\tmethod,\n\t\t\tpath,\n\t\t\tlocals,\n\t\t});\n\t\tif (routeResponse === false)\n\t\t\tthrow new Error(`No route found for ${pathToString(path, false)}`);\n\n\t\tif (interaction.replied || interaction.deferred) {\n\t\t\tif (flags)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"You can only set flags for interactions that haven't been replied to\",\n\t\t\t\t);\n\t\t\tif (routeResponse) await interaction.editReply(routeResponse);\n\t\t} else if (!routeResponse) {\n\t\t\tif (\"deferUpdate\" in interaction) {\n\t\t\t\tawait interaction.deferUpdate();\n\t\t\t} else {\n\t\t\t\tawait interaction.deferReply();\n\t\t\t}\n\t\t} else if (\"update\" in interaction) {\n\t\t\tif (flags)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"You can only set flags for interactions that haven't been replied to\",\n\t\t\t\t);\n\t\t\tawait interaction.update(routeResponse);\n\t\t} else {\n\t\t\tinteraction.reply({\n\t\t\t\t...(routeResponse as InteractionReplyOptions),\n\t\t\t\tflags,\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Resolves a route to the associated message (DOES NOT UPDATE MESSAGE)\n\t *\n\t * @param interaction interaction to connect to\n\t * @param path path to route the interaction to\n\t * @param method method to send to route\n\t * @param locals additional info to pass in to page through state.local (optional)\n\t * @returns discord message associated with route OR false\n\t */\n\tasync #resolve<P extends Path>({\n\t\tinteraction,\n\t\tmethod = \"GET\",\n\t\tpath,\n\t\tlocals,\n\t}: {\n\t\tinteraction: Interaction;\n\t\tmethod?: Method;\n\t\tpath: P;\n\t\tlocals?: L | undefined;\n\t}): Promise<RouteResponse | false> {\n\t\t// don't check validity because url params are considered invalid\n\t\tconst url = new URL(pathToString(path, false), BASE_URL);\n\t\tfor (const route of this.#routes.get(method) ?? []) {\n\t\t\tconst result = route.matchFunction(url.pathname);\n\t\t\tif (result) {\n\t\t\t\treturn await route.handler(interaction, {\n\t\t\t\t\t...(result as MatchResult<ExtractParams<P>>),\n\t\t\t\t\tquery: url.searchParams,\n\t\t\t\t\tembedRouter: this,\n\t\t\t\t\tlocals,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n}\n","import { Method } from \"./types/routes\";\n\nexport const ID_PREFIX = \"der\";\nexport const METHOD_TO_ENCODING: Record<Method, string> = {\n\tGET: \"G\",\n\tPOST: \"P\",\n\tPUT: \"U\",\n\tPATCH: \"A\",\n\tDELETE: \"D\",\n};\nexport const ENCODING_TO_METHOD: Record<string, Method> = {\n\tG: \"GET\",\n\tP: \"POST\",\n\tU: \"PUT\",\n\tA: \"PATCH\",\n\tD: \"DELETE\",\n};\n// base url is never sent; only used for processing locally\nexport const BASE_URL = \"discord://embed.router\";\n\nexport const PUA_START = 0xe000;\nexport const PUA_END = 0xf8ff;\nexport const PUA_RANGE = PUA_END - PUA_START + 1;\n","import { parse, Path, stringify, TokenData } from \"path-to-regexp\";\n\nexport const pathToString = <P extends Path>(\n\tpath: P,\n\tcheckValidity = true,\n): string => {\n\tif (checkValidity) {\n\t\treturn stringify(path instanceof TokenData ? path : parse(path));\n\t}\n\treturn typeof path === \"string\" ? path : stringify(path);\n};\n","import { compile, Path } from \"path-to-regexp\";\nimport { AnySelectMenuInteraction, ButtonInteraction } from \"discord.js\";\nimport { BASE_URL, ENCODING_TO_METHOD } from \"../consts\";\nimport { Method } from \"../types/routes\";\n\nexport const decodePath = ({\n\tidPrefix,\n\tinteraction,\n}: {\n\tidPrefix: string;\n\tinteraction: ButtonInteraction | AnySelectMenuInteraction;\n}): { method: Method; path: Path } | false => {\n\tconst customId = interaction.customId;\n\tif (!customId.startsWith(idPrefix)) return false;\n\n\tif (interaction.isButton()) {\n\t\treturn parseMethodAndPath(customId.slice(idPrefix.length));\n\t} else if (interaction.isAnySelectMenu()) {\n\t\tif (interaction.values.length === 0) return false;\n\t\tconst res = parseMethodAndPath(customId.slice(idPrefix.length));\n\t\tif (!res) return false;\n\n\t\tconst { method, path } = res;\n\t\treturn {\n\t\t\tmethod,\n\t\t\tpath: fillParams(path, {\n\t\t\t\t[interaction.isStringSelectMenu()\n\t\t\t\t\t? \"to\"\n\t\t\t\t\t: interaction.isChannelSelectMenu()\n\t\t\t\t\t\t? \"channelId\"\n\t\t\t\t\t\t: interaction.isRoleSelectMenu()\n\t\t\t\t\t\t\t? \"roleId\"\n\t\t\t\t\t\t\t: \"userId\"]: interaction.values[0]!.split(\"/\").slice(1),\n\t\t\t}),\n\t\t};\n\t}\n\n\treturn false;\n};\n\nexport const parseMethodAndPath = (\n\tpathWithMethod: string,\n): { method: Method; path: string } | false => {\n\t// path always start with \"/\"\n\tconst firstSlash = pathWithMethod.indexOf(\"/\");\n\t// invalid customId\n\tif (firstSlash <= 0) return false;\n\n\tconst method = ENCODING_TO_METHOD[pathWithMethod.slice(0, firstSlash)];\n\tif (method === undefined) return false;\n\treturn {\n\t\tmethod,\n\t\tpath: pathWithMethod.slice(firstSlash),\n\t};\n};\n\nconst fillParams = (\n\tpath: string,\n\tparams: Partial<Record<string, string | string[]>> = {},\n): string => {\n\tconst url = new URL(path, BASE_URL);\n\tconst toPath = compile(url.pathname);\n\n\turl.pathname = toPath(params);\n\tfor (const [key, value] of url.searchParams) {\n\t\tif (value.startsWith(\":\") && key.slice(1) in params) {\n\t\t\tconst paramValue = params?.[key.slice(1)];\n\t\t\tif (paramValue) {\n\t\t\t\turl.searchParams.set(\n\t\t\t\t\tkey,\n\t\t\t\t\tArray.isArray(paramValue) ? paramValue.join(\"/\") : paramValue,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\turl.searchParams.delete(key);\n\t\t\t}\n\t\t}\n\t}\n\treturn `${url.pathname}${url.search}`;\n};\n","import { APIButtonComponent, ButtonBuilder } from \"discord.js\";\nimport { Path } from \"path-to-regexp\";\nimport { EmbedRouter } from \"../EmbedRouter\";\nimport { encodePath } from \"../helpers/encodePath\";\nimport { isSetOptions, SetOptions } from \"../types/componentBuilders\";\n\nexport class RouteButtonBuilder<L> extends ButtonBuilder {\n\t#embedRouter: EmbedRouter<L>;\n\n\t/**\n\t *\n\t * @param embedRouter the router you want to route with\n\t * @param data the data to construct a component out of\n\t */\n\tconstructor(\n\t\tembedRouter: EmbedRouter<L>,\n\t\tdata?: Omit<Partial<APIButtonComponent>, \"custom_id\" | \"url\"> | undefined,\n\t) {\n\t\tsuper(data);\n\n\t\tthis.#embedRouter = embedRouter;\n\t}\n\n\t/**\n\t * Not supported for RouteButtonBuilder\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride setURL(): this {\n\t\tthrow new Error(\"setURL is not supported on RouteButtonBuilder\");\n\t}\n\n\t/**\n\t * Not supported for RouteButtonBuilder (use setTo)\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride setCustomId(): this {\n\t\tthrow new Error(\"setCustomId is not supported on RouteButtonBuilder\");\n\t}\n\n\t/**\n\t * Sets the path to route to when clicked\n\t *\n\t * @param path the path to route to\n\t * @param query any query parameters you want to add\n\t * @param method method to send to route\n\t */\n\tpublic setTo<P extends Path>({ method, path, query }: SetOptions<P>): this;\n\t/**\n\t * Sets the path to route to when clicked\n\t *\n\t * @param path the path to route to\n\t */\n\tpublic setTo<P extends Path>(path: P): this;\n\n\tpublic setTo<P extends Path>(arg: P | SetOptions<P>) {\n\t\tconst {\n\t\t\tmethod = \"GET\",\n\t\t\tpath,\n\t\t\tquery,\n\t\t} = isSetOptions(arg) ? arg : { path: arg };\n\n\t\tsuper.setCustomId(\n\t\t\tencodePath({\n\t\t\t\tidPrefix: this.#embedRouter.getIdPrefix(),\n\t\t\t\tmethod,\n\t\t\t\tpath,\n\t\t\t\tquery,\n\t\t\t}),\n\t\t);\n\n\t\treturn this;\n\t}\n}\n","import { Path } from \"path-to-regexp\";\nimport { BASE_URL, METHOD_TO_ENCODING } from \"../consts\";\nimport { pathToString } from \"./pathToString\";\nimport { Method } from \"../types/routes\";\n\nexport const encodePath = ({\n\tidPrefix,\n\tmethod,\n\tpath,\n\tquery,\n}: {\n\tidPrefix: string;\n\tmethod: Method;\n\tpath: Path;\n\tquery?: ConstructorParameters<typeof URLSearchParams>[0] | undefined;\n}) => {\n\tconst url = new URL(pathToString(path), BASE_URL);\n\tif (query) {\n\t\tfor (const [key, value] of new URLSearchParams(query)) {\n\t\t\turl.searchParams.set(key, value);\n\t\t}\n\t}\n\treturn `${idPrefix}${METHOD_TO_ENCODING[method]}${url.pathname}${url.search}`;\n};\n","import { Path } from \"path-to-regexp\";\nimport { Method } from \"./routes\";\n\nexport type SetOptions<P extends Path> = {\n\tmethod?: Method;\n\tpath: P;\n\tquery?: ConstructorParameters<typeof URLSearchParams>[0] | undefined;\n};\n\nexport const isSetOptions = <P extends Path>(\n\tu: unknown,\n): u is SetOptions<P> => {\n\treturn (\n\t\ttypeof u === \"object\" &&\n\t\tu !== null &&\n\t\t(!(\"method\" in u) ||\n\t\t\t(\"method\" in u && typeof u.method === \"string\") ||\n\t\t\tu.method === undefined) &&\n\t\t\"path\" in u &&\n\t\ttypeof u.path === \"string\" &&\n\t\t(!(\"query\" in u) ||\n\t\t\t(\"query\" in u && [\"object\", \"string\"].includes(typeof u.query)) ||\n\t\t\tu.query === undefined)\n\t);\n};\n","import {\n\tAPIStringSelectComponent,\n\tnormalizeArray,\n\tRestOrArray,\n\tStringSelectMenuBuilder,\n\tStringSelectMenuComponentData,\n} from \"discord.js\";\nimport { Path } from \"path-to-regexp\";\nimport { RouteStringSelectMenuOptionBuilder } from \"./RouteStringMenuOptionBuilder\";\nimport { EmbedRouter } from \"../EmbedRouter\";\nimport { encodePath } from \"../helpers/encodePath\";\nimport { isSetOptions, SetOptions } from \"../types/componentBuilders\";\n\nexport class RouteStringSelectMenuBuilder<L> extends StringSelectMenuBuilder {\n\t#embedRouter: EmbedRouter<L>;\n\n\t/**\n\t *\n\t * @param embedRouter the router you want to route with\n\t * @param path the path to redirect to, :to or *to in path will be replaced with the selected user's id\n\t * @param query any query parameters you want to add, :to will be replaced with the selected user's id\n\t * @param data the data to construct a component out of\n\t */\n\tconstructor(\n\t\tembedRouter: EmbedRouter<L>,\n\t\tdata?:\n\t\t\t| Partial<StringSelectMenuComponentData | APIStringSelectComponent>\n\t\t\t| undefined,\n\t) {\n\t\tsuper(data);\n\n\t\tthis.#embedRouter = embedRouter;\n\n\t\tsuper.setCustomId(\n\t\t\tencodePath({\n\t\t\t\tidPrefix: this.#embedRouter.getIdPrefix(),\n\t\t\t\tmethod: \"GET\",\n\t\t\t\tpath: \"/*to\",\n\t\t\t}),\n\t\t);\n\t}\n\n\t/**\n\t * Not supported for RouteStringSelectMenuBuilder (customId set from embedRouter)\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride setCustomId(): this {\n\t\tthrow new Error(\n\t\t\t\"setCustomId is not supported on RouteStringSelectMenuBuilder\",\n\t\t);\n\t}\n\n\t/**\n\t * Not supported for RouteStringSelectMenuBuilder (use addTos)\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride addOptions(): this {\n\t\tthrow new Error(\n\t\t\t\"addOptions is not supported on RouteStringSelectMenuBuilder\",\n\t\t);\n\t}\n\n\t/**\n\t * Not supported for RouteStringSelectMenuBuilder (use setTos)\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride setOptions(): this {\n\t\tthrow new Error(\n\t\t\t\"setOptions is not supported on RouteStringSelectMenuBuilder\",\n\t\t);\n\t}\n\n\t/**\n\t * Adds route select menu options to builder\n\t *\n\t * @param tos the list of route select menu options\n\t */\n\tpublic addTos(\n\t\t...tos: RestOrArray<\n\t\t\t| RouteStringSelectMenuOptionBuilder\n\t\t\t| ConstructorParameters<typeof RouteStringSelectMenuOptionBuilder>[0]\n\t\t>\n\t): this {\n\t\tconst resolved = normalizeArray(tos);\n\t\tsuper.addOptions(\n\t\t\tresolved.map((o) =>\n\t\t\t\to instanceof RouteStringSelectMenuOptionBuilder\n\t\t\t\t\t? o\n\t\t\t\t\t: new RouteStringSelectMenuOptionBuilder(o),\n\t\t\t),\n\t\t);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets route select menu options to builder\n\t *\n\t * @param tos the list of route select menu options\n\t */\n\tpublic setTos(\n\t\t...tos: RestOrArray<\n\t\t\t| RouteStringSelectMenuOptionBuilder\n\t\t\t| ConstructorParameters<typeof RouteStringSelectMenuOptionBuilder>[0]\n\t\t>\n\t): this {\n\t\tconst resolved = normalizeArray(tos);\n\t\tsuper.setOptions(\n\t\t\tresolved.map((o) =>\n\t\t\t\to instanceof RouteStringSelectMenuOptionBuilder\n\t\t\t\t\t? o\n\t\t\t\t\t: new RouteStringSelectMenuOptionBuilder(o),\n\t\t\t),\n\t\t);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the pattern to redirect to (Required)\n\t *\n\t * @param path the path to redirect to, :to or *to in path will be replaced with the selected user's id\n\t * @param query any query parameters you want to add, :to will be replaced with the selected user's id\n\t * @param method method to send to route\n\t */\n\tpublic setPattern<P extends Path>({\n\t\tmethod,\n\t\tpath,\n\t\tquery,\n\t}: SetOptions<P>): this;\n\t/**\n\t * Sets the path to route to when clicked\n\t *\n\t * @param path the path to route to\n\t */\n\tpublic setPattern<P extends Path>(path: P): this;\n\n\tpublic setPattern<P extends Path>(arg: P | SetOptions<P>) {\n\t\tconst {\n\t\t\tmethod = \"GET\",\n\t\t\tpath,\n\t\t\tquery,\n\t\t} = isSetOptions(arg) ? arg : { path: arg };\n\t\tsuper.setCustomId(\n\t\t\tencodePath({\n\t\t\t\tidPrefix: this.#embedRouter.getIdPrefix(),\n\t\t\t\tmethod,\n\t\t\t\tpath,\n\t\t\t\tquery,\n\t\t\t}),\n\t\t);\n\n\t\treturn this;\n\t}\n}\n","import { StringSelectMenuOptionBuilder } from \"discord.js\";\nimport { Path } from \"path-to-regexp\";\nimport { encodePath } from \"../helpers/encodePath\";\nimport { isSetOptions, SetOptions } from \"../types/componentBuilders\";\n\nexport class RouteStringSelectMenuOptionBuilder extends StringSelectMenuOptionBuilder {\n\t/**\n\t * Not supported for RouteStringSelectMenuOptionBuilder (use setTo)\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride setValue(): this {\n\t\tthrow new Error(\n\t\t\t\"setValue is not supported on RouteStringSelectMenuOptionBuilder\",\n\t\t);\n\t}\n\n\t/**\n\t * Sets the path to route to when clicked\n\t *\n\t * @param path the path to route to\n\t * @param query any query parameters you want to add\n\t * @param method method to send to route\n\t */\n\tpublic setTo<P extends Path>({ method, path, query }: SetOptions<P>): this;\n\t/**\n\t * Sets the path to route to when clicked\n\t *\n\t * @param path the path to route to\n\t */\n\tpublic setTo<P extends Path>(path: P): this;\n\n\tpublic setTo<P extends Path>(arg: P | SetOptions<P>) {\n\t\tconst {\n\t\t\tmethod = \"GET\",\n\t\t\tpath,\n\t\t\tquery,\n\t\t} = isSetOptions(arg) ? arg : { path: arg };\n\t\tsuper.setValue(\n\t\t\tencodePath({\n\t\t\t\tidPrefix: \"\",\n\t\t\t\tmethod,\n\t\t\t\tpath,\n\t\t\t\tquery,\n\t\t\t}),\n\t\t);\n\n\t\treturn this;\n\t}\n}\n","import {\n\tAPIChannelSelectComponent,\n\tChannelSelectMenuBuilder,\n\tChannelSelectMenuComponentData,\n} from \"discord.js\";\nimport { EmbedRouter } from \"../EmbedRouter\";\nimport { Path } from \"path-to-regexp\";\nimport { encodePath } from \"../helpers/encodePath\";\nimport { isSetOptions, SetOptions } from \"../types/componentBuilders\";\n\nexport class RouteChannelSelectMenuBuilder<L> extends ChannelSelectMenuBuilder {\n\t#embedRouter: EmbedRouter<L>;\n\n\t/**\n\t *\n\t * @param embedRouter the router you want to route with\n\t * @param data the data to construct a component out of\n\t */\n\tconstructor(\n\t\tembedRouter: EmbedRouter<L>,\n\t\tdata?:\n\t\t\t| Partial<ChannelSelectMenuComponentData | APIChannelSelectComponent>\n\t\t\t| undefined,\n\t) {\n\t\tsuper(data);\n\n\t\tthis.#embedRouter = embedRouter;\n\t}\n\n\t/**\n\t * Not supported for RouteChannelSelectMenuBuilder (customId set from embedRouter)\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride setCustomId(): this {\n\t\tthrow new Error(\n\t\t\t\"setCustomId is not supported on RouteChannelSelectMenuBuilder\",\n\t\t);\n\t}\n\n\t/**\n\t * Sets the pattern to redirect to (Required)\n\t *\n\t * @param path the path to redirect to, :channelId in path will be replaced with the selected user's id\n\t * @param query any query parameters you want to add, :channelId will be replaced with the selected user's id\n\t * @param method method to send to route\n\t */\n\tpublic setPattern<P extends Path>({\n\t\tmethod,\n\t\tpath,\n\t\tquery,\n\t}: SetOptions<P>): this;\n\t/**\n\t * Sets the path to route to when clicked\n\t *\n\t * @param path the path to route to\n\t */\n\tpublic setPattern<P extends Path>(path: P): this;\n\n\tpublic setPattern<P extends Path>(arg: P | SetOptions<P>) {\n\t\tconst {\n\t\t\tmethod = \"GET\",\n\t\t\tpath,\n\t\t\tquery,\n\t\t} = isSetOptions(arg) ? arg : { path: arg };\n\t\tsuper.setCustomId(\n\t\t\tencodePath({\n\t\t\t\tidPrefix: this.#embedRouter.getIdPrefix(),\n\t\t\t\tmethod,\n\t\t\t\tpath,\n\t\t\t\tquery,\n\t\t\t}),\n\t\t);\n\n\t\treturn this;\n\t}\n}\n","import {\n\tAPIRoleSelectComponent,\n\tRoleSelectMenuBuilder,\n\tRoleSelectMenuComponentData,\n} from \"discord.js\";\nimport { EmbedRouter } from \"../EmbedRouter\";\nimport { Path } from \"path-to-regexp\";\nimport { encodePath } from \"../helpers/encodePath\";\nimport { isSetOptions, SetOptions } from \"../types/componentBuilders\";\n\nexport class RouteRoleSelectMenuBuilder<L> extends RoleSelectMenuBuilder {\n\t#embedRouter: EmbedRouter<L>;\n\n\t/**\n\t *\n\t * @param embedRouter the router you want to route with\n\t * @param data the data to construct a component out of\n\t */\n\tconstructor(\n\t\tembedRouter: EmbedRouter<L>,\n\t\tdata?:\n\t\t\tPartial<RoleSelectMenuComponentData | APIRoleSelectComponent> | undefined,\n\t) {\n\t\tsuper(data);\n\n\t\tthis.#embedRouter = embedRouter;\n\t}\n\n\t/**\n\t * Not supported for RouteRoleSelectMenuBuilder (customId set from embedRouter)\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride setCustomId(): this {\n\t\tthrow new Error(\n\t\t\t\"setCustomId is not supported on RouteRoleSelectMenuBuilder\",\n\t\t);\n\t}\n\n\t/**\n\t * Sets the pattern to redirect to (Required)\n\t *\n\t * @param path the path to redirect to, :roleId in path will be replaced with the selected user's id\n\t * @param query any query parameters you want to add, :roleId will be replaced with the selected user's id\n\t * @param method method to send to route\n\t */\n\tpublic setPattern<P extends Path>({\n\t\tmethod,\n\t\tpath,\n\t\tquery,\n\t}: SetOptions<P>): this;\n\t/**\n\t * Sets the path to route to when clicked\n\t *\n\t * @param path the path to route to\n\t */\n\tpublic setPattern<P extends Path>(path: P): this;\n\n\tpublic setPattern<P extends Path>(arg: P | SetOptions<P>) {\n\t\tconst {\n\t\t\tmethod = \"GET\",\n\t\t\tpath,\n\t\t\tquery,\n\t\t} = isSetOptions(arg) ? arg : { path: arg };\n\t\tsuper.setCustomId(\n\t\t\tencodePath({\n\t\t\t\tidPrefix: this.#embedRouter.getIdPrefix(),\n\t\t\t\tmethod,\n\t\t\t\tpath,\n\t\t\t\tquery,\n\t\t\t}),\n\t\t);\n\n\t\treturn this;\n\t}\n}\n","import {\n\tAPIUserSelectComponent,\n\tUserSelectMenuBuilder,\n\tUserSelectMenuComponentData,\n} from \"discord.js\";\nimport { EmbedRouter } from \"../EmbedRouter\";\nimport { Path } from \"path-to-regexp\";\nimport { encodePath } from \"../helpers/encodePath\";\nimport { isSetOptions, SetOptions } from \"../types/componentBuilders\";\n\nexport class RouteUserSelectMenuBuilder<L> extends UserSelectMenuBuilder {\n\t#embedRouter: EmbedRouter<L>;\n\n\t/**\n\t *\n\t * @param embedRouter the router you want to route with\n\t * @param data the data to construct a component out of\n\t */\n\tconstructor(\n\t\tembedRouter: EmbedRouter<L>,\n\t\tdata?:\n\t\t\tPartial<UserSelectMenuComponentData | APIUserSelectComponent> | undefined,\n\t) {\n\t\tsuper(data);\n\n\t\tthis.#embedRouter = embedRouter;\n\t}\n\n\t/**\n\t * Not supported for RouteUserSelectMenuBuilder (customId set from embedRouter)\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride setCustomId(): this {\n\t\tthrow new Error(\n\t\t\t\"setCustomId is not supported on RouteUserSelectMenuBuilder\",\n\t\t);\n\t}\n\n\t/**\n\t * Sets the pattern to redirect to (Required)\n\t *\n\t * @param path the path to redirect to, :userId in path will be replaced with the selected user's id\n\t * @param query any query parameters you want to add, :userId will be replaced with the selected user's id\n\t * @param method method to send to route\n\t */\n\tpublic setPattern<P extends Path>({\n\t\tmethod,\n\t\tpath,\n\t\tquery,\n\t}: SetOptions<P>): this;\n\t/**\n\t * Sets the path to route to when clicked\n\t *\n\t * @param path the path to route to\n\t */\n\tpublic setPattern<P extends Path>(path: P): this;\n\n\tpublic setPattern<P extends Path>(arg: P | SetOptions<P>) {\n\t\tconst {\n\t\t\tmethod = \"GET\",\n\t\t\tpath,\n\t\t\tquery,\n\t\t} = isSetOptions(arg) ? arg : { path: arg };\n\t\tsuper.setCustomId(\n\t\t\tencodePath({\n\t\t\t\tidPrefix: this.#embedRouter.getIdPrefix(),\n\t\t\t\tmethod,\n\t\t\t\tpath,\n\t\t\t\tquery,\n\t\t\t}),\n\t\t);\n\n\t\treturn this;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,uBAAiB;AACjB,yBAA2B;AAC3B,IAAAA,yBAAyC;;;ACAlC,IAAM,YAAY;AAClB,IAAM,qBAA6C;AAAA,EACzD,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,QAAQ;AACT;AACO,IAAM,qBAA6C;AAAA,EACzD,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACJ;AAEO,IAAM,WAAW;AAEjB,IAAM,YAAY;AAClB,IAAM,UAAU;AAChB,IAAM,YAAY,UAAU,YAAY;;;ACtB/C,4BAAkD;AAE3C,IAAM,eAAe,CAC3BC,OACA,gBAAgB,SACJ;AACZ,MAAI,eAAe;AAClB,eAAO,iCAAUA,iBAAgB,kCAAYA,YAAO,6BAAMA,KAAI,CAAC;AAAA,EAChE;AACA,SAAO,OAAOA,UAAS,WAAWA,YAAO,iCAAUA,KAAI;AACxD;;;ACVA,IAAAC,yBAA8B;AAKvB,IAAM,aAAa,CAAC;AAAA,EAC1B;AAAA,EACA;AACD,MAG8C;AAC7C,QAAM,WAAW,YAAY;AAC7B,MAAI,CAAC,SAAS,WAAW,QAAQ,EAAG,QAAO;AAE3C,MAAI,YAAY,SAAS,GAAG;AAC3B,WAAO,mBAAmB,S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ACL,WAAW;AAAA,QACV,UAAU,KAAK,aAAa,YAAY;AAAA,QACxC;AAAA,QACA,MAAAA;AAAA,QACA;AAAA,MACD,CAAC;AAAA,IACF;AAEA,WAAO;AAAA,EACR;AACD;;;AC5EA,IAAAC,kBAIO;AAMA,IAAM,6BAAN,cAA4C,sCAAsB;AAAA,EACxE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,YACC,aACA,MAEC;AACD,UAAM,IAAI;AAEV,SAAK,eAAe;AAAA,EACrB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQS,cAAoB;AAC5B,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AAAA,EAqBO,WAA2B,KAAwB;AACzD,UAAM;AAAA,MACL,SAAS;AAAA,MACT,MAAAC;AAAA,MACA;AAAA,IACD,IAAI,aAAa,GAAG,IAAI,MAAM,EAAE,MAAM,IAAI;AAC1C,UAAM;AAAA,MACL,WAAW;AAAA,QACV,UAAU,KAAK,aAAa,YAAY;AAAA,QACxC;AAAA,QACA,MAAAA;AAAA,QACA;AAAA,MACD,CAAC;AAAA,IACF;AAEA,WAAO;AAAA,EACR;AACD;","names":["import_path_to_regexp","path","import_path_to_regexp","path","path","path","path","import_discord","import_discord","path","path","import_discord","path","import_discord","path","import_discord","path"]}
package/dist/index.mjs CHANGED
@@ -230,12 +230,13 @@ var EmbedRouter = class _EmbedRouter {
230
230
  this.dispatch({ interaction, method: res.method, path: res.path, locals });
231
231
  }
232
232
  /**
233
- * Connect or update an interaction message to a path
233
+ * Replies to or editReplies to an interaction based on the route output
234
234
  *
235
235
  * @param interaction interaction to connect to
236
236
  * @param path path to route the interaction to
237
237
  * @param method method to send to route
238
- * @param flags optional discord flags to send with message (only allowed on first reply)
238
+ * @param flags discord flags to send with message (optional, only allowed on first reply)
239
+ * @param locals additional info to pass in to page through state.local (optional)
239
240
  */
240
241
  async dispatch({
241
242
  interaction,
@@ -246,19 +247,26 @@ var EmbedRouter = class _EmbedRouter {
246
247
  }) {
247
248
  if (interaction.isAutocomplete())
248
249
  throw new Error("Autocomplete Interactions aren't supported");
249
- const resolvedRoute = this.#resolve(method, pathToString(path2, false));
250
- if (!resolvedRoute)
251
- throw new Error(`No route found for ${pathToString(path2, false)}`);
252
- const routeResponse = await resolvedRoute.handler(interaction, {
253
- ...resolvedRoute.state,
250
+ const routeResponse = await this.#resolve({
251
+ interaction,
252
+ method,
253
+ path: path2,
254
254
  locals
255
255
  });
256
+ if (routeResponse === false)
257
+ throw new Error(`No route found for ${pathToString(path2, false)}`);
256
258
  if (interaction.replied || interaction.deferred) {
257
259
  if (flags)
258
260
  throw new Error(
259
261
  "You can only set flags for interactions that haven't been replied to"
260
262
  );
261
- await interaction.editReply(routeResponse);
263
+ if (routeResponse) await interaction.editReply(routeResponse);
264
+ } else if (!routeResponse) {
265
+ if ("deferUpdate" in interaction) {
266
+ await interaction.deferUpdate();
267
+ } else {
268
+ await interaction.deferReply();
269
+ }
262
270
  } else if ("update" in interaction) {
263
271
  if (flags)
264
272
  throw new Error(
@@ -272,19 +280,31 @@ var EmbedRouter = class _EmbedRouter {
272
280
  });
273
281
  }
274
282
  }
275
- #resolve(method, routePath) {
276
- const url = new URL(routePath, BASE_URL);
283
+ /**
284
+ * Resolves a route to the associated message (DOES NOT UPDATE MESSAGE)
285
+ *
286
+ * @param interaction interaction to connect to
287
+ * @param path path to route the interaction to
288
+ * @param method method to send to route
289
+ * @param locals additional info to pass in to page through state.local (optional)
290
+ * @returns discord message associated with route OR false
291
+ */
292
+ async #resolve({
293
+ interaction,
294
+ method = "GET",
295
+ path: path2,
296
+ locals
297
+ }) {
298
+ const url = new URL(pathToString(path2, false), BASE_URL);
277
299
  for (const route of this.#routes.get(method) ?? []) {
278
300
  const result = route.matchFunction(url.pathname);
279
301
  if (result) {
280
- return {
281
- state: {
282
- ...result,
283
- query: url.searchParams,
284
- embedRouter: this
285
- },
286
- handler: route.handler
287
- };
302
+ return await route.handler(interaction, {
303
+ ...result,
304
+ query: url.searchParams,
305
+ embedRouter: this,
306
+ locals
307
+ });
288
308
  }
289
309
  }
290
310
  return false;
@@ -312,7 +332,7 @@ var encodePath = ({
312
332
 
313
333
  // src/types/componentBuilders.ts
314
334
  var isSetOptions = (u) => {
315
- return typeof u === "object" && u !== null && (!("method" in u) || "method" in u && typeof u.method === "string" || u.method === void 0) && "path" in u && typeof u.path === "string" && (!("query" in u) || "query" in u && typeof u.query in ["object", "string"] || u.query === void 0);
335
+ return typeof u === "object" && u !== null && (!("method" in u) || "method" in u && typeof u.method === "string" || u.method === void 0) && "path" in u && typeof u.path === "string" && (!("query" in u) || "query" in u && ["object", "string"].includes(typeof u.query) || u.query === void 0);
316
336
  };
317
337
 
318
338
  // src/componentBuilders/RouteButtonBuilder.ts
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/EmbedRouter.ts","../src/consts.ts","../src/helpers/pathToString.ts","../src/helpers/decodePath.ts","../src/componentBuilders/RouteButtonBuilder.ts","../src/helpers/encodePath.ts","../src/types/componentBuilders.ts","../src/componentBuilders/RouteStringSelectMenuBuilder.ts","../src/componentBuilders/RouteStringMenuOptionBuilder.ts","../src/componentBuilders/RouteChannelSelectMenuBuilder.ts","../src/componentBuilders/RouteRoleSelectMenuBuilder.ts","../src/componentBuilders/RouteUserSelectMenuBuilder.ts"],"sourcesContent":["import path from \"node:path\";\nimport { createHash } from \"node:crypto\";\nimport { match, Path } from \"path-to-regexp\";\nimport type {\n\tCompiledRoute,\n\tMethod,\n\tResolvedRoute,\n\tRouteHandler,\n\tState,\n} from \"./types/routes\";\nimport type { ExtractParams } from \"./types/ExtractParams\";\nimport {\n\tAnySelectMenuInteraction,\n\tButtonInteraction,\n\tInteraction,\n\tInteractionReplyOptions,\n} from \"discord.js\";\nimport { BASE_URL, ID_PREFIX, PUA_RANGE, PUA_START } from \"./consts\";\nimport { pathToString } from \"./helpers/pathToString\";\nimport { decodePath } from \"./helpers/decodePath\";\n\nexport class EmbedRouter<L> {\n\t// identifier -> embedRouter\n\tstatic #usedIdentifiers = new Map<string, EmbedRouter<unknown>>();\n\n\t// Name used to generate prefixes\n\t#name = \"\";\n\t// Prefix for customIds of RouteButtonBuilders\n\t#idPrefix: string;\n\t#identifier: string = \"\";\n\tpublic getIdPrefix() {\n\t\treturn `${this.#idPrefix}${this.#identifier}`;\n\t}\n\n\t// All added routes\n\t#routes: Map<Method, CompiledRoute<L>[]> = new Map();\n\n\t/**\n\t *\n\t * @param name the name to give the router. ensures buttons stay connected across restarts\n\t * @param idPrefix the prefix for RouteButtonBuilder customIds\n\t */\n\tconstructor({\n\t\tname = \"\",\n\t\tidPrefix = ID_PREFIX,\n\t}: {\n\t\tname?: string | undefined;\n\t\tidPrefix?: string | undefined;\n\t} = {}) {\n\t\tif (EmbedRouter.#usedIdentifiers.size >= PUA_RANGE) {\n\t\t\tthrow new Error(`You can not have more than ${PUA_RANGE} routers`);\n\t\t}\n\t\tif (idPrefix.includes(\"/\")) {\n\t\t\tthrow new Error(`Prefix can't contain \"/\": ${idPrefix}`);\n\t\t}\n\t\tthis.#idPrefix = idPrefix;\n\t\tthis.#name = name;\n\t\tthis.#updateIdentifier();\n\t}\n\n\t#updateIdentifier() {\n\t\t// Private Use Area: Unicode Characters not from any language\n\t\tconst hash = createHash(\"sha256\").update(this.#name).digest();\n\t\tlet raw = hash.readUint32BE(0);\n\t\tlet char: string;\n\t\tconst nameCollisions = [];\n\t\t// find next available identifier\n\t\twhile (true) {\n\t\t\tconst codepoint = PUA_START + (raw++ % PUA_RANGE);\n\t\t\tchar = String.fromCodePoint(codepoint);\n\n\t\t\tconst collisionRouter = EmbedRouter.#usedIdentifiers.get(char);\n\t\t\tif (collisionRouter === undefined) break; // no collisions\n\n\t\t\tif (this.#name.length > 0 && collisionRouter.#name.length === 0) {\n\t\t\t\t// evict old name; usedIdentifier is still taken\n\t\t\t\tcollisionRouter.#updateIdentifier();\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tnameCollisions.push(collisionRouter);\n\t\t}\n\t\tEmbedRouter.#usedIdentifiers.set(char, this as EmbedRouter<unknown>);\n\n\t\tif (nameCollisions.length > 0 && this.#name.length > 0) {\n\t\t\tprocess.emitWarning(\n\t\t\t\t`EmbedRouter identifier collision for name \"${this.#name}\" with ${nameCollisions.map((c) => `\"${c.#name}\"`).join(\", \")}`,\n\t\t\t\t\"EmbedRouterWarning\",\n\t\t\t);\n\t\t}\n\t\tthis.#identifier = char;\n\t}\n\n\t#addRoute<P extends Path = Path>(\n\t\tmethod: Method,\n\t\troutePath: P | P[],\n\t\thandler: RouteHandler<L, ExtractParams<P>>,\n\t) {\n\t\tconst methodRoutes = this.#routes.get(method) ?? [];\n\t\tmethodRoutes.push({\n\t\t\tmethod,\n\t\t\tpath: Array.isArray(routePath) ? routePath : [routePath],\n\t\t\tmatchFunction: match(routePath),\n\t\t\thandler: handler as RouteHandler<L>,\n\t\t});\n\t\tthis.#routes.set(method, methodRoutes);\n\t}\n\n\t/**\n\t * Registers a path with the router\n\t *\n\t * @param routePath path to match with\n\t * @param handler function that generates the message when a path is matched\n\t */\n\tpublic get<P extends Path = Path>(\n\t\troutePath: P | P[],\n\t\thandler: RouteHandler<L, ExtractParams<P>>,\n\t) {\n\t\tthis.#addRoute(\"GET\", routePath, handler);\n\t}\n\n\t/**\n\t * Registers a path with the router\n\t *\n\t * @param routePath path to match with\n\t * @param handler function that generates the message when a path is matched\n\t */\n\tpublic post<P extends Path = Path>(\n\t\troutePath: P | P[],\n\t\thandler: RouteHandler<L, ExtractParams<P>>,\n\t) {\n\t\tthis.#addRoute(\"POST\", routePath, handler);\n\t}\n\n\t/**\n\t * Registers a path with the router\n\t *\n\t * @param routePath path to match with\n\t * @param handler function that generates the message when a path is matched\n\t */\n\tpublic put<P extends Path = Path>(\n\t\troutePath: P | P[],\n\t\thandler: RouteHandler<L, ExtractParams<P>>,\n\t) {\n\t\tthis.#addRoute(\"PUT\", routePath, handler);\n\t}\n\n\t/**\n\t * Registers a path with the router\n\t *\n\t * @param routePath path to match with\n\t * @param handler function that generates the message when a path is matched\n\t */\n\tpublic patch<P extends Path = Path>(\n\t\troutePath: P | P[],\n\t\thandler: RouteHandler<L, ExtractParams<P>>,\n\t) {\n\t\tthis.#addRoute(\"PATCH\", routePath, handler);\n\t}\n\n\t/**\n\t * Registers a path with the router\n\t *\n\t * @param routePath path to match with\n\t * @param handler function that generates the message when a path is matched\n\t */\n\tpublic delete<P extends Path = Path>(\n\t\troutePath: P | P[],\n\t\thandler: RouteHandler<L, ExtractParams<P>>,\n\t) {\n\t\tthis.#addRoute(\"DELETE\", routePath, handler);\n\t}\n\n\t/**\n\t * Adds a subrouter to the router\n\t *\n\t * @param routePath path of the router\n\t * @param embedRouter router to add at the path\n\t */\n\tpublic use<P extends Path = Path>(routePath: P, embedRouter: EmbedRouter<L>) {\n\t\tconst pathString = pathToString(routePath);\n\t\tfor (const [method, routes] of embedRouter.#routes) {\n\t\t\tfor (const route of routes) {\n\t\t\t\tthis.#addRoute(\n\t\t\t\t\tmethod,\n\t\t\t\t\troute.path.map((p) => path.posix.join(pathString, pathToString(p))),\n\t\t\t\t\troute.handler,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Must be attached to \"interactionCreate\" event for RouteButtonBuilder to work\n\t *\n\t * @param interaction interactions from \"interactionCreate\" (filter for ButtonInteractions)\n\t */\n\tpublic async listener(\n\t\tinteraction: ButtonInteraction | AnySelectMenuInteraction,\n\t\tlocals?: L | undefined,\n\t) {\n\t\tconst res = decodePath({ idPrefix: this.getIdPrefix(), interaction });\n\t\tif (!res)\n\t\t\tthrow new Error(`Invalid component found: id ${interaction.customId}`);\n\n\t\tthis.dispatch({ interaction, method: res.method, path: res.path, locals });\n\t}\n\n\t/**\n\t * Connect or update an interaction message to a path\n\t *\n\t * @param interaction interaction to connect to\n\t * @param path path to route the interaction to\n\t * @param method method to send to route\n\t * @param flags optional discord flags to send with message (only allowed on first reply)\n\t */\n\tpublic async dispatch<P extends Path = Path>({\n\t\tinteraction,\n\t\tmethod = \"GET\",\n\t\tpath,\n\t\tflags,\n\t\tlocals,\n\t}: {\n\t\tinteraction: Interaction;\n\t\tmethod?: Method;\n\t\tpath: P;\n\t\tflags?: InteractionReplyOptions[\"flags\"] | undefined;\n\t\tlocals?: L | undefined;\n\t}) {\n\t\tif (interaction.isAutocomplete())\n\t\t\tthrow new Error(\"Autocomplete Interactions aren't supported\");\n\n\t\t// don't check validity because url params are considered invalid\n\t\tconst resolvedRoute = this.#resolve(method, pathToString(path, false));\n\t\tif (!resolvedRoute)\n\t\t\tthrow new Error(`No route found for ${pathToString(path, false)}`);\n\n\t\tconst routeResponse = await resolvedRoute.handler(interaction, {\n\t\t\t...resolvedRoute.state,\n\t\t\tlocals,\n\t\t});\n\n\t\tif (interaction.replied || interaction.deferred) {\n\t\t\tif (flags)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"You can only set flags for interactions that haven't been replied to\",\n\t\t\t\t);\n\t\t\tawait interaction.editReply(routeResponse);\n\t\t} else if (\"update\" in interaction) {\n\t\t\tif (flags)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"You can only set flags for interactions that haven't been replied to\",\n\t\t\t\t);\n\t\t\tawait interaction.update(routeResponse);\n\t\t} else {\n\t\t\tinteraction.reply({\n\t\t\t\t...(routeResponse as InteractionReplyOptions),\n\t\t\t\tflags,\n\t\t\t});\n\t\t}\n\t}\n\n\t#resolve<P extends string>(\n\t\tmethod: Method,\n\t\troutePath: P,\n\t): ResolvedRoute<L, ExtractParams<P>> | false {\n\t\tconst url = new URL(routePath, BASE_URL);\n\t\tfor (const route of this.#routes.get(method) ?? []) {\n\t\t\tconst result = route.matchFunction(url.pathname);\n\t\t\tif (result) {\n\t\t\t\treturn {\n\t\t\t\t\tstate: {\n\t\t\t\t\t\t...(result as State<L, ExtractParams<P>>),\n\t\t\t\t\t\tquery: url.searchParams,\n\t\t\t\t\t\tembedRouter: this,\n\t\t\t\t\t},\n\t\t\t\t\thandler: route.handler,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n}\n","import { Method } from \"./types/routes\";\n\nexport const ID_PREFIX = \"der\";\nexport const METHOD_TO_ENCODING: Record<Method, string> = {\n\tGET: \"G\",\n\tPOST: \"P\",\n\tPUT: \"U\",\n\tPATCH: \"A\",\n\tDELETE: \"D\",\n};\nexport const ENCODING_TO_METHOD: Record<string, Method> = {\n\tG: \"GET\",\n\tP: \"POST\",\n\tU: \"PUT\",\n\tA: \"PATCH\",\n\tD: \"DELETE\",\n};\n// base url is never sent; only used for processing locally\nexport const BASE_URL = \"discord://embed.router\";\n\nexport const PUA_START = 0xe000;\nexport const PUA_END = 0xf8ff;\nexport const PUA_RANGE = PUA_END - PUA_START + 1;\n","import { parse, Path, stringify, TokenData } from \"path-to-regexp\";\n\nexport const pathToString = <P extends Path>(\n\tpath: P,\n\tcheckValidity = true,\n): string => {\n\tif (checkValidity) {\n\t\treturn stringify(path instanceof TokenData ? path : parse(path));\n\t}\n\treturn typeof path === \"string\" ? path : stringify(path);\n};\n","import { compile, Path } from \"path-to-regexp\";\nimport { AnySelectMenuInteraction, ButtonInteraction } from \"discord.js\";\nimport { BASE_URL, ENCODING_TO_METHOD } from \"../consts\";\nimport { Method } from \"../types/routes\";\n\nexport const decodePath = ({\n\tidPrefix,\n\tinteraction,\n}: {\n\tidPrefix: string;\n\tinteraction: ButtonInteraction | AnySelectMenuInteraction;\n}): { method: Method; path: Path } | false => {\n\tconst customId = interaction.customId;\n\tif (!customId.startsWith(idPrefix)) return false;\n\n\tif (interaction.isButton()) {\n\t\treturn parseMethodAndPath(customId.slice(idPrefix.length));\n\t} else if (interaction.isAnySelectMenu()) {\n\t\tif (interaction.values.length === 0) return false;\n\t\tconst res = parseMethodAndPath(customId.slice(idPrefix.length));\n\t\tif (!res) return false;\n\n\t\tconst { method, path } = res;\n\t\treturn {\n\t\t\tmethod,\n\t\t\tpath: fillParams(path, {\n\t\t\t\t[interaction.isStringSelectMenu()\n\t\t\t\t\t? \"to\"\n\t\t\t\t\t: interaction.isChannelSelectMenu()\n\t\t\t\t\t\t? \"channelId\"\n\t\t\t\t\t\t: interaction.isRoleSelectMenu()\n\t\t\t\t\t\t\t? \"roleId\"\n\t\t\t\t\t\t\t: \"userId\"]: interaction.values[0]!.split(\"/\").slice(1),\n\t\t\t}),\n\t\t};\n\t}\n\n\treturn false;\n};\n\nexport const parseMethodAndPath = (\n\tpathWithMethod: string,\n): { method: Method; path: string } | false => {\n\t// path always start with \"/\"\n\tconst firstSlash = pathWithMethod.indexOf(\"/\");\n\t// invalid customId\n\tif (firstSlash <= 0) return false;\n\n\tconst method = ENCODING_TO_METHOD[pathWithMethod.slice(0, firstSlash)];\n\tif (method === undefined) return false;\n\treturn {\n\t\tmethod,\n\t\tpath: pathWithMethod.slice(firstSlash),\n\t};\n};\n\nconst fillParams = (\n\tpath: string,\n\tparams: Partial<Record<string, string | string[]>> = {},\n): string => {\n\tconst url = new URL(path, BASE_URL);\n\tconst toPath = compile(url.pathname);\n\n\turl.pathname = toPath(params);\n\tfor (const [key, value] of url.searchParams) {\n\t\tif (value.startsWith(\":\") && key.slice(1) in params) {\n\t\t\tconst paramValue = params?.[key.slice(1)];\n\t\t\tif (paramValue) {\n\t\t\t\turl.searchParams.set(\n\t\t\t\t\tkey,\n\t\t\t\t\tArray.isArray(paramValue) ? paramValue.join(\"/\") : paramValue,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\turl.searchParams.delete(key);\n\t\t\t}\n\t\t}\n\t}\n\treturn `${url.pathname}${url.search}`;\n};\n","import { APIButtonComponent, ButtonBuilder } from \"discord.js\";\nimport { Path } from \"path-to-regexp\";\nimport { EmbedRouter } from \"../EmbedRouter\";\nimport { encodePath } from \"../helpers/encodePath\";\nimport { isSetOptions, SetOptions } from \"../types/componentBuilders\";\n\nexport class RouteButtonBuilder<L> extends ButtonBuilder {\n\t#embedRouter: EmbedRouter<L>;\n\n\t/**\n\t *\n\t * @param embedRouter the router you want to route with\n\t * @param data the data to construct a component out of\n\t */\n\tconstructor(\n\t\tembedRouter: EmbedRouter<L>,\n\t\tdata?: Omit<Partial<APIButtonComponent>, \"custom_id\" | \"url\"> | undefined,\n\t) {\n\t\tsuper(data);\n\n\t\tthis.#embedRouter = embedRouter;\n\t}\n\n\t/**\n\t * Not supported for RouteButtonBuilder\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride setURL(): this {\n\t\tthrow new Error(\"setURL is not supported on RouteButtonBuilder\");\n\t}\n\n\t/**\n\t * Not supported for RouteButtonBuilder (use setTo)\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride setCustomId(): this {\n\t\tthrow new Error(\"setCustomId is not supported on RouteButtonBuilder\");\n\t}\n\n\t/**\n\t * Sets the path to route to when clicked\n\t *\n\t * @param path the path to route to\n\t * @param query any query parameters you want to add\n\t * @param method method to send to route\n\t */\n\tpublic setTo<P extends Path>({ method, path, query }: SetOptions<P>): this;\n\t/**\n\t * Sets the path to route to when clicked\n\t *\n\t * @param path the path to route to\n\t */\n\tpublic setTo<P extends Path>(path: P): this;\n\n\tpublic setTo<P extends Path>(arg: P | SetOptions<P>) {\n\t\tconst {\n\t\t\tmethod = \"GET\",\n\t\t\tpath,\n\t\t\tquery,\n\t\t} = isSetOptions(arg) ? arg : { path: arg };\n\t\tsuper.setCustomId(\n\t\t\tencodePath({\n\t\t\t\tidPrefix: this.#embedRouter.getIdPrefix(),\n\t\t\t\tmethod,\n\t\t\t\tpath,\n\t\t\t\tquery,\n\t\t\t}),\n\t\t);\n\n\t\treturn this;\n\t}\n}\n","import { Path } from \"path-to-regexp\";\nimport { BASE_URL, METHOD_TO_ENCODING } from \"../consts\";\nimport { pathToString } from \"./pathToString\";\nimport { Method } from \"../types/routes\";\n\nexport const encodePath = ({\n\tidPrefix,\n\tmethod,\n\tpath,\n\tquery,\n}: {\n\tidPrefix: string;\n\tmethod: Method;\n\tpath: Path;\n\tquery?: ConstructorParameters<typeof URLSearchParams>[0] | undefined;\n}) => {\n\tconst url = new URL(pathToString(path), BASE_URL);\n\tif (query) {\n\t\tfor (const [key, value] of new URLSearchParams(query)) {\n\t\t\turl.searchParams.set(key, value);\n\t\t}\n\t}\n\treturn `${idPrefix}${METHOD_TO_ENCODING[method]}${url.pathname}${url.search}`;\n};\n","import { Path } from \"path-to-regexp\";\nimport { Method } from \"./routes\";\n\nexport type SetOptions<P extends Path> = {\n\tmethod?: Method;\n\tpath: P;\n\tquery?: ConstructorParameters<typeof URLSearchParams>[0] | undefined;\n};\n\nexport const isSetOptions = <P extends Path>(\n\tu: unknown,\n): u is SetOptions<P> => {\n\treturn (\n\t\ttypeof u === \"object\" &&\n\t\tu !== null &&\n\t\t(!(\"method\" in u) ||\n\t\t\t(\"method\" in u && typeof u.method === \"string\") ||\n\t\t\tu.method === undefined) &&\n\t\t\"path\" in u &&\n\t\ttypeof u.path === \"string\" &&\n\t\t(!(\"query\" in u) ||\n\t\t\t(\"query\" in u && (typeof u.query) in [\"object\", \"string\"]) ||\n\t\t\tu.query === undefined)\n\t);\n};\n","import {\n\tAPIStringSelectComponent,\n\tnormalizeArray,\n\tRestOrArray,\n\tStringSelectMenuBuilder,\n\tStringSelectMenuComponentData,\n} from \"discord.js\";\nimport { Path } from \"path-to-regexp\";\nimport { RouteStringSelectMenuOptionBuilder } from \"./RouteStringMenuOptionBuilder\";\nimport { EmbedRouter } from \"../EmbedRouter\";\nimport { encodePath } from \"../helpers/encodePath\";\nimport { isSetOptions, SetOptions } from \"../types/componentBuilders\";\n\nexport class RouteStringSelectMenuBuilder<L> extends StringSelectMenuBuilder {\n\t#embedRouter: EmbedRouter<L>;\n\n\t/**\n\t *\n\t * @param embedRouter the router you want to route with\n\t * @param path the path to redirect to, :to or *to in path will be replaced with the selected user's id\n\t * @param query any query parameters you want to add, :to will be replaced with the selected user's id\n\t * @param data the data to construct a component out of\n\t */\n\tconstructor(\n\t\tembedRouter: EmbedRouter<L>,\n\t\tdata?:\n\t\t\t| Partial<StringSelectMenuComponentData | APIStringSelectComponent>\n\t\t\t| undefined,\n\t) {\n\t\tsuper(data);\n\n\t\tthis.#embedRouter = embedRouter;\n\n\t\tsuper.setCustomId(\n\t\t\tencodePath({\n\t\t\t\tidPrefix: this.#embedRouter.getIdPrefix(),\n\t\t\t\tmethod: \"GET\",\n\t\t\t\tpath: \"/*to\",\n\t\t\t}),\n\t\t);\n\t}\n\n\t/**\n\t * Not supported for RouteStringSelectMenuBuilder (customId set from embedRouter)\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride setCustomId(): this {\n\t\tthrow new Error(\n\t\t\t\"setCustomId is not supported on RouteStringSelectMenuBuilder\",\n\t\t);\n\t}\n\n\t/**\n\t * Not supported for RouteStringSelectMenuBuilder (use addTos)\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride addOptions(): this {\n\t\tthrow new Error(\n\t\t\t\"addOptions is not supported on RouteStringSelectMenuBuilder\",\n\t\t);\n\t}\n\n\t/**\n\t * Not supported for RouteStringSelectMenuBuilder (use setTos)\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride setOptions(): this {\n\t\tthrow new Error(\n\t\t\t\"setOptions is not supported on RouteStringSelectMenuBuilder\",\n\t\t);\n\t}\n\n\t/**\n\t * Adds route select menu options to builder\n\t *\n\t * @param tos the list of route select menu options\n\t */\n\tpublic addTos(\n\t\t...tos: RestOrArray<\n\t\t\t| RouteStringSelectMenuOptionBuilder\n\t\t\t| ConstructorParameters<typeof RouteStringSelectMenuOptionBuilder>[0]\n\t\t>\n\t): this {\n\t\tconst resolved = normalizeArray(tos);\n\t\tsuper.addOptions(\n\t\t\tresolved.map((o) =>\n\t\t\t\to instanceof RouteStringSelectMenuOptionBuilder\n\t\t\t\t\t? o\n\t\t\t\t\t: new RouteStringSelectMenuOptionBuilder(o),\n\t\t\t),\n\t\t);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets route select menu options to builder\n\t *\n\t * @param tos the list of route select menu options\n\t */\n\tpublic setTos(\n\t\t...tos: RestOrArray<\n\t\t\t| RouteStringSelectMenuOptionBuilder\n\t\t\t| ConstructorParameters<typeof RouteStringSelectMenuOptionBuilder>[0]\n\t\t>\n\t): this {\n\t\tconst resolved = normalizeArray(tos);\n\t\tsuper.setOptions(\n\t\t\tresolved.map((o) =>\n\t\t\t\to instanceof RouteStringSelectMenuOptionBuilder\n\t\t\t\t\t? o\n\t\t\t\t\t: new RouteStringSelectMenuOptionBuilder(o),\n\t\t\t),\n\t\t);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the pattern to redirect to (Required)\n\t *\n\t * @param path the path to redirect to, :to or *to in path will be replaced with the selected user's id\n\t * @param query any query parameters you want to add, :to will be replaced with the selected user's id\n\t * @param method method to send to route\n\t */\n\tpublic setPattern<P extends Path>({\n\t\tmethod,\n\t\tpath,\n\t\tquery,\n\t}: SetOptions<P>): this;\n\t/**\n\t * Sets the path to route to when clicked\n\t *\n\t * @param path the path to route to\n\t */\n\tpublic setPattern<P extends Path>(path: P): this;\n\n\tpublic setPattern<P extends Path>(arg: P | SetOptions<P>) {\n\t\tconst {\n\t\t\tmethod = \"GET\",\n\t\t\tpath,\n\t\t\tquery,\n\t\t} = isSetOptions(arg) ? arg : { path: arg };\n\t\tsuper.setCustomId(\n\t\t\tencodePath({\n\t\t\t\tidPrefix: this.#embedRouter.getIdPrefix(),\n\t\t\t\tmethod,\n\t\t\t\tpath,\n\t\t\t\tquery,\n\t\t\t}),\n\t\t);\n\n\t\treturn this;\n\t}\n}\n","import { StringSelectMenuOptionBuilder } from \"discord.js\";\nimport { Path } from \"path-to-regexp\";\nimport { encodePath } from \"../helpers/encodePath\";\nimport { isSetOptions, SetOptions } from \"../types/componentBuilders\";\n\nexport class RouteStringSelectMenuOptionBuilder extends StringSelectMenuOptionBuilder {\n\t/**\n\t * Not supported for RouteStringSelectMenuOptionBuilder (use setTo)\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride setValue(): this {\n\t\tthrow new Error(\n\t\t\t\"setValue is not supported on RouteStringSelectMenuOptionBuilder\",\n\t\t);\n\t}\n\n\t/**\n\t * Sets the path to route to when clicked\n\t *\n\t * @param path the path to route to\n\t * @param query any query parameters you want to add\n\t * @param method method to send to route\n\t */\n\tpublic setTo<P extends Path>({ method, path, query }: SetOptions<P>): this;\n\t/**\n\t * Sets the path to route to when clicked\n\t *\n\t * @param path the path to route to\n\t */\n\tpublic setTo<P extends Path>(path: P): this;\n\n\tpublic setTo<P extends Path>(arg: P | SetOptions<P>) {\n\t\tconst {\n\t\t\tmethod = \"GET\",\n\t\t\tpath,\n\t\t\tquery,\n\t\t} = isSetOptions(arg) ? arg : { path: arg };\n\t\tsuper.setValue(\n\t\t\tencodePath({\n\t\t\t\tidPrefix: \"\",\n\t\t\t\tmethod,\n\t\t\t\tpath,\n\t\t\t\tquery,\n\t\t\t}),\n\t\t);\n\n\t\treturn this;\n\t}\n}\n","import {\n\tAPIChannelSelectComponent,\n\tChannelSelectMenuBuilder,\n\tChannelSelectMenuComponentData,\n} from \"discord.js\";\nimport { EmbedRouter } from \"../EmbedRouter\";\nimport { Path } from \"path-to-regexp\";\nimport { encodePath } from \"../helpers/encodePath\";\nimport { isSetOptions, SetOptions } from \"../types/componentBuilders\";\n\nexport class RouteChannelSelectMenuBuilder<L> extends ChannelSelectMenuBuilder {\n\t#embedRouter: EmbedRouter<L>;\n\n\t/**\n\t *\n\t * @param embedRouter the router you want to route with\n\t * @param data the data to construct a component out of\n\t */\n\tconstructor(\n\t\tembedRouter: EmbedRouter<L>,\n\t\tdata?:\n\t\t\t| Partial<ChannelSelectMenuComponentData | APIChannelSelectComponent>\n\t\t\t| undefined,\n\t) {\n\t\tsuper(data);\n\n\t\tthis.#embedRouter = embedRouter;\n\t}\n\n\t/**\n\t * Not supported for RouteChannelSelectMenuBuilder (customId set from embedRouter)\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride setCustomId(): this {\n\t\tthrow new Error(\n\t\t\t\"setCustomId is not supported on RouteChannelSelectMenuBuilder\",\n\t\t);\n\t}\n\n\t/**\n\t * Sets the pattern to redirect to (Required)\n\t *\n\t * @param path the path to redirect to, :channelId in path will be replaced with the selected user's id\n\t * @param query any query parameters you want to add, :channelId will be replaced with the selected user's id\n\t * @param method method to send to route\n\t */\n\tpublic setPattern<P extends Path>({\n\t\tmethod,\n\t\tpath,\n\t\tquery,\n\t}: SetOptions<P>): this;\n\t/**\n\t * Sets the path to route to when clicked\n\t *\n\t * @param path the path to route to\n\t */\n\tpublic setPattern<P extends Path>(path: P): this;\n\n\tpublic setPattern<P extends Path>(arg: P | SetOptions<P>) {\n\t\tconst {\n\t\t\tmethod = \"GET\",\n\t\t\tpath,\n\t\t\tquery,\n\t\t} = isSetOptions(arg) ? arg : { path: arg };\n\t\tsuper.setCustomId(\n\t\t\tencodePath({\n\t\t\t\tidPrefix: this.#embedRouter.getIdPrefix(),\n\t\t\t\tmethod,\n\t\t\t\tpath,\n\t\t\t\tquery,\n\t\t\t}),\n\t\t);\n\n\t\treturn this;\n\t}\n}\n","import {\n\tAPIRoleSelectComponent,\n\tRoleSelectMenuBuilder,\n\tRoleSelectMenuComponentData,\n} from \"discord.js\";\nimport { EmbedRouter } from \"../EmbedRouter\";\nimport { Path } from \"path-to-regexp\";\nimport { encodePath } from \"../helpers/encodePath\";\nimport { isSetOptions, SetOptions } from \"../types/componentBuilders\";\n\nexport class RouteRoleSelectMenuBuilder<L> extends RoleSelectMenuBuilder {\n\t#embedRouter: EmbedRouter<L>;\n\n\t/**\n\t *\n\t * @param embedRouter the router you want to route with\n\t * @param data the data to construct a component out of\n\t */\n\tconstructor(\n\t\tembedRouter: EmbedRouter<L>,\n\t\tdata?:\n\t\t\tPartial<RoleSelectMenuComponentData | APIRoleSelectComponent> | undefined,\n\t) {\n\t\tsuper(data);\n\n\t\tthis.#embedRouter = embedRouter;\n\t}\n\n\t/**\n\t * Not supported for RouteRoleSelectMenuBuilder (customId set from embedRouter)\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride setCustomId(): this {\n\t\tthrow new Error(\n\t\t\t\"setCustomId is not supported on RouteRoleSelectMenuBuilder\",\n\t\t);\n\t}\n\n\t/**\n\t * Sets the pattern to redirect to (Required)\n\t *\n\t * @param path the path to redirect to, :roleId in path will be replaced with the selected user's id\n\t * @param query any query parameters you want to add, :roleId will be replaced with the selected user's id\n\t * @param method method to send to route\n\t */\n\tpublic setPattern<P extends Path>({\n\t\tmethod,\n\t\tpath,\n\t\tquery,\n\t}: SetOptions<P>): this;\n\t/**\n\t * Sets the path to route to when clicked\n\t *\n\t * @param path the path to route to\n\t */\n\tpublic setPattern<P extends Path>(path: P): this;\n\n\tpublic setPattern<P extends Path>(arg: P | SetOptions<P>) {\n\t\tconst {\n\t\t\tmethod = \"GET\",\n\t\t\tpath,\n\t\t\tquery,\n\t\t} = isSetOptions(arg) ? arg : { path: arg };\n\t\tsuper.setCustomId(\n\t\t\tencodePath({\n\t\t\t\tidPrefix: this.#embedRouter.getIdPrefix(),\n\t\t\t\tmethod,\n\t\t\t\tpath,\n\t\t\t\tquery,\n\t\t\t}),\n\t\t);\n\n\t\treturn this;\n\t}\n}\n","import {\n\tAPIUserSelectComponent,\n\tUserSelectMenuBuilder,\n\tUserSelectMenuComponentData,\n} from \"discord.js\";\nimport { EmbedRouter } from \"../EmbedRouter\";\nimport { Path } from \"path-to-regexp\";\nimport { encodePath } from \"../helpers/encodePath\";\nimport { isSetOptions, SetOptions } from \"../types/componentBuilders\";\n\nexport class RouteUserSelectMenuBuilder<L> extends UserSelectMenuBuilder {\n\t#embedRouter: EmbedRouter<L>;\n\n\t/**\n\t *\n\t * @param embedRouter the router you want to route with\n\t * @param data the data to construct a component out of\n\t */\n\tconstructor(\n\t\tembedRouter: EmbedRouter<L>,\n\t\tdata?:\n\t\t\tPartial<UserSelectMenuComponentData | APIUserSelectComponent> | undefined,\n\t) {\n\t\tsuper(data);\n\n\t\tthis.#embedRouter = embedRouter;\n\t}\n\n\t/**\n\t * Not supported for RouteUserSelectMenuBuilder (customId set from embedRouter)\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride setCustomId(): this {\n\t\tthrow new Error(\n\t\t\t\"setCustomId is not supported on RouteUserSelectMenuBuilder\",\n\t\t);\n\t}\n\n\t/**\n\t * Sets the pattern to redirect to (Required)\n\t *\n\t * @param path the path to redirect to, :userId in path will be replaced with the selected user's id\n\t * @param query any query parameters you want to add, :userId will be replaced with the selected user's id\n\t * @param method method to send to route\n\t */\n\tpublic setPattern<P extends Path>({\n\t\tmethod,\n\t\tpath,\n\t\tquery,\n\t}: SetOptions<P>): this;\n\t/**\n\t * Sets the path to route to when clicked\n\t *\n\t * @param path the path to route to\n\t */\n\tpublic setPattern<P extends Path>(path: P): this;\n\n\tpublic setPattern<P extends Path>(arg: P | SetOptions<P>) {\n\t\tconst {\n\t\t\tmethod = \"GET\",\n\t\t\tpath,\n\t\t\tquery,\n\t\t} = isSetOptions(arg) ? arg : { path: arg };\n\t\tsuper.setCustomId(\n\t\t\tencodePath({\n\t\t\t\tidPrefix: this.#embedRouter.getIdPrefix(),\n\t\t\t\tmethod,\n\t\t\t\tpath,\n\t\t\t\tquery,\n\t\t\t}),\n\t\t);\n\n\t\treturn this;\n\t}\n}\n"],"mappings":";AAAA,OAAO,UAAU;AACjB,SAAS,kBAAkB;AAC3B,SAAS,aAAmB;;;ACArB,IAAM,YAAY;AAClB,IAAM,qBAA6C;AAAA,EACzD,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,QAAQ;AACT;AACO,IAAM,qBAA6C;AAAA,EACzD,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACJ;AAEO,IAAM,WAAW;AAEjB,IAAM,YAAY;AAClB,IAAM,UAAU;AAChB,IAAM,YAAY,UAAU,YAAY;;;ACtB/C,SAAS,OAAa,WAAW,iBAAiB;AAE3C,IAAM,eAAe,CAC3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AAA,EAqBO,WAA2B,KAAwB;AACzD,UAAM;AAAA,MACL,SAAS;AAAA,MACT,MAAAC;AAAA,MACA;AAAA,IACD,IAAI,aAAa,GAAG,IAAI,MAAM,EAAE,MAAM,IAAI;AAC1C,UAAM;AAAA,MACL,WAAW;AAAA,QACV,UAAU,KAAK,aAAa,YAAY;AAAA,QACxC;AAAA,QACA,MAAAA;AAAA,QACA;AAAA,MACD,CAAC;AAAA,IACF;AAEA,WAAO;AAAA,EACR;AACD;;;AC5EA;AAAA,EAEC;AAAA,OAEM;AAMA,IAAM,6BAAN,cAA4C,sBAAsB;AAAA,EACxE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,YACC,aACA,MAEC;AACD,UAAM,IAAI;AAEV,SAAK,eAAe;AAAA,EACrB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQS,cAAoB;AAC5B,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AAAA,EAqBO,WAA2B,KAAwB;AACzD,UAAM;AAAA,MACL,SAAS;AAAA,MACT,MAAAC;AAAA,MACA;AAAA,IACD,IAAI,aAAa,GAAG,IAAI,MAAM,EAAE,MAAM,IAAI;AAC1C,UAAM;AAAA,MACL,WAAW;AAAA,QACV,UAAU,KAAK,aAAa,YAAY;AAAA,QACxC;AAAA,QACA,MAAAA;AAAA,QACA;AAAA,MACD,CAAC;AAAA,IACF;AAEA,WAAO;AAAA,EACR;AACD;","names":["path","path","path","path","path","path","path","path","path","path"]}
1
+ {"version":3,"sources":["../src/EmbedRouter.ts","../src/consts.ts","../src/helpers/pathToString.ts","../src/helpers/decodePath.ts","../src/componentBuilders/RouteButtonBuilder.ts","../src/helpers/encodePath.ts","../src/types/componentBuilders.ts","../src/componentBuilders/RouteStringSelectMenuBuilder.ts","../src/componentBuilders/RouteStringMenuOptionBuilder.ts","../src/componentBuilders/RouteChannelSelectMenuBuilder.ts","../src/componentBuilders/RouteRoleSelectMenuBuilder.ts","../src/componentBuilders/RouteUserSelectMenuBuilder.ts"],"sourcesContent":["import path from \"node:path\";\nimport { createHash } from \"node:crypto\";\nimport { match, MatchResult, Path } from \"path-to-regexp\";\nimport type {\n\tCompiledRoute,\n\tMethod,\n\tRouteHandler,\n\tRouteResponse,\n} from \"./types/routes\";\nimport type { ExtractParams } from \"./types/ExtractParams\";\nimport {\n\tAnySelectMenuInteraction,\n\tButtonInteraction,\n\tInteraction,\n\tInteractionReplyOptions,\n} from \"discord.js\";\nimport { BASE_URL, ID_PREFIX, PUA_RANGE, PUA_START } from \"./consts\";\nimport { pathToString } from \"./helpers/pathToString\";\nimport { decodePath } from \"./helpers/decodePath\";\n\nexport class EmbedRouter<L> {\n\t// identifier -> embedRouter\n\tstatic #usedIdentifiers = new Map<string, EmbedRouter<unknown>>();\n\n\t// Name used to generate prefixes\n\t#name = \"\";\n\t// Prefix for customIds of RouteButtonBuilders\n\t#idPrefix: string;\n\t#identifier: string = \"\";\n\tpublic getIdPrefix() {\n\t\treturn `${this.#idPrefix}${this.#identifier}`;\n\t}\n\n\t// All added routes\n\t#routes: Map<Method, CompiledRoute<Method, L>[]> = new Map();\n\n\t/**\n\t *\n\t * @param name the name to give the router. ensures buttons stay connected across restarts\n\t * @param idPrefix the prefix for RouteButtonBuilder customIds\n\t */\n\tconstructor({\n\t\tname = \"\",\n\t\tidPrefix = ID_PREFIX,\n\t}: {\n\t\tname?: string | undefined;\n\t\tidPrefix?: string | undefined;\n\t} = {}) {\n\t\tif (EmbedRouter.#usedIdentifiers.size >= PUA_RANGE) {\n\t\t\tthrow new Error(`You can not have more than ${PUA_RANGE} routers`);\n\t\t}\n\t\tif (idPrefix.includes(\"/\")) {\n\t\t\tthrow new Error(`Prefix can't contain \"/\": ${idPrefix}`);\n\t\t}\n\t\tthis.#idPrefix = idPrefix;\n\t\tthis.#name = name;\n\t\tthis.#updateIdentifier();\n\t}\n\n\t#updateIdentifier() {\n\t\t// Private Use Area: Unicode Characters not from any language\n\t\tconst hash = createHash(\"sha256\").update(this.#name).digest();\n\t\tlet raw = hash.readUint32BE(0);\n\t\tlet char: string;\n\t\tconst nameCollisions = [];\n\t\t// find next available identifier\n\t\twhile (true) {\n\t\t\tconst codepoint = PUA_START + (raw++ % PUA_RANGE);\n\t\t\tchar = String.fromCodePoint(codepoint);\n\n\t\t\tconst collisionRouter = EmbedRouter.#usedIdentifiers.get(char);\n\t\t\tif (collisionRouter === undefined) break; // no collisions\n\n\t\t\tif (this.#name.length > 0 && collisionRouter.#name.length === 0) {\n\t\t\t\t// evict old name; usedIdentifier is still taken\n\t\t\t\tcollisionRouter.#updateIdentifier();\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tnameCollisions.push(collisionRouter);\n\t\t}\n\t\tEmbedRouter.#usedIdentifiers.set(char, this as EmbedRouter<unknown>);\n\n\t\tif (nameCollisions.length > 0 && this.#name.length > 0) {\n\t\t\tprocess.emitWarning(\n\t\t\t\t`EmbedRouter identifier collision for name \"${this.#name}\" with ${nameCollisions.map((c) => `\"${c.#name}\"`).join(\", \")}`,\n\t\t\t\t\"EmbedRouterWarning\",\n\t\t\t);\n\t\t}\n\t\tthis.#identifier = char;\n\t}\n\n\t#addRoute<M extends Method, P extends Path = Path>(\n\t\tmethod: M,\n\t\troutePath: P | P[],\n\t\thandler: RouteHandler<M, L, ExtractParams<P>>,\n\t) {\n\t\tconst methodRoutes = this.#routes.get(method) ?? [];\n\t\tmethodRoutes.push({\n\t\t\tmethod,\n\t\t\tpath: Array.isArray(routePath) ? routePath : [routePath],\n\t\t\tmatchFunction: match(routePath),\n\t\t\thandler: handler as RouteHandler<M, L>,\n\t\t});\n\t\tthis.#routes.set(method, methodRoutes);\n\t}\n\n\t/**\n\t * Registers a path with the router\n\t *\n\t * @param routePath path to match with\n\t * @param handler function that generates the message when a path is matched\n\t */\n\tpublic get<P extends Path = Path>(\n\t\troutePath: P | P[],\n\t\thandler: RouteHandler<\"GET\", L, ExtractParams<P>>,\n\t) {\n\t\tthis.#addRoute(\"GET\", routePath, handler);\n\t}\n\n\t/**\n\t * Registers a path with the router\n\t *\n\t * @param routePath path to match with\n\t * @param handler function that generates the message when a path is matched\n\t */\n\tpublic post<P extends Path = Path>(\n\t\troutePath: P | P[],\n\t\thandler: RouteHandler<\"POST\", L, ExtractParams<P>>,\n\t) {\n\t\tthis.#addRoute(\"POST\", routePath, handler);\n\t}\n\n\t/**\n\t * Registers a path with the router\n\t *\n\t * @param routePath path to match with\n\t * @param handler function that generates the message when a path is matched\n\t */\n\tpublic put<P extends Path = Path>(\n\t\troutePath: P | P[],\n\t\thandler: RouteHandler<\"PUT\", L, ExtractParams<P>>,\n\t) {\n\t\tthis.#addRoute(\"PUT\", routePath, handler);\n\t}\n\n\t/**\n\t * Registers a path with the router\n\t *\n\t * @param routePath path to match with\n\t * @param handler function that generates the message when a path is matched\n\t */\n\tpublic patch<P extends Path = Path>(\n\t\troutePath: P | P[],\n\t\thandler: RouteHandler<\"PATCH\", L, ExtractParams<P>>,\n\t) {\n\t\tthis.#addRoute(\"PATCH\", routePath, handler);\n\t}\n\n\t/**\n\t * Registers a path with the router\n\t *\n\t * @param routePath path to match with\n\t * @param handler function that generates the message when a path is matched\n\t */\n\tpublic delete<P extends Path = Path>(\n\t\troutePath: P | P[],\n\t\thandler: RouteHandler<\"DELETE\", L, ExtractParams<P>>,\n\t) {\n\t\tthis.#addRoute(\"DELETE\", routePath, handler);\n\t}\n\n\t/**\n\t * Adds a subrouter to the router\n\t *\n\t * @param routePath path of the router\n\t * @param embedRouter router to add at the path\n\t */\n\tpublic use<P extends Path = Path>(routePath: P, embedRouter: EmbedRouter<L>) {\n\t\tconst pathString = pathToString(routePath);\n\t\tfor (const [method, routes] of embedRouter.#routes) {\n\t\t\tfor (const route of routes) {\n\t\t\t\tthis.#addRoute(\n\t\t\t\t\tmethod,\n\t\t\t\t\troute.path.map((p) => path.posix.join(pathString, pathToString(p))),\n\t\t\t\t\troute.handler,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Must be attached to \"interactionCreate\" event for RouteButtonBuilder to work\n\t *\n\t * @param interaction interactions from \"interactionCreate\" (filter for ButtonInteractions)\n\t */\n\tpublic async listener(\n\t\tinteraction: ButtonInteraction | AnySelectMenuInteraction,\n\t\tlocals?: L | undefined,\n\t) {\n\t\tconst res = decodePath({ idPrefix: this.getIdPrefix(), interaction });\n\t\tif (!res)\n\t\t\tthrow new Error(`Invalid component found: id ${interaction.customId}`);\n\n\t\tthis.dispatch({ interaction, method: res.method, path: res.path, locals });\n\t}\n\n\t/**\n\t * Replies to or editReplies to an interaction based on the route output\n\t *\n\t * @param interaction interaction to connect to\n\t * @param path path to route the interaction to\n\t * @param method method to send to route\n\t * @param flags discord flags to send with message (optional, only allowed on first reply)\n\t * @param locals additional info to pass in to page through state.local (optional)\n\t */\n\tpublic async dispatch<P extends Path = Path>({\n\t\tinteraction,\n\t\tmethod = \"GET\",\n\t\tpath,\n\t\tflags,\n\t\tlocals,\n\t}: {\n\t\tinteraction: Interaction;\n\t\tmethod?: Method;\n\t\tpath: P;\n\t\tflags?: InteractionReplyOptions[\"flags\"] | undefined;\n\t\tlocals?: L | undefined;\n\t}) {\n\t\tif (interaction.isAutocomplete())\n\t\t\tthrow new Error(\"Autocomplete Interactions aren't supported\");\n\n\t\t// don't check validity because url params are considered invalid\n\t\tconst routeResponse = await this.#resolve({\n\t\t\tinteraction,\n\t\t\tmethod,\n\t\t\tpath,\n\t\t\tlocals,\n\t\t});\n\t\tif (routeResponse === false)\n\t\t\tthrow new Error(`No route found for ${pathToString(path, false)}`);\n\n\t\tif (interaction.replied || interaction.deferred) {\n\t\t\tif (flags)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"You can only set flags for interactions that haven't been replied to\",\n\t\t\t\t);\n\t\t\tif (routeResponse) await interaction.editReply(routeResponse);\n\t\t} else if (!routeResponse) {\n\t\t\tif (\"deferUpdate\" in interaction) {\n\t\t\t\tawait interaction.deferUpdate();\n\t\t\t} else {\n\t\t\t\tawait interaction.deferReply();\n\t\t\t}\n\t\t} else if (\"update\" in interaction) {\n\t\t\tif (flags)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"You can only set flags for interactions that haven't been replied to\",\n\t\t\t\t);\n\t\t\tawait interaction.update(routeResponse);\n\t\t} else {\n\t\t\tinteraction.reply({\n\t\t\t\t...(routeResponse as InteractionReplyOptions),\n\t\t\t\tflags,\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Resolves a route to the associated message (DOES NOT UPDATE MESSAGE)\n\t *\n\t * @param interaction interaction to connect to\n\t * @param path path to route the interaction to\n\t * @param method method to send to route\n\t * @param locals additional info to pass in to page through state.local (optional)\n\t * @returns discord message associated with route OR false\n\t */\n\tasync #resolve<P extends Path>({\n\t\tinteraction,\n\t\tmethod = \"GET\",\n\t\tpath,\n\t\tlocals,\n\t}: {\n\t\tinteraction: Interaction;\n\t\tmethod?: Method;\n\t\tpath: P;\n\t\tlocals?: L | undefined;\n\t}): Promise<RouteResponse | false> {\n\t\t// don't check validity because url params are considered invalid\n\t\tconst url = new URL(pathToString(path, false), BASE_URL);\n\t\tfor (const route of this.#routes.get(method) ?? []) {\n\t\t\tconst result = route.matchFunction(url.pathname);\n\t\t\tif (result) {\n\t\t\t\treturn await route.handler(interaction, {\n\t\t\t\t\t...(result as MatchResult<ExtractParams<P>>),\n\t\t\t\t\tquery: url.searchParams,\n\t\t\t\t\tembedRouter: this,\n\t\t\t\t\tlocals,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n}\n","import { Method } from \"./types/routes\";\n\nexport const ID_PREFIX = \"der\";\nexport const METHOD_TO_ENCODING: Record<Method, string> = {\n\tGET: \"G\",\n\tPOST: \"P\",\n\tPUT: \"U\",\n\tPATCH: \"A\",\n\tDELETE: \"D\",\n};\nexport const ENCODING_TO_METHOD: Record<string, Method> = {\n\tG: \"GET\",\n\tP: \"POST\",\n\tU: \"PUT\",\n\tA: \"PATCH\",\n\tD: \"DELETE\",\n};\n// base url is never sent; only used for processing locally\nexport const BASE_URL = \"discord://embed.router\";\n\nexport const PUA_START = 0xe000;\nexport const PUA_END = 0xf8ff;\nexport const PUA_RANGE = PUA_END - PUA_START + 1;\n","import { parse, Path, stringify, TokenData } from \"path-to-regexp\";\n\nexport const pathToString = <P extends Path>(\n\tpath: P,\n\tcheckValidity = true,\n): string => {\n\tif (checkValidity) {\n\t\treturn stringify(path instanceof TokenData ? path : parse(path));\n\t}\n\treturn typeof path === \"string\" ? path : stringify(path);\n};\n","import { compile, Path } from \"path-to-regexp\";\nimport { AnySelectMenuInteraction, ButtonInteraction } from \"discord.js\";\nimport { BASE_URL, ENCODING_TO_METHOD } from \"../consts\";\nimport { Method } from \"../types/routes\";\n\nexport const decodePath = ({\n\tidPrefix,\n\tinteraction,\n}: {\n\tidPrefix: string;\n\tinteraction: ButtonInteraction | AnySelectMenuInteraction;\n}): { method: Method; path: Path } | false => {\n\tconst customId = interaction.customId;\n\tif (!customId.startsWith(idPrefix)) return false;\n\n\tif (interaction.isButton()) {\n\t\treturn parseMethodAndPath(customId.slice(idPrefix.length));\n\t} else if (interaction.isAnySelectMenu()) {\n\t\tif (interaction.values.length === 0) return false;\n\t\tconst res = parseMethodAndPath(customId.slice(idPrefix.length));\n\t\tif (!res) return false;\n\n\t\tconst { method, path } = res;\n\t\treturn {\n\t\t\tmethod,\n\t\t\tpath: fillParams(path, {\n\t\t\t\t[interaction.isStringSelectMenu()\n\t\t\t\t\t? \"to\"\n\t\t\t\t\t: interaction.isChannelSelectMenu()\n\t\t\t\t\t\t? \"channelId\"\n\t\t\t\t\t\t: interaction.isRoleSelectMenu()\n\t\t\t\t\t\t\t? \"roleId\"\n\t\t\t\t\t\t\t: \"userId\"]: interaction.values[0]!.split(\"/\").slice(1),\n\t\t\t}),\n\t\t};\n\t}\n\n\treturn false;\n};\n\nexport const parseMethodAndPath = (\n\tpathWithMethod: string,\n): { method: Method; path: string } | false => {\n\t// path always start with \"/\"\n\tconst firstSlash = pathWithMethod.indexOf(\"/\");\n\t// invalid customId\n\tif (firstSlash <= 0) return false;\n\n\tconst method = ENCODING_TO_METHOD[pathWithMethod.slice(0, firstSlash)];\n\tif (method === undefined) return false;\n\treturn {\n\t\tmethod,\n\t\tpath: pathWithMethod.slice(firstSlash),\n\t};\n};\n\nconst fillParams = (\n\tpath: string,\n\tparams: Partial<Record<string, string | string[]>> = {},\n): string => {\n\tconst url = new URL(path, BASE_URL);\n\tconst toPath = compile(url.pathname);\n\n\turl.pathname = toPath(params);\n\tfor (const [key, value] of url.searchParams) {\n\t\tif (value.startsWith(\":\") && key.slice(1) in params) {\n\t\t\tconst paramValue = params?.[key.slice(1)];\n\t\t\tif (paramValue) {\n\t\t\t\turl.searchParams.set(\n\t\t\t\t\tkey,\n\t\t\t\t\tArray.isArray(paramValue) ? paramValue.join(\"/\") : paramValue,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\turl.searchParams.delete(key);\n\t\t\t}\n\t\t}\n\t}\n\treturn `${url.pathname}${url.search}`;\n};\n","import { APIButtonComponent, ButtonBuilder } from \"discord.js\";\nimport { Path } from \"path-to-regexp\";\nimport { EmbedRouter } from \"../EmbedRouter\";\nimport { encodePath } from \"../helpers/encodePath\";\nimport { isSetOptions, SetOptions } from \"../types/componentBuilders\";\n\nexport class RouteButtonBuilder<L> extends ButtonBuilder {\n\t#embedRouter: EmbedRouter<L>;\n\n\t/**\n\t *\n\t * @param embedRouter the router you want to route with\n\t * @param data the data to construct a component out of\n\t */\n\tconstructor(\n\t\tembedRouter: EmbedRouter<L>,\n\t\tdata?: Omit<Partial<APIButtonComponent>, \"custom_id\" | \"url\"> | undefined,\n\t) {\n\t\tsuper(data);\n\n\t\tthis.#embedRouter = embedRouter;\n\t}\n\n\t/**\n\t * Not supported for RouteButtonBuilder\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride setURL(): this {\n\t\tthrow new Error(\"setURL is not supported on RouteButtonBuilder\");\n\t}\n\n\t/**\n\t * Not supported for RouteButtonBuilder (use setTo)\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride setCustomId(): this {\n\t\tthrow new Error(\"setCustomId is not supported on RouteButtonBuilder\");\n\t}\n\n\t/**\n\t * Sets the path to route to when clicked\n\t *\n\t * @param path the path to route to\n\t * @param query any query parameters you want to add\n\t * @param method method to send to route\n\t */\n\tpublic setTo<P extends Path>({ method, path, query }: SetOptions<P>): this;\n\t/**\n\t * Sets the path to route to when clicked\n\t *\n\t * @param path the path to route to\n\t */\n\tpublic setTo<P extends Path>(path: P): this;\n\n\tpublic setTo<P extends Path>(arg: P | SetOptions<P>) {\n\t\tconst {\n\t\t\tmethod = \"GET\",\n\t\t\tpath,\n\t\t\tquery,\n\t\t} = isSetOptions(arg) ? arg : { path: arg };\n\n\t\tsuper.setCustomId(\n\t\t\tencodePath({\n\t\t\t\tidPrefix: this.#embedRouter.getIdPrefix(),\n\t\t\t\tmethod,\n\t\t\t\tpath,\n\t\t\t\tquery,\n\t\t\t}),\n\t\t);\n\n\t\treturn this;\n\t}\n}\n","import { Path } from \"path-to-regexp\";\nimport { BASE_URL, METHOD_TO_ENCODING } from \"../consts\";\nimport { pathToString } from \"./pathToString\";\nimport { Method } from \"../types/routes\";\n\nexport const encodePath = ({\n\tidPrefix,\n\tmethod,\n\tpath,\n\tquery,\n}: {\n\tidPrefix: string;\n\tmethod: Method;\n\tpath: Path;\n\tquery?: ConstructorParameters<typeof URLSearchParams>[0] | undefined;\n}) => {\n\tconst url = new URL(pathToString(path), BASE_URL);\n\tif (query) {\n\t\tfor (const [key, value] of new URLSearchParams(query)) {\n\t\t\turl.searchParams.set(key, value);\n\t\t}\n\t}\n\treturn `${idPrefix}${METHOD_TO_ENCODING[method]}${url.pathname}${url.search}`;\n};\n","import { Path } from \"path-to-regexp\";\nimport { Method } from \"./routes\";\n\nexport type SetOptions<P extends Path> = {\n\tmethod?: Method;\n\tpath: P;\n\tquery?: ConstructorParameters<typeof URLSearchParams>[0] | undefined;\n};\n\nexport const isSetOptions = <P extends Path>(\n\tu: unknown,\n): u is SetOptions<P> => {\n\treturn (\n\t\ttypeof u === \"object\" &&\n\t\tu !== null &&\n\t\t(!(\"method\" in u) ||\n\t\t\t(\"method\" in u && typeof u.method === \"string\") ||\n\t\t\tu.method === undefined) &&\n\t\t\"path\" in u &&\n\t\ttypeof u.path === \"string\" &&\n\t\t(!(\"query\" in u) ||\n\t\t\t(\"query\" in u && [\"object\", \"string\"].includes(typeof u.query)) ||\n\t\t\tu.query === undefined)\n\t);\n};\n","import {\n\tAPIStringSelectComponent,\n\tnormalizeArray,\n\tRestOrArray,\n\tStringSelectMenuBuilder,\n\tStringSelectMenuComponentData,\n} from \"discord.js\";\nimport { Path } from \"path-to-regexp\";\nimport { RouteStringSelectMenuOptionBuilder } from \"./RouteStringMenuOptionBuilder\";\nimport { EmbedRouter } from \"../EmbedRouter\";\nimport { encodePath } from \"../helpers/encodePath\";\nimport { isSetOptions, SetOptions } from \"../types/componentBuilders\";\n\nexport class RouteStringSelectMenuBuilder<L> extends StringSelectMenuBuilder {\n\t#embedRouter: EmbedRouter<L>;\n\n\t/**\n\t *\n\t * @param embedRouter the router you want to route with\n\t * @param path the path to redirect to, :to or *to in path will be replaced with the selected user's id\n\t * @param query any query parameters you want to add, :to will be replaced with the selected user's id\n\t * @param data the data to construct a component out of\n\t */\n\tconstructor(\n\t\tembedRouter: EmbedRouter<L>,\n\t\tdata?:\n\t\t\t| Partial<StringSelectMenuComponentData | APIStringSelectComponent>\n\t\t\t| undefined,\n\t) {\n\t\tsuper(data);\n\n\t\tthis.#embedRouter = embedRouter;\n\n\t\tsuper.setCustomId(\n\t\t\tencodePath({\n\t\t\t\tidPrefix: this.#embedRouter.getIdPrefix(),\n\t\t\t\tmethod: \"GET\",\n\t\t\t\tpath: \"/*to\",\n\t\t\t}),\n\t\t);\n\t}\n\n\t/**\n\t * Not supported for RouteStringSelectMenuBuilder (customId set from embedRouter)\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride setCustomId(): this {\n\t\tthrow new Error(\n\t\t\t\"setCustomId is not supported on RouteStringSelectMenuBuilder\",\n\t\t);\n\t}\n\n\t/**\n\t * Not supported for RouteStringSelectMenuBuilder (use addTos)\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride addOptions(): this {\n\t\tthrow new Error(\n\t\t\t\"addOptions is not supported on RouteStringSelectMenuBuilder\",\n\t\t);\n\t}\n\n\t/**\n\t * Not supported for RouteStringSelectMenuBuilder (use setTos)\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride setOptions(): this {\n\t\tthrow new Error(\n\t\t\t\"setOptions is not supported on RouteStringSelectMenuBuilder\",\n\t\t);\n\t}\n\n\t/**\n\t * Adds route select menu options to builder\n\t *\n\t * @param tos the list of route select menu options\n\t */\n\tpublic addTos(\n\t\t...tos: RestOrArray<\n\t\t\t| RouteStringSelectMenuOptionBuilder\n\t\t\t| ConstructorParameters<typeof RouteStringSelectMenuOptionBuilder>[0]\n\t\t>\n\t): this {\n\t\tconst resolved = normalizeArray(tos);\n\t\tsuper.addOptions(\n\t\t\tresolved.map((o) =>\n\t\t\t\to instanceof RouteStringSelectMenuOptionBuilder\n\t\t\t\t\t? o\n\t\t\t\t\t: new RouteStringSelectMenuOptionBuilder(o),\n\t\t\t),\n\t\t);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets route select menu options to builder\n\t *\n\t * @param tos the list of route select menu options\n\t */\n\tpublic setTos(\n\t\t...tos: RestOrArray<\n\t\t\t| RouteStringSelectMenuOptionBuilder\n\t\t\t| ConstructorParameters<typeof RouteStringSelectMenuOptionBuilder>[0]\n\t\t>\n\t): this {\n\t\tconst resolved = normalizeArray(tos);\n\t\tsuper.setOptions(\n\t\t\tresolved.map((o) =>\n\t\t\t\to instanceof RouteStringSelectMenuOptionBuilder\n\t\t\t\t\t? o\n\t\t\t\t\t: new RouteStringSelectMenuOptionBuilder(o),\n\t\t\t),\n\t\t);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the pattern to redirect to (Required)\n\t *\n\t * @param path the path to redirect to, :to or *to in path will be replaced with the selected user's id\n\t * @param query any query parameters you want to add, :to will be replaced with the selected user's id\n\t * @param method method to send to route\n\t */\n\tpublic setPattern<P extends Path>({\n\t\tmethod,\n\t\tpath,\n\t\tquery,\n\t}: SetOptions<P>): this;\n\t/**\n\t * Sets the path to route to when clicked\n\t *\n\t * @param path the path to route to\n\t */\n\tpublic setPattern<P extends Path>(path: P): this;\n\n\tpublic setPattern<P extends Path>(arg: P | SetOptions<P>) {\n\t\tconst {\n\t\t\tmethod = \"GET\",\n\t\t\tpath,\n\t\t\tquery,\n\t\t} = isSetOptions(arg) ? arg : { path: arg };\n\t\tsuper.setCustomId(\n\t\t\tencodePath({\n\t\t\t\tidPrefix: this.#embedRouter.getIdPrefix(),\n\t\t\t\tmethod,\n\t\t\t\tpath,\n\t\t\t\tquery,\n\t\t\t}),\n\t\t);\n\n\t\treturn this;\n\t}\n}\n","import { StringSelectMenuOptionBuilder } from \"discord.js\";\nimport { Path } from \"path-to-regexp\";\nimport { encodePath } from \"../helpers/encodePath\";\nimport { isSetOptions, SetOptions } from \"../types/componentBuilders\";\n\nexport class RouteStringSelectMenuOptionBuilder extends StringSelectMenuOptionBuilder {\n\t/**\n\t * Not supported for RouteStringSelectMenuOptionBuilder (use setTo)\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride setValue(): this {\n\t\tthrow new Error(\n\t\t\t\"setValue is not supported on RouteStringSelectMenuOptionBuilder\",\n\t\t);\n\t}\n\n\t/**\n\t * Sets the path to route to when clicked\n\t *\n\t * @param path the path to route to\n\t * @param query any query parameters you want to add\n\t * @param method method to send to route\n\t */\n\tpublic setTo<P extends Path>({ method, path, query }: SetOptions<P>): this;\n\t/**\n\t * Sets the path to route to when clicked\n\t *\n\t * @param path the path to route to\n\t */\n\tpublic setTo<P extends Path>(path: P): this;\n\n\tpublic setTo<P extends Path>(arg: P | SetOptions<P>) {\n\t\tconst {\n\t\t\tmethod = \"GET\",\n\t\t\tpath,\n\t\t\tquery,\n\t\t} = isSetOptions(arg) ? arg : { path: arg };\n\t\tsuper.setValue(\n\t\t\tencodePath({\n\t\t\t\tidPrefix: \"\",\n\t\t\t\tmethod,\n\t\t\t\tpath,\n\t\t\t\tquery,\n\t\t\t}),\n\t\t);\n\n\t\treturn this;\n\t}\n}\n","import {\n\tAPIChannelSelectComponent,\n\tChannelSelectMenuBuilder,\n\tChannelSelectMenuComponentData,\n} from \"discord.js\";\nimport { EmbedRouter } from \"../EmbedRouter\";\nimport { Path } from \"path-to-regexp\";\nimport { encodePath } from \"../helpers/encodePath\";\nimport { isSetOptions, SetOptions } from \"../types/componentBuilders\";\n\nexport class RouteChannelSelectMenuBuilder<L> extends ChannelSelectMenuBuilder {\n\t#embedRouter: EmbedRouter<L>;\n\n\t/**\n\t *\n\t * @param embedRouter the router you want to route with\n\t * @param data the data to construct a component out of\n\t */\n\tconstructor(\n\t\tembedRouter: EmbedRouter<L>,\n\t\tdata?:\n\t\t\t| Partial<ChannelSelectMenuComponentData | APIChannelSelectComponent>\n\t\t\t| undefined,\n\t) {\n\t\tsuper(data);\n\n\t\tthis.#embedRouter = embedRouter;\n\t}\n\n\t/**\n\t * Not supported for RouteChannelSelectMenuBuilder (customId set from embedRouter)\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride setCustomId(): this {\n\t\tthrow new Error(\n\t\t\t\"setCustomId is not supported on RouteChannelSelectMenuBuilder\",\n\t\t);\n\t}\n\n\t/**\n\t * Sets the pattern to redirect to (Required)\n\t *\n\t * @param path the path to redirect to, :channelId in path will be replaced with the selected user's id\n\t * @param query any query parameters you want to add, :channelId will be replaced with the selected user's id\n\t * @param method method to send to route\n\t */\n\tpublic setPattern<P extends Path>({\n\t\tmethod,\n\t\tpath,\n\t\tquery,\n\t}: SetOptions<P>): this;\n\t/**\n\t * Sets the path to route to when clicked\n\t *\n\t * @param path the path to route to\n\t */\n\tpublic setPattern<P extends Path>(path: P): this;\n\n\tpublic setPattern<P extends Path>(arg: P | SetOptions<P>) {\n\t\tconst {\n\t\t\tmethod = \"GET\",\n\t\t\tpath,\n\t\t\tquery,\n\t\t} = isSetOptions(arg) ? arg : { path: arg };\n\t\tsuper.setCustomId(\n\t\t\tencodePath({\n\t\t\t\tidPrefix: this.#embedRouter.getIdPrefix(),\n\t\t\t\tmethod,\n\t\t\t\tpath,\n\t\t\t\tquery,\n\t\t\t}),\n\t\t);\n\n\t\treturn this;\n\t}\n}\n","import {\n\tAPIRoleSelectComponent,\n\tRoleSelectMenuBuilder,\n\tRoleSelectMenuComponentData,\n} from \"discord.js\";\nimport { EmbedRouter } from \"../EmbedRouter\";\nimport { Path } from \"path-to-regexp\";\nimport { encodePath } from \"../helpers/encodePath\";\nimport { isSetOptions, SetOptions } from \"../types/componentBuilders\";\n\nexport class RouteRoleSelectMenuBuilder<L> extends RoleSelectMenuBuilder {\n\t#embedRouter: EmbedRouter<L>;\n\n\t/**\n\t *\n\t * @param embedRouter the router you want to route with\n\t * @param data the data to construct a component out of\n\t */\n\tconstructor(\n\t\tembedRouter: EmbedRouter<L>,\n\t\tdata?:\n\t\t\tPartial<RoleSelectMenuComponentData | APIRoleSelectComponent> | undefined,\n\t) {\n\t\tsuper(data);\n\n\t\tthis.#embedRouter = embedRouter;\n\t}\n\n\t/**\n\t * Not supported for RouteRoleSelectMenuBuilder (customId set from embedRouter)\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride setCustomId(): this {\n\t\tthrow new Error(\n\t\t\t\"setCustomId is not supported on RouteRoleSelectMenuBuilder\",\n\t\t);\n\t}\n\n\t/**\n\t * Sets the pattern to redirect to (Required)\n\t *\n\t * @param path the path to redirect to, :roleId in path will be replaced with the selected user's id\n\t * @param query any query parameters you want to add, :roleId will be replaced with the selected user's id\n\t * @param method method to send to route\n\t */\n\tpublic setPattern<P extends Path>({\n\t\tmethod,\n\t\tpath,\n\t\tquery,\n\t}: SetOptions<P>): this;\n\t/**\n\t * Sets the path to route to when clicked\n\t *\n\t * @param path the path to route to\n\t */\n\tpublic setPattern<P extends Path>(path: P): this;\n\n\tpublic setPattern<P extends Path>(arg: P | SetOptions<P>) {\n\t\tconst {\n\t\t\tmethod = \"GET\",\n\t\t\tpath,\n\t\t\tquery,\n\t\t} = isSetOptions(arg) ? arg : { path: arg };\n\t\tsuper.setCustomId(\n\t\t\tencodePath({\n\t\t\t\tidPrefix: this.#embedRouter.getIdPrefix(),\n\t\t\t\tmethod,\n\t\t\t\tpath,\n\t\t\t\tquery,\n\t\t\t}),\n\t\t);\n\n\t\treturn this;\n\t}\n}\n","import {\n\tAPIUserSelectComponent,\n\tUserSelectMenuBuilder,\n\tUserSelectMenuComponentData,\n} from \"discord.js\";\nimport { EmbedRouter } from \"../EmbedRouter\";\nimport { Path } from \"path-to-regexp\";\nimport { encodePath } from \"../helpers/encodePath\";\nimport { isSetOptions, SetOptions } from \"../types/componentBuilders\";\n\nexport class RouteUserSelectMenuBuilder<L> extends UserSelectMenuBuilder {\n\t#embedRouter: EmbedRouter<L>;\n\n\t/**\n\t *\n\t * @param embedRouter the router you want to route with\n\t * @param data the data to construct a component out of\n\t */\n\tconstructor(\n\t\tembedRouter: EmbedRouter<L>,\n\t\tdata?:\n\t\t\tPartial<UserSelectMenuComponentData | APIUserSelectComponent> | undefined,\n\t) {\n\t\tsuper(data);\n\n\t\tthis.#embedRouter = embedRouter;\n\t}\n\n\t/**\n\t * Not supported for RouteUserSelectMenuBuilder (customId set from embedRouter)\n\t *\n\t * @remarks\n\t * @param\n\t */\n\toverride setCustomId(): this {\n\t\tthrow new Error(\n\t\t\t\"setCustomId is not supported on RouteUserSelectMenuBuilder\",\n\t\t);\n\t}\n\n\t/**\n\t * Sets the pattern to redirect to (Required)\n\t *\n\t * @param path the path to redirect to, :userId in path will be replaced with the selected user's id\n\t * @param query any query parameters you want to add, :userId will be replaced with the selected user's id\n\t * @param method method to send to route\n\t */\n\tpublic setPattern<P extends Path>({\n\t\tmethod,\n\t\tpath,\n\t\tquery,\n\t}: SetOptions<P>): this;\n\t/**\n\t * Sets the path to route to when clicked\n\t *\n\t * @param path the path to route to\n\t */\n\tpublic setPattern<P extends Path>(path: P): this;\n\n\tpublic setPattern<P extends Path>(arg: P | SetOptions<P>) {\n\t\tconst {\n\t\t\tmethod = \"GET\",\n\t\t\tpath,\n\t\t\tquery,\n\t\t} = isSetOptions(arg) ? arg : { path: arg };\n\t\tsuper.setCustomId(\n\t\t\tencodePath({\n\t\t\t\tidPrefix: this.#embedRouter.getIdPrefix(),\n\t\t\t\tmethod,\n\t\t\t\tpath,\n\t\t\t\tquery,\n\t\t\t}),\n\t\t);\n\n\t\treturn this;\n\t}\n}\n"],"mappings":";AAAA,OAAO,UAAU;AACjB,SAAS,kBAAkB;AAC3B,SAAS,aAAgC;;;ACAlC,IAAM,YAAY;AAClB,IAAM,qBAA6C;AAAA,EACzD,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,QAAQ;AACT;AACO,IAAM,qBAA6C;AAAA,EACzD,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACJ;AAEO,IAAM,WAAW;AAEjB,IAAM,YAAY;AAClB,IAAM,UAAU;AAChB,IAAM,YAAY,UAAU,YAAY;;;ACtB/C,SAAS,OAAa,WAAW,iBAAiB;AAE3C,IAAM,eAAe,CAC3BA,OACA,gBAAgB,SACJ;AACZ,MAAI,eAAe;AAClB,WAAO,UAAUA,iBAAgB,YAAYA,QAAO,MAAMA,KAAI,CAAC;AAAA,EAChE;AACA,SAAO,OAAOA,UAAS,WAAWA,QAAO,UAAUA,KAAI;AACxD;;;ACVA,SAAS,eAAqB;AAKvB,IAAM,aAAa,CAAC;AAAA,EAC1B;AAAA,EACA;AACD,MAG8C;AAC7C,QAAM,WAAW,YAAY;AAC7B,MAAI,CAAC,SAAS,WAAW,QAAQ,EAAG,QAAO;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MACA;AAAA,IACD,IAAI,aAAa,GAAG,IAAI,MAAM,EAAE,MAAM,IAAI;AAC1C,UAAM;AAAA,MACL,WAAW;AAAA,QACV,UAAU,KAAK,aAAa,YAAY;AAAA,QACxC;AAAA,QACA,MAAAA;AAAA,QACA;AAAA,MACD,CAAC;AAAA,IACF;AAEA,WAAO;AAAA,EACR;AACD;;;AC5EA;AAAA,EAEC;AAAA,OAEM;AAMA,IAAM,6BAAN,cAA4C,sBAAsB;AAAA,EACxE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,YACC,aACA,MAEC;AACD,UAAM,IAAI;AAEV,SAAK,eAAe;AAAA,EACrB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQS,cAAoB;AAC5B,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AAAA,EAqBO,WAA2B,KAAwB;AACzD,UAAM;AAAA,MACL,SAAS;AAAA,MACT,MAAAC;AAAA,MACA;AAAA,IACD,IAAI,aAAa,GAAG,IAAI,MAAM,EAAE,MAAM,IAAI;AAC1C,UAAM;AAAA,MACL,WAAW;AAAA,QACV,UAAU,KAAK,aAAa,YAAY;AAAA,QACxC;AAAA,QACA,MAAAA;AAAA,QACA;AAAA,MACD,CAAC;AAAA,IACF;AAEA,WAAO;AAAA,EACR;AACD;","names":["path","path","path","path","path","path","path","path","path","path"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "discord-embed-router",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "A vite inspired router for discord.js embeds and interactions",
5
5
  "files": [
6
6
  "dist"
@@ -29,6 +29,7 @@
29
29
  "scripts": {
30
30
  "build": "tsup",
31
31
  "lint": "eslint",
32
+ "typecheck": "tsc --noEmit",
32
33
  "format": "prettier . --write"
33
34
  },
34
35
  "homepage": "https://github.com/altrup/discord-embed-router#readme",