@hyperneutrino/djs-lite 1.1.0 → 1.2.1

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 +17 -17
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -31,7 +31,7 @@ process.on("uncaughtException", (err) => console.error(err));
31
31
 
32
32
  type Handler<T extends CommandInteraction | AutocompleteInteraction | MessageComponentInteraction | ModalSubmitInteraction> = (
33
33
  interaction: T,
34
- ...args: any[]
34
+ ...args: T extends MessageComponentInteraction | ModalSubmitInteraction ? (string | undefined)[] : []
35
35
  ) => Awaitable<unknown>;
36
36
 
37
37
  abstract class Command<T extends BaseApplicationCommandData, U extends CommandInteraction, Z extends boolean = false> {
@@ -57,7 +57,7 @@ export class SlashCommand extends Command<ChatInputApplicationCommandData & { ty
57
57
  export class UserCommand extends Command<UserApplicationCommandData, UserContextMenuCommandInteraction> {}
58
58
  export class MessageCommand extends Command<MessageApplicationCommandData, MessageContextMenuCommandInteraction> {}
59
59
 
60
- abstract class ComponentResponder<T extends ModalSubmitInteraction | MessageComponentInteraction> {
60
+ abstract class ComponentHandler<T extends ModalSubmitInteraction | MessageComponentInteraction> {
61
61
  handler: Handler<T>;
62
62
 
63
63
  constructor(handler: Handler<T>) {
@@ -65,13 +65,13 @@ abstract class ComponentResponder<T extends ModalSubmitInteraction | MessageComp
65
65
  }
66
66
  }
67
67
 
68
- export class ModalResponder extends ComponentResponder<ModalSubmitInteraction> {}
69
- export class ButtonResponder extends ComponentResponder<ButtonInteraction> {}
70
- export class StringSelectResponder extends ComponentResponder<StringSelectMenuInteraction> {}
71
- export class UserSelectResponder extends ComponentResponder<UserSelectMenuInteraction> {}
72
- export class RoleSelectResponder extends ComponentResponder<RoleSelectMenuInteraction> {}
73
- export class MentionSelectResponder extends ComponentResponder<MentionableSelectMenuInteraction> {}
74
- export class ChannelSelectResponder extends ComponentResponder<ChannelSelectMenuInteraction> {}
68
+ export class ModalHandler extends ComponentHandler<ModalSubmitInteraction> {}
69
+ export class ButtonHandler extends ComponentHandler<ButtonInteraction> {}
70
+ export class StringSelectHandler extends ComponentHandler<StringSelectMenuInteraction> {}
71
+ export class UserSelectHandler extends ComponentHandler<UserSelectMenuInteraction> {}
72
+ export class RoleSelectHandler extends ComponentHandler<RoleSelectMenuInteraction> {}
73
+ export class MentionSelectHandler extends ComponentHandler<MentionableSelectMenuInteraction> {}
74
+ export class ChannelSelectHandler extends ComponentHandler<ChannelSelectMenuInteraction> {}
75
75
 
76
76
  export class EventHandler<T extends keyof ClientEvents> {
77
77
  event: T;
@@ -155,14 +155,14 @@ export async function loadInteractions(client: Client<true>, directory: string,
155
155
 
156
156
  const { default: item } = await import(absolutePath).catch(() => null);
157
157
 
158
- if (item instanceof ModalResponder) modalHandlers.set(handlerKey, item.handler);
159
- else if (item instanceof ButtonResponder) buttonHandlers.set(handlerKey, item.handler);
160
- else if (item instanceof StringSelectResponder) stringHandlers.set(handlerKey, item.handler);
161
- else if (item instanceof UserSelectResponder) userHandlers.set(handlerKey, item.handler);
162
- else if (item instanceof RoleSelectResponder) roleHandlers.set(handlerKey, item.handler);
163
- else if (item instanceof MentionSelectResponder) mentionHandlers.set(handlerKey, item.handler);
164
- else if (item instanceof ChannelSelectResponder) channelHandlers.set(handlerKey, item.handler);
165
- else throw new Error(`Loading interactions failed: export from ${relativePath} was not an instance of <InteractionType>Responder.`);
158
+ if (item instanceof ModalHandler) modalHandlers.set(handlerKey, item.handler);
159
+ else if (item instanceof ButtonHandler) buttonHandlers.set(handlerKey, item.handler);
160
+ else if (item instanceof StringSelectHandler) stringHandlers.set(handlerKey, item.handler);
161
+ else if (item instanceof UserSelectHandler) userHandlers.set(handlerKey, item.handler);
162
+ else if (item instanceof RoleSelectHandler) roleHandlers.set(handlerKey, item.handler);
163
+ else if (item instanceof MentionSelectHandler) mentionHandlers.set(handlerKey, item.handler);
164
+ else if (item instanceof ChannelSelectHandler) channelHandlers.set(handlerKey, item.handler);
165
+ else throw new Error(`Loading interactions failed: export from ${relativePath} was not an instance of <InteractionType>Handler.`);
166
166
  }),
167
167
  );
168
168
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hyperneutrino/djs-lite",
3
3
  "private": false,
4
- "version": "1.1.0",
4
+ "version": "1.2.1",
5
5
  "module": "index.ts",
6
6
  "type": "module",
7
7
  "devDependencies": {