@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.
Files changed (2) hide show
  1. package/index.ts +21 -15
  2. 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 stringHandlers = new Map<string, Handler<StringSelectMenuInteraction>>();
241
- const userHandlers = new Map<string, Handler<UserSelectMenuInteraction>>();
242
- const roleHandlers = new Map<string, Handler<RoleSelectMenuInteraction>>();
243
- const mentionHandlers = new Map<string, Handler<MentionableSelectMenuInteraction>>();
244
- const channelHandlers = new Map<string, Handler<ChannelSelectMenuInteraction>>();
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) stringHandlers.set(handlerKey, item.handler);
252
- else if (item instanceof UserSelectHandler) userHandlers.set(handlerKey, item.handler);
253
- else if (item instanceof RoleSelectHandler) roleHandlers.set(handlerKey, item.handler);
254
- else if (item instanceof MentionSelectHandler) mentionHandlers.set(handlerKey, item.handler);
255
- else if (item instanceof ChannelSelectHandler) channelHandlers.set(handlerKey, item.handler);
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()) stringHandlers.get(path)?.(interaction, ...args);
268
- else if (interaction.isUserSelectMenu()) userHandlers.get(path)?.(interaction, ...args);
269
- else if (interaction.isRoleSelectMenu()) roleHandlers.get(path)?.(interaction, ...args);
270
- else if (interaction.isMentionableSelectMenu()) mentionHandlers.get(path)?.(interaction, ...args);
271
- else if (interaction.isChannelSelectMenu()) channelHandlers.get(path)?.(interaction, ...args);
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
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hyperneutrino/djs-lite",
3
3
  "private": false,
4
- "version": "1.4.2",
4
+ "version": "1.4.3",
5
5
  "module": "index.ts",
6
6
  "type": "module",
7
7
  "devDependencies": {