@@ -24,7 +24,9 @@ import { SlashCommandBuilder } from "@discordjs/builders";
24
24
*
25
25
* @example
26
26
* ```ts
27
- * import { InteractionRouter } from 'discord.https/router';
27
+ * // utility/ping.js
28
+ *
29
+ * import { InteractionRouter } from 'discord.https/router';
28
30
* const router = new InteractionRouter();
29
31
* export deafult router.command(
30
32
* (builder) => builder.setName("Ping!").setDescription("Returns Pong!"),
@@ -88,7 +90,7 @@ class InteractionRouter {
88
90
*
89
91
* This does **not** affect other routers or collectors.
90
92
*
91
- * @param fns Async middleware functions.
93
+ * @param fns Async middleware functions. See { @link GenericMiddleware} for callback parameters
92
94
*/
93
95
94
96
middleware ( ...fns : GeneralMiddleware [ ] ) {
@@ -108,7 +110,7 @@ class InteractionRouter {
108
110
* ```
109
111
*
110
112
* @param commandbuilder - Function returning a {@link SlashCommandBuilder}.
111
- * @param fns - Middleware functions for the command .
113
+ * @param fns { @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function | Async } functions. See { @link GenericMiddleware } for callback parameters .
112
114
* @returns An {@link AutoCompleteKeyBuilder} for autocomplete options.
113
115
*/
114
116
command ( commandbuilder : CommandbuilderType , ...fns : CommandMiddleware [ ] ) {
@@ -126,6 +128,7 @@ class InteractionRouter {
126
128
/**
127
129
* Registers a button interaction with its associated middleware.
128
130
*
131
+ * @param fns {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function | Async } functions. See {@link GenericMiddleware } for callback parameters.
129
132
* @example
130
133
* ```ts
131
134
* router.button("custom_button_id", buttonMiddleware);
@@ -139,6 +142,7 @@ class InteractionRouter {
139
142
/**
140
143
* Registers a modal interaction with its associated middleware.
141
144
*
145
+ * @param fns {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function | Async } functions. See {@link GenericMiddleware } for callback parameters.
142
146
* @example
143
147
* ```ts
144
148
* router.modal("custom_modal_id", modalMiddleware);
@@ -152,6 +156,7 @@ class InteractionRouter {
152
156
/**
153
157
* Registers a role select interaction with its associated middleware.
154
158
*
159
+ * @param fns {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function | Async } functions. See {@link GenericMiddleware } for callback parameters.
155
160
* @example
156
161
* ```ts
157
162
* router.roleSelect("roleSelectName", roleSelectMiddleware);
@@ -165,6 +170,7 @@ class InteractionRouter {
165
170
/**
166
171
* Registers a user select interaction with its associated middleware.
167
172
*
173
+ * @param fns {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function | Async } functions. See {@link GenericMiddleware } for callback parameters.
168
174
* @example
169
175
* ```ts
170
176
* router.userSelect("userSelectName", userSelectMiddleware);
@@ -177,6 +183,7 @@ class InteractionRouter {
177
183
/**
178
184
* Registers a string select interaction with its associated middleware.
179
185
*
186
+ * @param fns {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function | Async } functions. See {@link GenericMiddleware } for callback parameters.
180
187
* @example
181
188
* ```ts
182
189
* router.stringSelect("stringSelectName", stringSelectMiddleware);
@@ -190,6 +197,7 @@ class InteractionRouter {
190
197
/**
191
198
* Registers a channel select interaction with its associated middleware.
192
199
*
200
+ * @param fns {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function | Async } functions. See {@link GenericMiddleware } for callback parameters.
193
201
* @example
194
202
* ```ts
195
203
* router.channelSelect("channelSelectName", channelSelectMiddleware);
@@ -203,6 +211,7 @@ class InteractionRouter {
203
211
/**
204
212
* Registers a mentionable select interaction with its associated middleware.
205
213
*
214
+ * @param fns {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function | Async } functions. See {@link GenericMiddleware } for callback parameters.
206
215
* @example
207
216
* ```ts
208
217
* router.mentionableSelect("mentionableSelectName", mentionableSelectMiddleware);
@@ -216,18 +225,19 @@ class InteractionRouter {
216
225
/**
217
226
* Registers an autocomplete interaction with its associated middleware.
218
227
*
228
+ * @param fns {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function | Async } functions. See {@link GenericMiddleware } for callback parameters.
219
229
* @example
220
230
* ```ts
221
231
* const githubQuery = router.command(
222
232
* (builder) =>
223
233
* builder
224
- * .setName("weather") // The command name
225
- * .setDescription("QuQuery weather information!") // The command description
234
+ * .setName("weather")
235
+ * .setDescription("Query weather information!")
226
236
* .addStringOption(option =>
227
237
* option
228
- * .setName("city") // Option name
229
- * .setDescription("City to get the weather for") // Option description
230
- * .setAutocomplete(true) // Enable autocomplete for this option
238
+ * .setName("city")
239
+ * .setDescription("City to get the weather for")
240
+ * .setAutocomplete(true)
231
241
* ),
232
242
* (interaction) => handler
233
243
* );
@@ -249,6 +259,7 @@ class InteractionRouter {
249
259
/**
250
260
* Registers a user context menu interaction with its associated middleware.
251
261
*
262
+ * @param fns {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function | Async } functions. See {@link GenericMiddleware } for callback parameters.
252
263
* @example
253
264
* ```ts
254
265
* router.userContextMenu("userContextMenuId", userContextMenuMiddleware);
@@ -262,6 +273,7 @@ class InteractionRouter {
262
273
/**
263
274
* Registers a message context menu interaction with its associated middleware.
264
275
*
276
+ * @param fns {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function | Async } functions. See {@link GenericMiddleware } for callback parameters.
265
277
* @example
266
278
* ```ts
267
279
* router.messageContextMenu("messageContextMenu", messageContextMenuMiddleware);
@@ -296,19 +308,25 @@ class InteractionRouter {
296
308
/**
297
309
* Collector for InteractionRouter.
298
310
*
299
- * @example
311
+ *
312
+ * @example
313
+ *
314
+ * Example: Organizing multiple interaction routes with a collector.
315
+ *
300
316
* ```ts
301
- * import { InteractionRouter, InteractionRouterCollector } from ' discord.https/router' ;
317
+ * import { InteractionRouterCollector } from " discord.https/router" ;
302
318
*
303
- * const router = new InteractionRouter()
304
- * router.command(
305
- * (builder) => builder.setName("Ping!").setDescription("Returns Pong!")
306
- * (interaction) => interaction.reply({
307
- * content: "pong!"
308
- * })
309
- * )
310
- * // Register routes
311
- * InteractionRouterCollector.register(router);
319
+ * // Recommend using PascalCase and ending with the 'Route' suffix
320
+ * // for variable naming convention
321
+ *
322
+ * import PingRoute from "./ping.js";
323
+ * import GithubRoute from "./github.js";
324
+ *
325
+ *
326
+ * export default new InteractionRouterCollector().register(
327
+ * PingRoute,
328
+ * GithubRoute
329
+ * );
312
330
* ```
313
331
*/
314
332
0 commit comments