@hyperneutrino/djs-lite 1.4.2 → 1.4.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/index.ts +21 -15
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -232,27 +232,29 @@ export async function loadCommands(client: Client<true>, directory: string, guil
|
|
|
232
232
|
} else {
|
|
233
233
|
await client.application.commands.set(commandData);
|
|
234
234
|
}
|
|
235
|
+
|
|
236
|
+
return { commands: commandData, slashCommandHandlers, userCommandHandlers, messageCommandHandlers };
|
|
235
237
|
}
|
|
236
238
|
|
|
237
239
|
export async function loadInteractions(client: Client, directory: string, argumentSeparator: string = ":") {
|
|
238
240
|
const modalHandlers = new Map<string, Handler<ModalSubmitInteraction>>();
|
|
239
241
|
const buttonHandlers = new Map<string, Handler<ButtonInteraction>>();
|
|
240
|
-
const
|
|
241
|
-
const
|
|
242
|
-
const
|
|
243
|
-
const
|
|
244
|
-
const
|
|
242
|
+
const stringSelectHandlers = new Map<string, Handler<StringSelectMenuInteraction>>();
|
|
243
|
+
const userSelectHandlers = new Map<string, Handler<UserSelectMenuInteraction>>();
|
|
244
|
+
const roleSelectHandlers = new Map<string, Handler<RoleSelectMenuInteraction>>();
|
|
245
|
+
const mentionSelectHandlers = new Map<string, Handler<MentionableSelectMenuInteraction>>();
|
|
246
|
+
const channelSelectHandlers = new Map<string, Handler<ChannelSelectMenuInteraction>>();
|
|
245
247
|
|
|
246
248
|
await importAll({ directory, recursive: true }, async ({ relativePath, item }) => {
|
|
247
249
|
const handlerKey = relativePath.replace(/\.[^/.]+$/, "").replace(/\\/g, "/");
|
|
248
250
|
|
|
249
251
|
if (item instanceof ModalHandler) modalHandlers.set(handlerKey, item.handler);
|
|
250
252
|
else if (item instanceof ButtonHandler) buttonHandlers.set(handlerKey, item.handler);
|
|
251
|
-
else if (item instanceof StringSelectHandler)
|
|
252
|
-
else if (item instanceof UserSelectHandler)
|
|
253
|
-
else if (item instanceof RoleSelectHandler)
|
|
254
|
-
else if (item instanceof MentionSelectHandler)
|
|
255
|
-
else if (item instanceof ChannelSelectHandler)
|
|
253
|
+
else if (item instanceof StringSelectHandler) stringSelectHandlers.set(handlerKey, item.handler);
|
|
254
|
+
else if (item instanceof UserSelectHandler) userSelectHandlers.set(handlerKey, item.handler);
|
|
255
|
+
else if (item instanceof RoleSelectHandler) roleSelectHandlers.set(handlerKey, item.handler);
|
|
256
|
+
else if (item instanceof MentionSelectHandler) mentionSelectHandlers.set(handlerKey, item.handler);
|
|
257
|
+
else if (item instanceof ChannelSelectHandler) channelSelectHandlers.set(handlerKey, item.handler);
|
|
256
258
|
else throw new Error(`Loading interactions failed: export from ${relativePath} was not an instance of <InteractionType>Handler.`);
|
|
257
259
|
});
|
|
258
260
|
|
|
@@ -264,12 +266,14 @@ export async function loadInteractions(client: Client, directory: string, argume
|
|
|
264
266
|
|
|
265
267
|
if (interaction.isModalSubmit()) modalHandlers.get(path)?.(interaction, ...args);
|
|
266
268
|
else if (interaction.isButton()) buttonHandlers.get(path)?.(interaction, ...args);
|
|
267
|
-
else if (interaction.isStringSelectMenu())
|
|
268
|
-
else if (interaction.isUserSelectMenu())
|
|
269
|
-
else if (interaction.isRoleSelectMenu())
|
|
270
|
-
else if (interaction.isMentionableSelectMenu())
|
|
271
|
-
else if (interaction.isChannelSelectMenu())
|
|
269
|
+
else if (interaction.isStringSelectMenu()) stringSelectHandlers.get(path)?.(interaction, ...args);
|
|
270
|
+
else if (interaction.isUserSelectMenu()) userSelectHandlers.get(path)?.(interaction, ...args);
|
|
271
|
+
else if (interaction.isRoleSelectMenu()) roleSelectHandlers.get(path)?.(interaction, ...args);
|
|
272
|
+
else if (interaction.isMentionableSelectMenu()) mentionSelectHandlers.get(path)?.(interaction, ...args);
|
|
273
|
+
else if (interaction.isChannelSelectMenu()) channelSelectHandlers.get(path)?.(interaction, ...args);
|
|
272
274
|
});
|
|
275
|
+
|
|
276
|
+
return { modalHandlers, buttonHandlers, stringSelectHandlers, userSelectHandlers, roleSelectHandlers, mentionSelectHandlers, channelSelectHandlers };
|
|
273
277
|
}
|
|
274
278
|
|
|
275
279
|
export async function loadEvents(client: Client, directory: string, recursive: boolean = false) {
|
|
@@ -283,4 +287,6 @@ export async function loadEvents(client: Client, directory: string, recursive: b
|
|
|
283
287
|
});
|
|
284
288
|
|
|
285
289
|
Object.entries(handlers).forEach(([key, handlers]) => client.on(key, (...args) => handlers.forEach((handler) => (handler as any)(...args))));
|
|
290
|
+
|
|
291
|
+
return { handlers };
|
|
286
292
|
}
|