discord-embed-router 0.2.0 → 0.2.2
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 +136 -42
- package/dist/index.d.ts +136 -42
- package/dist/index.js +250 -120
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +251 -123
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ParamData, Path, MatchFunction, MatchResult, TokenData } from 'path-to-regexp';
|
|
2
|
-
import { Interaction, InteractionEditReplyOptions, ButtonInteraction, AnySelectMenuInteraction, InteractionReplyOptions, ButtonBuilder, APIButtonComponent, StringSelectMenuOptionBuilder,
|
|
2
|
+
import { Interaction, InteractionEditReplyOptions, ButtonInteraction, AnySelectMenuInteraction, InteractionReplyOptions, ButtonBuilder, APIButtonComponent, StringSelectMenuOptionBuilder, StringSelectMenuBuilder, StringSelectMenuComponentData, APIStringSelectComponent, RestOrArray, ChannelSelectMenuBuilder, ChannelSelectMenuComponentData, APIChannelSelectComponent, RoleSelectMenuBuilder, RoleSelectMenuComponentData, APIRoleSelectComponent, UserSelectMenuBuilder, UserSelectMenuComponentData, APIUserSelectComponent } from 'discord.js';
|
|
3
3
|
|
|
4
4
|
type State<L, P extends ParamData = ParamData> = MatchResult<P> & {
|
|
5
5
|
embedRouter: EmbedRouter<L>;
|
|
@@ -8,7 +8,9 @@ type State<L, P extends ParamData = ParamData> = MatchResult<P> & {
|
|
|
8
8
|
};
|
|
9
9
|
type RouteResponse = InteractionEditReplyOptions;
|
|
10
10
|
type RouteHandler<L, P extends ParamData = ParamData> = (interaction: Interaction, state: State<L, P>) => Promise<RouteResponse> | RouteResponse;
|
|
11
|
+
type Method = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
11
12
|
type CompiledRoute<L, P extends ParamData = ParamData> = {
|
|
13
|
+
method: Method;
|
|
12
14
|
path: Path[];
|
|
13
15
|
matchFunction: MatchFunction<P>;
|
|
14
16
|
handler: RouteHandler<L, P>;
|
|
@@ -31,22 +33,17 @@ type ExtractParams<T extends string | TokenData, Depth extends string = ""> = T
|
|
|
31
33
|
}) & ExtractParams<After, Depth> : ExtractParams<Rest, Depth> : Char extends "{" ? ExtractParams<Rest, `${Depth}1`> : Char extends "}" ? ExtractParams<Rest, Depth extends `1${infer Rest2}` ? Rest2 : Depth> : ExtractParams<Rest, Depth> : object : never;
|
|
32
34
|
|
|
33
35
|
declare class EmbedRouter<L> {
|
|
34
|
-
private
|
|
35
|
-
private name;
|
|
36
|
-
private idPrefix;
|
|
37
|
-
private identifier;
|
|
36
|
+
#private;
|
|
38
37
|
getIdPrefix(): string;
|
|
39
|
-
private routes;
|
|
40
38
|
/**
|
|
41
39
|
*
|
|
42
40
|
* @param name the name to give the router. ensures buttons stay connected across restarts
|
|
43
41
|
* @param idPrefix the prefix for RouteButtonBuilder customIds
|
|
44
42
|
*/
|
|
45
43
|
constructor({ name, idPrefix, }?: {
|
|
46
|
-
name?: string;
|
|
47
|
-
idPrefix?: string;
|
|
44
|
+
name?: string | undefined;
|
|
45
|
+
idPrefix?: string | undefined;
|
|
48
46
|
});
|
|
49
|
-
private updateIdentifier;
|
|
50
47
|
/**
|
|
51
48
|
* Registers a path with the router
|
|
52
49
|
*
|
|
@@ -54,6 +51,34 @@ declare class EmbedRouter<L> {
|
|
|
54
51
|
* @param handler function that generates the message when a path is matched
|
|
55
52
|
*/
|
|
56
53
|
get<P extends Path = Path>(routePath: P | P[], handler: RouteHandler<L, ExtractParams<P>>): void;
|
|
54
|
+
/**
|
|
55
|
+
* Registers a path with the router
|
|
56
|
+
*
|
|
57
|
+
* @param routePath path to match with
|
|
58
|
+
* @param handler function that generates the message when a path is matched
|
|
59
|
+
*/
|
|
60
|
+
post<P extends Path = Path>(routePath: P | P[], handler: RouteHandler<L, ExtractParams<P>>): void;
|
|
61
|
+
/**
|
|
62
|
+
* Registers a path with the router
|
|
63
|
+
*
|
|
64
|
+
* @param routePath path to match with
|
|
65
|
+
* @param handler function that generates the message when a path is matched
|
|
66
|
+
*/
|
|
67
|
+
put<P extends Path = Path>(routePath: P | P[], handler: RouteHandler<L, ExtractParams<P>>): void;
|
|
68
|
+
/**
|
|
69
|
+
* Registers a path with the router
|
|
70
|
+
*
|
|
71
|
+
* @param routePath path to match with
|
|
72
|
+
* @param handler function that generates the message when a path is matched
|
|
73
|
+
*/
|
|
74
|
+
patch<P extends Path = Path>(routePath: P | P[], handler: RouteHandler<L, ExtractParams<P>>): void;
|
|
75
|
+
/**
|
|
76
|
+
* Registers a path with the router
|
|
77
|
+
*
|
|
78
|
+
* @param routePath path to match with
|
|
79
|
+
* @param handler function that generates the message when a path is matched
|
|
80
|
+
*/
|
|
81
|
+
delete<P extends Path = Path>(routePath: P | P[], handler: RouteHandler<L, ExtractParams<P>>): void;
|
|
57
82
|
/**
|
|
58
83
|
* Adds a subrouter to the router
|
|
59
84
|
*
|
|
@@ -66,26 +91,38 @@ declare class EmbedRouter<L> {
|
|
|
66
91
|
*
|
|
67
92
|
* @param interaction interactions from "interactionCreate" (filter for ButtonInteractions)
|
|
68
93
|
*/
|
|
69
|
-
listener(interaction: ButtonInteraction | AnySelectMenuInteraction, locals?: L): Promise<void>;
|
|
94
|
+
listener(interaction: ButtonInteraction | AnySelectMenuInteraction, locals?: L | undefined): Promise<void>;
|
|
70
95
|
/**
|
|
71
96
|
* Connect or update an interaction message to a path
|
|
72
97
|
*
|
|
73
98
|
* @param interaction interaction to connect to
|
|
74
99
|
* @param path path to route the interaction to
|
|
100
|
+
* @param method method to send to route
|
|
75
101
|
* @param flags optional discord flags to send with message (only allowed on first reply)
|
|
76
102
|
*/
|
|
77
|
-
dispatch<P extends Path = Path>(interaction
|
|
78
|
-
|
|
103
|
+
dispatch<P extends Path = Path>({ interaction, method, path, flags, locals, }: {
|
|
104
|
+
interaction: Interaction;
|
|
105
|
+
method?: Method;
|
|
106
|
+
path: P;
|
|
107
|
+
flags?: InteractionReplyOptions["flags"] | undefined;
|
|
108
|
+
locals?: L | undefined;
|
|
109
|
+
}): Promise<void>;
|
|
79
110
|
}
|
|
80
111
|
|
|
112
|
+
type SetOptions<P extends Path> = {
|
|
113
|
+
method?: Method;
|
|
114
|
+
path: P;
|
|
115
|
+
query?: ConstructorParameters<typeof URLSearchParams>[0] | undefined;
|
|
116
|
+
};
|
|
117
|
+
|
|
81
118
|
declare class RouteButtonBuilder<L> extends ButtonBuilder {
|
|
82
|
-
private
|
|
119
|
+
#private;
|
|
83
120
|
/**
|
|
84
121
|
*
|
|
85
122
|
* @param embedRouter the router you want to route with
|
|
86
123
|
* @param data the data to construct a component out of
|
|
87
124
|
*/
|
|
88
|
-
constructor(embedRouter: EmbedRouter<L>, data?: Omit<Partial<APIButtonComponent>, "custom_id" | "url">);
|
|
125
|
+
constructor(embedRouter: EmbedRouter<L>, data?: Omit<Partial<APIButtonComponent>, "custom_id" | "url"> | undefined);
|
|
89
126
|
/**
|
|
90
127
|
* Not supported for RouteButtonBuilder
|
|
91
128
|
*
|
|
@@ -105,18 +142,18 @@ declare class RouteButtonBuilder<L> extends ButtonBuilder {
|
|
|
105
142
|
*
|
|
106
143
|
* @param path the path to route to
|
|
107
144
|
* @param query any query parameters you want to add
|
|
145
|
+
* @param method method to send to route
|
|
108
146
|
*/
|
|
109
|
-
setTo<P extends Path>(
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
declare class RouteStringSelectMenuOptionBuilder extends StringSelectMenuOptionBuilder {
|
|
147
|
+
setTo<P extends Path>({ method, path, query }: SetOptions<P>): this;
|
|
113
148
|
/**
|
|
149
|
+
* Sets the path to route to when clicked
|
|
114
150
|
*
|
|
115
|
-
* @param
|
|
151
|
+
* @param path the path to route to
|
|
116
152
|
*/
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
153
|
+
setTo<P extends Path>(path: P): this;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
declare class RouteStringSelectMenuOptionBuilder extends StringSelectMenuOptionBuilder {
|
|
120
157
|
/**
|
|
121
158
|
* Not supported for RouteStringSelectMenuOptionBuilder (use setTo)
|
|
122
159
|
*
|
|
@@ -129,12 +166,19 @@ declare class RouteStringSelectMenuOptionBuilder extends StringSelectMenuOptionB
|
|
|
129
166
|
*
|
|
130
167
|
* @param path the path to route to
|
|
131
168
|
* @param query any query parameters you want to add
|
|
169
|
+
* @param method method to send to route
|
|
132
170
|
*/
|
|
133
|
-
setTo<P extends Path>(
|
|
171
|
+
setTo<P extends Path>({ method, path, query }: SetOptions<P>): this;
|
|
172
|
+
/**
|
|
173
|
+
* Sets the path to route to when clicked
|
|
174
|
+
*
|
|
175
|
+
* @param path the path to route to
|
|
176
|
+
*/
|
|
177
|
+
setTo<P extends Path>(path: P): this;
|
|
134
178
|
}
|
|
135
179
|
|
|
136
|
-
declare class RouteStringSelectMenuBuilder<L
|
|
137
|
-
private
|
|
180
|
+
declare class RouteStringSelectMenuBuilder<L> extends StringSelectMenuBuilder {
|
|
181
|
+
#private;
|
|
138
182
|
/**
|
|
139
183
|
*
|
|
140
184
|
* @param embedRouter the router you want to route with
|
|
@@ -142,7 +186,7 @@ declare class RouteStringSelectMenuBuilder<L, P extends Path> extends StringSele
|
|
|
142
186
|
* @param query any query parameters you want to add, :to will be replaced with the selected user's id
|
|
143
187
|
* @param data the data to construct a component out of
|
|
144
188
|
*/
|
|
145
|
-
constructor(embedRouter: EmbedRouter<L>,
|
|
189
|
+
constructor(embedRouter: EmbedRouter<L>, data?: Partial<StringSelectMenuComponentData | APIStringSelectComponent> | undefined);
|
|
146
190
|
/**
|
|
147
191
|
* Not supported for RouteStringSelectMenuBuilder (customId set from embedRouter)
|
|
148
192
|
*
|
|
@@ -176,18 +220,30 @@ declare class RouteStringSelectMenuBuilder<L, P extends Path> extends StringSele
|
|
|
176
220
|
* @param tos the list of route select menu options
|
|
177
221
|
*/
|
|
178
222
|
setTos(...tos: RestOrArray<RouteStringSelectMenuOptionBuilder | ConstructorParameters<typeof RouteStringSelectMenuOptionBuilder>[0]>): this;
|
|
223
|
+
/**
|
|
224
|
+
* Sets the pattern to redirect to (Required)
|
|
225
|
+
*
|
|
226
|
+
* @param path the path to redirect to, :to or *to in path will be replaced with the selected user's id
|
|
227
|
+
* @param query any query parameters you want to add, :to will be replaced with the selected user's id
|
|
228
|
+
* @param method method to send to route
|
|
229
|
+
*/
|
|
230
|
+
setPattern<P extends Path>({ method, path, query, }: SetOptions<P>): this;
|
|
231
|
+
/**
|
|
232
|
+
* Sets the path to route to when clicked
|
|
233
|
+
*
|
|
234
|
+
* @param path the path to route to
|
|
235
|
+
*/
|
|
236
|
+
setPattern<P extends Path>(path: P): this;
|
|
179
237
|
}
|
|
180
238
|
|
|
181
|
-
declare class RouteChannelSelectMenuBuilder<L
|
|
182
|
-
private
|
|
239
|
+
declare class RouteChannelSelectMenuBuilder<L> extends ChannelSelectMenuBuilder {
|
|
240
|
+
#private;
|
|
183
241
|
/**
|
|
184
242
|
*
|
|
185
243
|
* @param embedRouter the router you want to route with
|
|
186
|
-
* @param path the path to redirect to, :channelId in path will be replaced with the selected user's id
|
|
187
|
-
* @param query any query parameters you want to add, :channelId will be replaced with the selected user's id
|
|
188
244
|
* @param data the data to construct a component out of
|
|
189
245
|
*/
|
|
190
|
-
constructor(embedRouter: EmbedRouter<L>,
|
|
246
|
+
constructor(embedRouter: EmbedRouter<L>, data?: Partial<ChannelSelectMenuComponentData | APIChannelSelectComponent> | undefined);
|
|
191
247
|
/**
|
|
192
248
|
* Not supported for RouteChannelSelectMenuBuilder (customId set from embedRouter)
|
|
193
249
|
*
|
|
@@ -195,18 +251,30 @@ declare class RouteChannelSelectMenuBuilder<L, P extends Path> extends ChannelSe
|
|
|
195
251
|
* @param
|
|
196
252
|
*/
|
|
197
253
|
setCustomId(): this;
|
|
254
|
+
/**
|
|
255
|
+
* Sets the pattern to redirect to (Required)
|
|
256
|
+
*
|
|
257
|
+
* @param path the path to redirect to, :channelId in path will be replaced with the selected user's id
|
|
258
|
+
* @param query any query parameters you want to add, :channelId will be replaced with the selected user's id
|
|
259
|
+
* @param method method to send to route
|
|
260
|
+
*/
|
|
261
|
+
setPattern<P extends Path>({ method, path, query, }: SetOptions<P>): this;
|
|
262
|
+
/**
|
|
263
|
+
* Sets the path to route to when clicked
|
|
264
|
+
*
|
|
265
|
+
* @param path the path to route to
|
|
266
|
+
*/
|
|
267
|
+
setPattern<P extends Path>(path: P): this;
|
|
198
268
|
}
|
|
199
269
|
|
|
200
|
-
declare class RouteRoleSelectMenuBuilder<L
|
|
201
|
-
private
|
|
270
|
+
declare class RouteRoleSelectMenuBuilder<L> extends RoleSelectMenuBuilder {
|
|
271
|
+
#private;
|
|
202
272
|
/**
|
|
203
273
|
*
|
|
204
274
|
* @param embedRouter the router you want to route with
|
|
205
|
-
* @param path the path to redirect to, :roleId in path will be replaced with the selected user's id
|
|
206
|
-
* @param query any query parameters you want to add, :roleId will be replaced with the selected user's id
|
|
207
275
|
* @param data the data to construct a component out of
|
|
208
276
|
*/
|
|
209
|
-
constructor(embedRouter: EmbedRouter<L>,
|
|
277
|
+
constructor(embedRouter: EmbedRouter<L>, data?: Partial<RoleSelectMenuComponentData | APIRoleSelectComponent> | undefined);
|
|
210
278
|
/**
|
|
211
279
|
* Not supported for RouteRoleSelectMenuBuilder (customId set from embedRouter)
|
|
212
280
|
*
|
|
@@ -214,18 +282,30 @@ declare class RouteRoleSelectMenuBuilder<L, P extends Path> extends RoleSelectMe
|
|
|
214
282
|
* @param
|
|
215
283
|
*/
|
|
216
284
|
setCustomId(): this;
|
|
285
|
+
/**
|
|
286
|
+
* Sets the pattern to redirect to (Required)
|
|
287
|
+
*
|
|
288
|
+
* @param path the path to redirect to, :roleId in path will be replaced with the selected user's id
|
|
289
|
+
* @param query any query parameters you want to add, :roleId will be replaced with the selected user's id
|
|
290
|
+
* @param method method to send to route
|
|
291
|
+
*/
|
|
292
|
+
setPattern<P extends Path>({ method, path, query, }: SetOptions<P>): this;
|
|
293
|
+
/**
|
|
294
|
+
* Sets the path to route to when clicked
|
|
295
|
+
*
|
|
296
|
+
* @param path the path to route to
|
|
297
|
+
*/
|
|
298
|
+
setPattern<P extends Path>(path: P): this;
|
|
217
299
|
}
|
|
218
300
|
|
|
219
|
-
declare class RouteUserSelectMenuBuilder<L
|
|
220
|
-
private
|
|
301
|
+
declare class RouteUserSelectMenuBuilder<L> extends UserSelectMenuBuilder {
|
|
302
|
+
#private;
|
|
221
303
|
/**
|
|
222
304
|
*
|
|
223
305
|
* @param embedRouter the router you want to route with
|
|
224
|
-
* @param path the path to redirect to, :userId in path will be replaced with the selected user's id
|
|
225
|
-
* @param query any query parameters you want to add, :userId will be replaced with the selected user's id
|
|
226
306
|
* @param data the data to construct a component out of
|
|
227
307
|
*/
|
|
228
|
-
constructor(embedRouter: EmbedRouter<L>,
|
|
308
|
+
constructor(embedRouter: EmbedRouter<L>, data?: Partial<UserSelectMenuComponentData | APIUserSelectComponent> | undefined);
|
|
229
309
|
/**
|
|
230
310
|
* Not supported for RouteUserSelectMenuBuilder (customId set from embedRouter)
|
|
231
311
|
*
|
|
@@ -233,6 +313,20 @@ declare class RouteUserSelectMenuBuilder<L, P extends Path> extends UserSelectMe
|
|
|
233
313
|
* @param
|
|
234
314
|
*/
|
|
235
315
|
setCustomId(): this;
|
|
316
|
+
/**
|
|
317
|
+
* Sets the pattern to redirect to (Required)
|
|
318
|
+
*
|
|
319
|
+
* @param path the path to redirect to, :userId in path will be replaced with the selected user's id
|
|
320
|
+
* @param query any query parameters you want to add, :userId will be replaced with the selected user's id
|
|
321
|
+
* @param method method to send to route
|
|
322
|
+
*/
|
|
323
|
+
setPattern<P extends Path>({ method, path, query, }: SetOptions<P>): this;
|
|
324
|
+
/**
|
|
325
|
+
* Sets the path to route to when clicked
|
|
326
|
+
*
|
|
327
|
+
* @param path the path to route to
|
|
328
|
+
*/
|
|
329
|
+
setPattern<P extends Path>(path: P): this;
|
|
236
330
|
}
|
|
237
331
|
|
|
238
|
-
export { type CompiledRoute, EmbedRouter, type ResolvedRoute, RouteButtonBuilder, RouteChannelSelectMenuBuilder, type RouteHandler, type RouteResponse, RouteRoleSelectMenuBuilder, RouteStringSelectMenuBuilder, RouteStringSelectMenuOptionBuilder, RouteUserSelectMenuBuilder, type State };
|
|
332
|
+
export { type CompiledRoute, EmbedRouter, type Method, type ResolvedRoute, RouteButtonBuilder, RouteChannelSelectMenuBuilder, type RouteHandler, type RouteResponse, RouteRoleSelectMenuBuilder, RouteStringSelectMenuBuilder, RouteStringSelectMenuOptionBuilder, RouteUserSelectMenuBuilder, type State };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ParamData, Path, MatchFunction, MatchResult, TokenData } from 'path-to-regexp';
|
|
2
|
-
import { Interaction, InteractionEditReplyOptions, ButtonInteraction, AnySelectMenuInteraction, InteractionReplyOptions, ButtonBuilder, APIButtonComponent, StringSelectMenuOptionBuilder,
|
|
2
|
+
import { Interaction, InteractionEditReplyOptions, ButtonInteraction, AnySelectMenuInteraction, InteractionReplyOptions, ButtonBuilder, APIButtonComponent, StringSelectMenuOptionBuilder, StringSelectMenuBuilder, StringSelectMenuComponentData, APIStringSelectComponent, RestOrArray, ChannelSelectMenuBuilder, ChannelSelectMenuComponentData, APIChannelSelectComponent, RoleSelectMenuBuilder, RoleSelectMenuComponentData, APIRoleSelectComponent, UserSelectMenuBuilder, UserSelectMenuComponentData, APIUserSelectComponent } from 'discord.js';
|
|
3
3
|
|
|
4
4
|
type State<L, P extends ParamData = ParamData> = MatchResult<P> & {
|
|
5
5
|
embedRouter: EmbedRouter<L>;
|
|
@@ -8,7 +8,9 @@ type State<L, P extends ParamData = ParamData> = MatchResult<P> & {
|
|
|
8
8
|
};
|
|
9
9
|
type RouteResponse = InteractionEditReplyOptions;
|
|
10
10
|
type RouteHandler<L, P extends ParamData = ParamData> = (interaction: Interaction, state: State<L, P>) => Promise<RouteResponse> | RouteResponse;
|
|
11
|
+
type Method = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
11
12
|
type CompiledRoute<L, P extends ParamData = ParamData> = {
|
|
13
|
+
method: Method;
|
|
12
14
|
path: Path[];
|
|
13
15
|
matchFunction: MatchFunction<P>;
|
|
14
16
|
handler: RouteHandler<L, P>;
|
|
@@ -31,22 +33,17 @@ type ExtractParams<T extends string | TokenData, Depth extends string = ""> = T
|
|
|
31
33
|
}) & ExtractParams<After, Depth> : ExtractParams<Rest, Depth> : Char extends "{" ? ExtractParams<Rest, `${Depth}1`> : Char extends "}" ? ExtractParams<Rest, Depth extends `1${infer Rest2}` ? Rest2 : Depth> : ExtractParams<Rest, Depth> : object : never;
|
|
32
34
|
|
|
33
35
|
declare class EmbedRouter<L> {
|
|
34
|
-
private
|
|
35
|
-
private name;
|
|
36
|
-
private idPrefix;
|
|
37
|
-
private identifier;
|
|
36
|
+
#private;
|
|
38
37
|
getIdPrefix(): string;
|
|
39
|
-
private routes;
|
|
40
38
|
/**
|
|
41
39
|
*
|
|
42
40
|
* @param name the name to give the router. ensures buttons stay connected across restarts
|
|
43
41
|
* @param idPrefix the prefix for RouteButtonBuilder customIds
|
|
44
42
|
*/
|
|
45
43
|
constructor({ name, idPrefix, }?: {
|
|
46
|
-
name?: string;
|
|
47
|
-
idPrefix?: string;
|
|
44
|
+
name?: string | undefined;
|
|
45
|
+
idPrefix?: string | undefined;
|
|
48
46
|
});
|
|
49
|
-
private updateIdentifier;
|
|
50
47
|
/**
|
|
51
48
|
* Registers a path with the router
|
|
52
49
|
*
|
|
@@ -54,6 +51,34 @@ declare class EmbedRouter<L> {
|
|
|
54
51
|
* @param handler function that generates the message when a path is matched
|
|
55
52
|
*/
|
|
56
53
|
get<P extends Path = Path>(routePath: P | P[], handler: RouteHandler<L, ExtractParams<P>>): void;
|
|
54
|
+
/**
|
|
55
|
+
* Registers a path with the router
|
|
56
|
+
*
|
|
57
|
+
* @param routePath path to match with
|
|
58
|
+
* @param handler function that generates the message when a path is matched
|
|
59
|
+
*/
|
|
60
|
+
post<P extends Path = Path>(routePath: P | P[], handler: RouteHandler<L, ExtractParams<P>>): void;
|
|
61
|
+
/**
|
|
62
|
+
* Registers a path with the router
|
|
63
|
+
*
|
|
64
|
+
* @param routePath path to match with
|
|
65
|
+
* @param handler function that generates the message when a path is matched
|
|
66
|
+
*/
|
|
67
|
+
put<P extends Path = Path>(routePath: P | P[], handler: RouteHandler<L, ExtractParams<P>>): void;
|
|
68
|
+
/**
|
|
69
|
+
* Registers a path with the router
|
|
70
|
+
*
|
|
71
|
+
* @param routePath path to match with
|
|
72
|
+
* @param handler function that generates the message when a path is matched
|
|
73
|
+
*/
|
|
74
|
+
patch<P extends Path = Path>(routePath: P | P[], handler: RouteHandler<L, ExtractParams<P>>): void;
|
|
75
|
+
/**
|
|
76
|
+
* Registers a path with the router
|
|
77
|
+
*
|
|
78
|
+
* @param routePath path to match with
|
|
79
|
+
* @param handler function that generates the message when a path is matched
|
|
80
|
+
*/
|
|
81
|
+
delete<P extends Path = Path>(routePath: P | P[], handler: RouteHandler<L, ExtractParams<P>>): void;
|
|
57
82
|
/**
|
|
58
83
|
* Adds a subrouter to the router
|
|
59
84
|
*
|
|
@@ -66,26 +91,38 @@ declare class EmbedRouter<L> {
|
|
|
66
91
|
*
|
|
67
92
|
* @param interaction interactions from "interactionCreate" (filter for ButtonInteractions)
|
|
68
93
|
*/
|
|
69
|
-
listener(interaction: ButtonInteraction | AnySelectMenuInteraction, locals?: L): Promise<void>;
|
|
94
|
+
listener(interaction: ButtonInteraction | AnySelectMenuInteraction, locals?: L | undefined): Promise<void>;
|
|
70
95
|
/**
|
|
71
96
|
* Connect or update an interaction message to a path
|
|
72
97
|
*
|
|
73
98
|
* @param interaction interaction to connect to
|
|
74
99
|
* @param path path to route the interaction to
|
|
100
|
+
* @param method method to send to route
|
|
75
101
|
* @param flags optional discord flags to send with message (only allowed on first reply)
|
|
76
102
|
*/
|
|
77
|
-
dispatch<P extends Path = Path>(interaction
|
|
78
|
-
|
|
103
|
+
dispatch<P extends Path = Path>({ interaction, method, path, flags, locals, }: {
|
|
104
|
+
interaction: Interaction;
|
|
105
|
+
method?: Method;
|
|
106
|
+
path: P;
|
|
107
|
+
flags?: InteractionReplyOptions["flags"] | undefined;
|
|
108
|
+
locals?: L | undefined;
|
|
109
|
+
}): Promise<void>;
|
|
79
110
|
}
|
|
80
111
|
|
|
112
|
+
type SetOptions<P extends Path> = {
|
|
113
|
+
method?: Method;
|
|
114
|
+
path: P;
|
|
115
|
+
query?: ConstructorParameters<typeof URLSearchParams>[0] | undefined;
|
|
116
|
+
};
|
|
117
|
+
|
|
81
118
|
declare class RouteButtonBuilder<L> extends ButtonBuilder {
|
|
82
|
-
private
|
|
119
|
+
#private;
|
|
83
120
|
/**
|
|
84
121
|
*
|
|
85
122
|
* @param embedRouter the router you want to route with
|
|
86
123
|
* @param data the data to construct a component out of
|
|
87
124
|
*/
|
|
88
|
-
constructor(embedRouter: EmbedRouter<L>, data?: Omit<Partial<APIButtonComponent>, "custom_id" | "url">);
|
|
125
|
+
constructor(embedRouter: EmbedRouter<L>, data?: Omit<Partial<APIButtonComponent>, "custom_id" | "url"> | undefined);
|
|
89
126
|
/**
|
|
90
127
|
* Not supported for RouteButtonBuilder
|
|
91
128
|
*
|
|
@@ -105,18 +142,18 @@ declare class RouteButtonBuilder<L> extends ButtonBuilder {
|
|
|
105
142
|
*
|
|
106
143
|
* @param path the path to route to
|
|
107
144
|
* @param query any query parameters you want to add
|
|
145
|
+
* @param method method to send to route
|
|
108
146
|
*/
|
|
109
|
-
setTo<P extends Path>(
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
declare class RouteStringSelectMenuOptionBuilder extends StringSelectMenuOptionBuilder {
|
|
147
|
+
setTo<P extends Path>({ method, path, query }: SetOptions<P>): this;
|
|
113
148
|
/**
|
|
149
|
+
* Sets the path to route to when clicked
|
|
114
150
|
*
|
|
115
|
-
* @param
|
|
151
|
+
* @param path the path to route to
|
|
116
152
|
*/
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
153
|
+
setTo<P extends Path>(path: P): this;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
declare class RouteStringSelectMenuOptionBuilder extends StringSelectMenuOptionBuilder {
|
|
120
157
|
/**
|
|
121
158
|
* Not supported for RouteStringSelectMenuOptionBuilder (use setTo)
|
|
122
159
|
*
|
|
@@ -129,12 +166,19 @@ declare class RouteStringSelectMenuOptionBuilder extends StringSelectMenuOptionB
|
|
|
129
166
|
*
|
|
130
167
|
* @param path the path to route to
|
|
131
168
|
* @param query any query parameters you want to add
|
|
169
|
+
* @param method method to send to route
|
|
132
170
|
*/
|
|
133
|
-
setTo<P extends Path>(
|
|
171
|
+
setTo<P extends Path>({ method, path, query }: SetOptions<P>): this;
|
|
172
|
+
/**
|
|
173
|
+
* Sets the path to route to when clicked
|
|
174
|
+
*
|
|
175
|
+
* @param path the path to route to
|
|
176
|
+
*/
|
|
177
|
+
setTo<P extends Path>(path: P): this;
|
|
134
178
|
}
|
|
135
179
|
|
|
136
|
-
declare class RouteStringSelectMenuBuilder<L
|
|
137
|
-
private
|
|
180
|
+
declare class RouteStringSelectMenuBuilder<L> extends StringSelectMenuBuilder {
|
|
181
|
+
#private;
|
|
138
182
|
/**
|
|
139
183
|
*
|
|
140
184
|
* @param embedRouter the router you want to route with
|
|
@@ -142,7 +186,7 @@ declare class RouteStringSelectMenuBuilder<L, P extends Path> extends StringSele
|
|
|
142
186
|
* @param query any query parameters you want to add, :to will be replaced with the selected user's id
|
|
143
187
|
* @param data the data to construct a component out of
|
|
144
188
|
*/
|
|
145
|
-
constructor(embedRouter: EmbedRouter<L>,
|
|
189
|
+
constructor(embedRouter: EmbedRouter<L>, data?: Partial<StringSelectMenuComponentData | APIStringSelectComponent> | undefined);
|
|
146
190
|
/**
|
|
147
191
|
* Not supported for RouteStringSelectMenuBuilder (customId set from embedRouter)
|
|
148
192
|
*
|
|
@@ -176,18 +220,30 @@ declare class RouteStringSelectMenuBuilder<L, P extends Path> extends StringSele
|
|
|
176
220
|
* @param tos the list of route select menu options
|
|
177
221
|
*/
|
|
178
222
|
setTos(...tos: RestOrArray<RouteStringSelectMenuOptionBuilder | ConstructorParameters<typeof RouteStringSelectMenuOptionBuilder>[0]>): this;
|
|
223
|
+
/**
|
|
224
|
+
* Sets the pattern to redirect to (Required)
|
|
225
|
+
*
|
|
226
|
+
* @param path the path to redirect to, :to or *to in path will be replaced with the selected user's id
|
|
227
|
+
* @param query any query parameters you want to add, :to will be replaced with the selected user's id
|
|
228
|
+
* @param method method to send to route
|
|
229
|
+
*/
|
|
230
|
+
setPattern<P extends Path>({ method, path, query, }: SetOptions<P>): this;
|
|
231
|
+
/**
|
|
232
|
+
* Sets the path to route to when clicked
|
|
233
|
+
*
|
|
234
|
+
* @param path the path to route to
|
|
235
|
+
*/
|
|
236
|
+
setPattern<P extends Path>(path: P): this;
|
|
179
237
|
}
|
|
180
238
|
|
|
181
|
-
declare class RouteChannelSelectMenuBuilder<L
|
|
182
|
-
private
|
|
239
|
+
declare class RouteChannelSelectMenuBuilder<L> extends ChannelSelectMenuBuilder {
|
|
240
|
+
#private;
|
|
183
241
|
/**
|
|
184
242
|
*
|
|
185
243
|
* @param embedRouter the router you want to route with
|
|
186
|
-
* @param path the path to redirect to, :channelId in path will be replaced with the selected user's id
|
|
187
|
-
* @param query any query parameters you want to add, :channelId will be replaced with the selected user's id
|
|
188
244
|
* @param data the data to construct a component out of
|
|
189
245
|
*/
|
|
190
|
-
constructor(embedRouter: EmbedRouter<L>,
|
|
246
|
+
constructor(embedRouter: EmbedRouter<L>, data?: Partial<ChannelSelectMenuComponentData | APIChannelSelectComponent> | undefined);
|
|
191
247
|
/**
|
|
192
248
|
* Not supported for RouteChannelSelectMenuBuilder (customId set from embedRouter)
|
|
193
249
|
*
|
|
@@ -195,18 +251,30 @@ declare class RouteChannelSelectMenuBuilder<L, P extends Path> extends ChannelSe
|
|
|
195
251
|
* @param
|
|
196
252
|
*/
|
|
197
253
|
setCustomId(): this;
|
|
254
|
+
/**
|
|
255
|
+
* Sets the pattern to redirect to (Required)
|
|
256
|
+
*
|
|
257
|
+
* @param path the path to redirect to, :channelId in path will be replaced with the selected user's id
|
|
258
|
+
* @param query any query parameters you want to add, :channelId will be replaced with the selected user's id
|
|
259
|
+
* @param method method to send to route
|
|
260
|
+
*/
|
|
261
|
+
setPattern<P extends Path>({ method, path, query, }: SetOptions<P>): this;
|
|
262
|
+
/**
|
|
263
|
+
* Sets the path to route to when clicked
|
|
264
|
+
*
|
|
265
|
+
* @param path the path to route to
|
|
266
|
+
*/
|
|
267
|
+
setPattern<P extends Path>(path: P): this;
|
|
198
268
|
}
|
|
199
269
|
|
|
200
|
-
declare class RouteRoleSelectMenuBuilder<L
|
|
201
|
-
private
|
|
270
|
+
declare class RouteRoleSelectMenuBuilder<L> extends RoleSelectMenuBuilder {
|
|
271
|
+
#private;
|
|
202
272
|
/**
|
|
203
273
|
*
|
|
204
274
|
* @param embedRouter the router you want to route with
|
|
205
|
-
* @param path the path to redirect to, :roleId in path will be replaced with the selected user's id
|
|
206
|
-
* @param query any query parameters you want to add, :roleId will be replaced with the selected user's id
|
|
207
275
|
* @param data the data to construct a component out of
|
|
208
276
|
*/
|
|
209
|
-
constructor(embedRouter: EmbedRouter<L>,
|
|
277
|
+
constructor(embedRouter: EmbedRouter<L>, data?: Partial<RoleSelectMenuComponentData | APIRoleSelectComponent> | undefined);
|
|
210
278
|
/**
|
|
211
279
|
* Not supported for RouteRoleSelectMenuBuilder (customId set from embedRouter)
|
|
212
280
|
*
|
|
@@ -214,18 +282,30 @@ declare class RouteRoleSelectMenuBuilder<L, P extends Path> extends RoleSelectMe
|
|
|
214
282
|
* @param
|
|
215
283
|
*/
|
|
216
284
|
setCustomId(): this;
|
|
285
|
+
/**
|
|
286
|
+
* Sets the pattern to redirect to (Required)
|
|
287
|
+
*
|
|
288
|
+
* @param path the path to redirect to, :roleId in path will be replaced with the selected user's id
|
|
289
|
+
* @param query any query parameters you want to add, :roleId will be replaced with the selected user's id
|
|
290
|
+
* @param method method to send to route
|
|
291
|
+
*/
|
|
292
|
+
setPattern<P extends Path>({ method, path, query, }: SetOptions<P>): this;
|
|
293
|
+
/**
|
|
294
|
+
* Sets the path to route to when clicked
|
|
295
|
+
*
|
|
296
|
+
* @param path the path to route to
|
|
297
|
+
*/
|
|
298
|
+
setPattern<P extends Path>(path: P): this;
|
|
217
299
|
}
|
|
218
300
|
|
|
219
|
-
declare class RouteUserSelectMenuBuilder<L
|
|
220
|
-
private
|
|
301
|
+
declare class RouteUserSelectMenuBuilder<L> extends UserSelectMenuBuilder {
|
|
302
|
+
#private;
|
|
221
303
|
/**
|
|
222
304
|
*
|
|
223
305
|
* @param embedRouter the router you want to route with
|
|
224
|
-
* @param path the path to redirect to, :userId in path will be replaced with the selected user's id
|
|
225
|
-
* @param query any query parameters you want to add, :userId will be replaced with the selected user's id
|
|
226
306
|
* @param data the data to construct a component out of
|
|
227
307
|
*/
|
|
228
|
-
constructor(embedRouter: EmbedRouter<L>,
|
|
308
|
+
constructor(embedRouter: EmbedRouter<L>, data?: Partial<UserSelectMenuComponentData | APIUserSelectComponent> | undefined);
|
|
229
309
|
/**
|
|
230
310
|
* Not supported for RouteUserSelectMenuBuilder (customId set from embedRouter)
|
|
231
311
|
*
|
|
@@ -233,6 +313,20 @@ declare class RouteUserSelectMenuBuilder<L, P extends Path> extends UserSelectMe
|
|
|
233
313
|
* @param
|
|
234
314
|
*/
|
|
235
315
|
setCustomId(): this;
|
|
316
|
+
/**
|
|
317
|
+
* Sets the pattern to redirect to (Required)
|
|
318
|
+
*
|
|
319
|
+
* @param path the path to redirect to, :userId in path will be replaced with the selected user's id
|
|
320
|
+
* @param query any query parameters you want to add, :userId will be replaced with the selected user's id
|
|
321
|
+
* @param method method to send to route
|
|
322
|
+
*/
|
|
323
|
+
setPattern<P extends Path>({ method, path, query, }: SetOptions<P>): this;
|
|
324
|
+
/**
|
|
325
|
+
* Sets the path to route to when clicked
|
|
326
|
+
*
|
|
327
|
+
* @param path the path to route to
|
|
328
|
+
*/
|
|
329
|
+
setPattern<P extends Path>(path: P): this;
|
|
236
330
|
}
|
|
237
331
|
|
|
238
|
-
export { type CompiledRoute, EmbedRouter, type ResolvedRoute, RouteButtonBuilder, RouteChannelSelectMenuBuilder, type RouteHandler, type RouteResponse, RouteRoleSelectMenuBuilder, RouteStringSelectMenuBuilder, RouteStringSelectMenuOptionBuilder, RouteUserSelectMenuBuilder, type State };
|
|
332
|
+
export { type CompiledRoute, EmbedRouter, type Method, type ResolvedRoute, RouteButtonBuilder, RouteChannelSelectMenuBuilder, type RouteHandler, type RouteResponse, RouteRoleSelectMenuBuilder, RouteStringSelectMenuBuilder, RouteStringSelectMenuOptionBuilder, RouteUserSelectMenuBuilder, type State };
|