@globalart/nestcord 1.4.2 → 1.5.0

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 (31) hide show
  1. package/dist/core/commands/slash-commands/options/attachment-option.decorator.d.ts +1 -1
  2. package/dist/core/commands/slash-commands/options/boolean-option.decorator.d.ts +1 -1
  3. package/dist/core/commands/slash-commands/options/channel-option.decorator.d.ts +1 -1
  4. package/dist/core/commands/slash-commands/options/integer-option.decorator.d.ts +2 -2
  5. package/dist/core/commands/slash-commands/options/member-option.decorator.d.ts +1 -1
  6. package/dist/core/commands/slash-commands/options/mentionable-option.decorator.d.ts +1 -1
  7. package/dist/core/commands/slash-commands/options/number-option.decorator.d.ts +2 -2
  8. package/dist/core/commands/slash-commands/options/role-option.decorator.d.ts +1 -1
  9. package/dist/core/commands/slash-commands/options/string-option.decorator.d.ts +2 -2
  10. package/dist/core/commands/slash-commands/options/user-option.decorator.d.ts +1 -1
  11. package/dist/core/context/nestcord-base.discovery.d.ts +4 -4
  12. package/dist/core/context/nestcord-base.discovery.js +1 -0
  13. package/dist/core/context/nestcord-params.factory.d.ts +1 -1
  14. package/dist/core/context/nestcord-params.factory.js +2 -1
  15. package/dist/core/listeners/decorators/on.decorator.d.ts +2 -3
  16. package/dist/core/listeners/decorators/on.decorator.js +1 -1
  17. package/dist/core/listeners/decorators/once.decorator.d.ts +2 -3
  18. package/dist/core/listeners/decorators/once.decorator.js +1 -1
  19. package/dist/core/listeners/handlers/base.handler.d.ts +1 -1
  20. package/dist/core/listeners/handlers/base.handler.js +1 -1
  21. package/dist/core/listeners/handlers/guild-member-update.handler.js +10 -5
  22. package/dist/core/listeners/handlers/message-update.handler.js +4 -2
  23. package/dist/core/listeners/handlers/presence-update.handler.js +2 -1
  24. package/dist/core/listeners/handlers/user-update.handler.js +8 -4
  25. package/dist/core/listeners/listener.discovery.d.ts +3 -3
  26. package/dist/core/listeners/listener.discovery.js +1 -1
  27. package/dist/core/listeners/listeners.module.d.ts +1 -1
  28. package/dist/core/listeners/listeners.module.js +14 -3
  29. package/dist/core/message-components/message-component.discovery.d.ts +1 -1
  30. package/dist/localization/interfaces/translate-function.interface.d.ts +1 -1
  31. package/package.json +8 -8
@@ -5,8 +5,8 @@
5
5
  */
6
6
  export declare const AttachmentOption: (data: {
7
7
  name: string;
8
- description: string;
9
8
  name_localizations?: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>>;
9
+ description: string;
10
10
  description_localizations?: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>>;
11
11
  required?: boolean;
12
12
  }) => PropertyDecorator;
@@ -5,8 +5,8 @@
5
5
  */
6
6
  export declare const BooleanOption: (data: {
7
7
  name: string;
8
- description: string;
9
8
  name_localizations?: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>>;
9
+ description: string;
10
10
  description_localizations?: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>>;
11
11
  required?: boolean;
12
12
  }) => PropertyDecorator;
@@ -5,8 +5,8 @@
5
5
  */
6
6
  export declare const ChannelOption: (data: {
7
7
  name: string;
8
- description: string;
9
8
  name_localizations?: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>>;
9
+ description: string;
10
10
  description_localizations?: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>>;
11
11
  required?: boolean;
12
12
  channel_types?: (import("discord.js").ChannelType.GuildText | import("discord.js").ChannelType.GuildVoice | import("discord.js").ChannelType.GuildCategory | import("discord.js").ChannelType.GuildAnnouncement | import("discord.js").ChannelType.AnnouncementThread | import("discord.js").ChannelType.PublicThread | import("discord.js").ChannelType.PrivateThread | import("discord.js").ChannelType.GuildStageVoice | import("discord.js").ChannelType.GuildDirectory | import("discord.js").ChannelType.GuildForum | import("discord.js").ChannelType.GuildMedia)[];
@@ -5,8 +5,8 @@
5
5
  */
6
6
  export declare const IntegerOption: (data: {
7
7
  name: string;
8
- description: string;
9
8
  name_localizations?: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>>;
9
+ description: string;
10
10
  description_localizations?: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>>;
11
11
  required?: boolean;
12
12
  choices?: [];
@@ -15,8 +15,8 @@ export declare const IntegerOption: (data: {
15
15
  autocomplete: true;
16
16
  } | {
17
17
  name: string;
18
- description: string;
19
18
  name_localizations?: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>>;
19
+ description: string;
20
20
  description_localizations?: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>>;
21
21
  required?: boolean;
22
22
  choices?: import("discord.js").APIApplicationCommandOptionChoice<number>[];
@@ -5,8 +5,8 @@
5
5
  */
6
6
  export declare const MemberOption: (data: {
7
7
  name: string;
8
- description: string;
9
8
  name_localizations?: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>>;
9
+ description: string;
10
10
  description_localizations?: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>>;
11
11
  required?: boolean;
12
12
  }) => PropertyDecorator;
@@ -5,8 +5,8 @@
5
5
  */
6
6
  export declare const MentionableOption: (data: {
7
7
  name: string;
8
- description: string;
9
8
  name_localizations?: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>>;
9
+ description: string;
10
10
  description_localizations?: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>>;
11
11
  required?: boolean;
12
12
  }) => PropertyDecorator;
@@ -5,8 +5,8 @@
5
5
  */
6
6
  export declare const NumberOption: (data: {
7
7
  name: string;
8
- description: string;
9
8
  name_localizations?: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>>;
9
+ description: string;
10
10
  description_localizations?: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>>;
11
11
  required?: boolean;
12
12
  choices?: [];
@@ -15,8 +15,8 @@ export declare const NumberOption: (data: {
15
15
  autocomplete: true;
16
16
  } | {
17
17
  name: string;
18
- description: string;
19
18
  name_localizations?: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>>;
19
+ description: string;
20
20
  description_localizations?: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>>;
21
21
  required?: boolean;
22
22
  choices?: import("discord.js").APIApplicationCommandOptionChoice<number>[];
@@ -5,8 +5,8 @@
5
5
  */
6
6
  export declare const RoleOption: (data: {
7
7
  name: string;
8
- description: string;
9
8
  name_localizations?: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>>;
9
+ description: string;
10
10
  description_localizations?: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>>;
11
11
  required?: boolean;
12
12
  }) => PropertyDecorator;
@@ -5,8 +5,8 @@
5
5
  */
6
6
  export declare const StringOption: (data: {
7
7
  name: string;
8
- description: string;
9
8
  name_localizations?: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>>;
9
+ description: string;
10
10
  description_localizations?: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>>;
11
11
  required?: boolean;
12
12
  choices?: [];
@@ -15,8 +15,8 @@ export declare const StringOption: (data: {
15
15
  max_length?: number;
16
16
  } | {
17
17
  name: string;
18
- description: string;
19
18
  name_localizations?: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>>;
19
+ description: string;
20
20
  description_localizations?: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>>;
21
21
  required?: boolean;
22
22
  choices?: import("discord.js").APIApplicationCommandOptionChoice<string>[];
@@ -5,8 +5,8 @@
5
5
  */
6
6
  export declare const UserOption: (data: {
7
7
  name: string;
8
- description: string;
9
8
  name_localizations?: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>>;
9
+ description: string;
10
10
  description_localizations?: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>>;
11
11
  required?: boolean;
12
12
  }) => PropertyDecorator;
@@ -6,19 +6,19 @@ import { TextCommandDiscovery } from '../text-commands';
6
6
  import { ModalDiscovery } from '../modals';
7
7
  interface DiscoveredItem {
8
8
  class: any;
9
- handler?: (...args: any[]) => any;
9
+ handler?: (...args: unknown[]) => void;
10
10
  }
11
- export declare abstract class NestCordBaseDiscovery<T = any> {
11
+ export declare abstract class NestCordBaseDiscovery<T = unknown> {
12
12
  protected readonly meta: T;
13
13
  protected readonly reflector: Reflector;
14
14
  protected discovery: DiscoveredItem;
15
15
  protected contextCallback: Function;
16
16
  constructor(meta: T);
17
17
  getClass(): any;
18
- getHandler(): (...args: any[]) => any;
18
+ getHandler(): (...args: unknown[]) => void;
19
19
  setDiscoveryMeta(meta: DiscoveredItem): void;
20
20
  setContextCallback(fn: Function): void;
21
- execute(context?: any): any;
21
+ execute(context?: unknown): any;
22
22
  isContextMenu(): this is ContextMenuDiscovery;
23
23
  isSlashCommand(): this is SlashCommandDiscovery;
24
24
  isMessageComponent(): this is MessageComponentDiscovery;
@@ -18,6 +18,7 @@ class NestCordBaseDiscovery {
18
18
  setDiscoveryMeta(meta) {
19
19
  this.discovery || (this.discovery = meta);
20
20
  }
21
+ // eslint-disable-next-line @typescript-eslint/ban-types
21
22
  setContextCallback(fn) {
22
23
  this.contextCallback || (this.contextCallback = fn);
23
24
  }
@@ -2,5 +2,5 @@ import { ParamsFactory } from '@nestjs/core/helpers/external-context-creator';
2
2
  import { NestCordBaseDiscovery } from '.';
3
3
  import { ParamData } from '@nestjs/common';
4
4
  export declare class NestCordParamsFactory implements ParamsFactory {
5
- exchangeKeyForValue(type: number, data: ParamData, args: [Array<any>, NestCordBaseDiscovery]): any;
5
+ exchangeKeyForValue(type: number, data: ParamData, args: [Array<unknown>, NestCordBaseDiscovery]): unknown[] | NestCordBaseDiscovery<unknown>;
6
6
  }
@@ -4,8 +4,9 @@ exports.NestCordParamsFactory = void 0;
4
4
  const nestcord_paramtype_enum_1 = require("./nestcord-paramtype.enum");
5
5
  class NestCordParamsFactory {
6
6
  exchangeKeyForValue(type, data, args) {
7
- if (!args)
7
+ if (!args) {
8
8
  return null;
9
+ }
9
10
  switch (type) {
10
11
  case nestcord_paramtype_enum_1.NestCordParamType.CONTEXT:
11
12
  return args[0];
@@ -1,7 +1,6 @@
1
- import { NestCordEvents } from '../listener.interface';
2
1
  /**
3
2
  * Decorator that marks a method as a listener for discord.js client.
4
- * @param event The event name.
3
+ * @param event - The event or events name.
5
4
  * @returns The decorated method.
6
5
  */
7
- export declare const On: <K extends keyof E, E = NestCordEvents>(event: K) => import("@nestjs/common").CustomDecorator;
6
+ export declare const On: <K extends keyof import("discord.js").ClientEvents | "guildChannelPermissionsUpdate" | keyof import("..").CustomGuildAuditLogEntryCreateEvents | keyof import("..").CustomGuildMemberUpdateEvents | keyof import("..").CustomGuildUpdateEvents | keyof import("..").CustomMessageUpdateEvents | keyof import("..").CustomPresenceUpdateEvents | keyof import("..").CustomRoleUpdateEvents | keyof import("..").CustomThreadUpdateEvents | keyof import("..").CustomUserUpdateEvents | keyof import("..").CustomVoiceStateUpdateEvents>(event: K | K[]) => import("@nestjs/common").CustomDecorator;
@@ -4,7 +4,7 @@ exports.On = void 0;
4
4
  const listener_decorator_1 = require("./listener.decorator");
5
5
  /**
6
6
  * Decorator that marks a method as a listener for discord.js client.
7
- * @param event The event name.
7
+ * @param event - The event or events name.
8
8
  * @returns The decorated method.
9
9
  */
10
10
  const On = (event) => (0, listener_decorator_1.Listener)({ type: 'on', event });
@@ -1,7 +1,6 @@
1
- import { NestCordEvents } from '../listener.interface';
2
1
  /**
3
2
  * Decorator that marks a method as a listener for discord.js client.
4
- * @param event
3
+ * @param event - The event name to listen for once.
5
4
  * @returns The decorated method.
6
5
  */
7
- export declare const Once: <K extends keyof E, E = NestCordEvents>(event: K) => import("@nestjs/common").CustomDecorator;
6
+ export declare const Once: <K extends keyof import("discord.js").ClientEvents | "guildChannelPermissionsUpdate" | keyof import("..").CustomGuildAuditLogEntryCreateEvents | keyof import("..").CustomGuildMemberUpdateEvents | keyof import("..").CustomGuildUpdateEvents | keyof import("..").CustomMessageUpdateEvents | keyof import("..").CustomPresenceUpdateEvents | keyof import("..").CustomRoleUpdateEvents | keyof import("..").CustomThreadUpdateEvents | keyof import("..").CustomUserUpdateEvents | keyof import("..").CustomVoiceStateUpdateEvents>(event: K | K[]) => import("@nestjs/common").CustomDecorator;
@@ -4,7 +4,7 @@ exports.Once = void 0;
4
4
  const listener_decorator_1 = require("./listener.decorator");
5
5
  /**
6
6
  * Decorator that marks a method as a listener for discord.js client.
7
- * @param event
7
+ * @param event - The event name to listen for once.
8
8
  * @returns The decorated method.
9
9
  */
10
10
  const Once = (event) => (0, listener_decorator_1.Listener)({ type: 'once', event });
@@ -1,7 +1,7 @@
1
1
  import { ClientEvents } from 'discord.js';
2
2
  import { NestCordEvents } from '../listener.interface';
3
3
  type OnlyCustomEvents = Exclude<NestCordEvents, ClientEvents>;
4
- export declare abstract class BaseHandler<Events extends Record<string, Array<any>> = OnlyCustomEvents> {
4
+ export declare abstract class BaseHandler<Events extends Record<string, Array<unknown>> = OnlyCustomEvents> {
5
5
  private readonly client;
6
6
  protected on<K extends keyof Events>(event: K, fn: (args: Events[K]) => void): void;
7
7
  protected emit<K extends keyof Events>(event: K, ...args: Events[K]): void;
@@ -14,7 +14,7 @@ const discord_js_1 = require("discord.js");
14
14
  const common_1 = require("@nestjs/common");
15
15
  class BaseHandler {
16
16
  on(event, fn) {
17
- this.client.on(event, (...args) => fn.call(this, args));
17
+ this.client.on(event, (...args) => fn(args));
18
18
  }
19
19
  emit(event, ...args) {
20
20
  this.client.emit(event, ...args);
@@ -15,8 +15,9 @@ const decorators_1 = require("../decorators");
15
15
  const base_handler_1 = require("./base.handler");
16
16
  let GuildMemberUpdateHandler = class GuildMemberUpdateHandler extends base_handler_1.BaseHandler {
17
17
  handleGuildMemberAvatar([oldMember, newMember]) {
18
- if (oldMember.partial)
18
+ if (oldMember.partial) {
19
19
  return;
20
+ }
20
21
  if (!oldMember.avatar && newMember.avatar) {
21
22
  this.emit('guildMemberAvatarAdd', newMember, newMember.avatarURL());
22
23
  }
@@ -28,8 +29,9 @@ let GuildMemberUpdateHandler = class GuildMemberUpdateHandler extends base_handl
28
29
  }
29
30
  }
30
31
  handleGuildMemberRoles([oldMember, newMember]) {
31
- if (oldMember.partial)
32
+ if (oldMember.partial) {
32
33
  return;
34
+ }
33
35
  const addedRoles = newMember.roles.cache.reduce((acc, role) => (!oldMember.roles.cache.has(role.id) ? acc.push(role) && acc : acc), []);
34
36
  addedRoles.forEach((role) => {
35
37
  this.emit('guildMemberRoleAdd', newMember, role);
@@ -40,8 +42,9 @@ let GuildMemberUpdateHandler = class GuildMemberUpdateHandler extends base_handl
40
42
  });
41
43
  }
42
44
  handleGuildMemberBoosting([oldMember, newMember]) {
43
- if (oldMember.partial)
45
+ if (oldMember.partial) {
44
46
  return;
47
+ }
45
48
  if (!oldMember.premiumSince && newMember.premiumSince) {
46
49
  this.emit('guildMemberBoost', newMember);
47
50
  }
@@ -50,15 +53,17 @@ let GuildMemberUpdateHandler = class GuildMemberUpdateHandler extends base_handl
50
53
  }
51
54
  }
52
55
  handleGuildMemberNicknameUpdate([oldMember, newMember]) {
53
- if (oldMember.partial)
56
+ if (oldMember.partial) {
54
57
  return;
58
+ }
55
59
  if (oldMember.nickname !== newMember.nickname) {
56
60
  this.emit('guildMemberNicknameUpdate', newMember, oldMember.nickname, newMember.nickname);
57
61
  }
58
62
  }
59
63
  handleGuildMemberEntered([oldMember, newMember]) {
60
- if (oldMember.partial)
64
+ if (oldMember.partial) {
61
65
  return;
66
+ }
62
67
  if (oldMember.pending !== newMember.pending) {
63
68
  this.emit('guildMemberEntered', newMember);
64
69
  }
@@ -15,15 +15,17 @@ const decorators_1 = require("../decorators");
15
15
  const common_1 = require("@nestjs/common");
16
16
  let MessageUpdateHandler = class MessageUpdateHandler extends base_handler_1.BaseHandler {
17
17
  handleMessagePinned([oldMessage, newMessage]) {
18
- if (oldMessage.partial || newMessage.partial)
18
+ if (oldMessage.partial || newMessage.partial) {
19
19
  return;
20
+ }
20
21
  if (!oldMessage.pinned && newMessage.pinned) {
21
22
  this.emit('messagePinned', newMessage);
22
23
  }
23
24
  }
24
25
  handleMessageContentEdited([oldMessage, newMessage]) {
25
- if (oldMessage.partial || newMessage.partial)
26
+ if (oldMessage.partial || newMessage.partial) {
26
27
  return;
28
+ }
27
29
  if (oldMessage.content !== newMessage.content) {
28
30
  this.emit('messageContentEdited', newMessage, oldMessage.content, newMessage.content);
29
31
  }
@@ -15,8 +15,9 @@ const common_1 = require("@nestjs/common");
15
15
  const decorators_1 = require("../decorators");
16
16
  let PresenceUpdateHandler = class PresenceUpdateHandler extends base_handler_1.BaseHandler {
17
17
  handlePresenceUpdate([oldPresence, newPresence]) {
18
- if (!oldPresence)
18
+ if (!oldPresence) {
19
19
  return;
20
+ }
20
21
  if (oldPresence.status !== 'offline' && newPresence.status === 'offline') {
21
22
  this.emit('guildMemberOffline', newPresence.member, oldPresence.status);
22
23
  }
@@ -15,29 +15,33 @@ const decorators_1 = require("../decorators");
15
15
  const base_handler_1 = require("./base.handler");
16
16
  let UserUpdateHandler = class UserUpdateHandler extends base_handler_1.BaseHandler {
17
17
  handleUserAvatarUpdate([oldUser, newUser]) {
18
- if (oldUser.partial)
18
+ if (oldUser.partial) {
19
19
  return;
20
+ }
20
21
  if (oldUser.displayAvatarURL() !== newUser.displayAvatarURL()) {
21
22
  this.emit('userAvatarUpdate', newUser, oldUser.displayAvatarURL(), newUser.displayAvatarURL());
22
23
  }
23
24
  }
24
25
  handleUserUsernameUpdate([oldUser, newUser]) {
25
- if (oldUser.partial)
26
+ if (oldUser.partial) {
26
27
  return;
28
+ }
27
29
  if (oldUser.username !== newUser.username) {
28
30
  this.emit('userUsernameUpdate', newUser, oldUser.username, newUser.username);
29
31
  }
30
32
  }
31
33
  handleUserDiscriminatorUpdate([oldUser, newUser]) {
32
- if (oldUser.partial)
34
+ if (oldUser.partial) {
33
35
  return;
36
+ }
34
37
  if (oldUser.discriminator !== newUser.discriminator) {
35
38
  this.emit('userDiscriminatorUpdate', newUser, oldUser.discriminator, newUser.discriminator);
36
39
  }
37
40
  }
38
41
  handleUserFlagsUpdate([oldUser, newUser]) {
39
- if (oldUser.partial)
42
+ if (oldUser.partial) {
40
43
  return;
44
+ }
41
45
  if (oldUser.flags !== newUser.flags) {
42
46
  this.emit('userFlagsUpdate', newUser, oldUser.flags, newUser.flags);
43
47
  }
@@ -1,14 +1,14 @@
1
1
  import { NestCordBaseDiscovery } from '../context';
2
2
  export interface ListenerMeta {
3
3
  type: 'once' | 'on';
4
- event: string | symbol | number;
4
+ event: string | string[];
5
5
  }
6
6
  /**
7
7
  * Represents a listener discovery.
8
8
  */
9
9
  export declare class ListenerDiscovery extends NestCordBaseDiscovery<ListenerMeta> {
10
10
  getType(): "once" | "on";
11
- getEvent(): string;
11
+ getEvent(): string | string[];
12
12
  isListener(): this is ListenerDiscovery;
13
- toJSON(): Record<string, any>;
13
+ toJSON(): ListenerMeta;
14
14
  }
@@ -10,7 +10,7 @@ class ListenerDiscovery extends context_1.NestCordBaseDiscovery {
10
10
  return this.meta.type;
11
11
  }
12
12
  getEvent() {
13
- return this.meta.event.toString();
13
+ return Array.isArray(this.meta.event) ? this.meta.event : this.meta.event.toString();
14
14
  }
15
15
  isListener() {
16
16
  return true;
@@ -11,5 +11,5 @@ export declare class ListenersModule implements OnModuleInit, OnApplicationBoots
11
11
  private readonly reflector;
12
12
  constructor(client: Client, explorerService: ExplorerService<ListenerDiscovery>, discoveryService: DiscoveryService, metadataScanner: MetadataScanner, reflector: Reflector);
13
13
  onModuleInit(): void;
14
- onApplicationBootstrap(): any;
14
+ onApplicationBootstrap(): void;
15
15
  }
@@ -27,6 +27,7 @@ const discord_js_1 = require("discord.js");
27
27
  const nestcord_explorer_service_1 = require("../nestcord-explorer.service");
28
28
  const core_1 = require("@nestjs/core");
29
29
  const CustomListeners = require("./handlers");
30
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
30
31
  const { BaseHandler } = CustomListeners, listeners = __rest(CustomListeners, ["BaseHandler"]);
31
32
  let ListenersModule = class ListenersModule {
32
33
  constructor(client, explorerService, discoveryService, metadataScanner, reflector) {
@@ -37,9 +38,19 @@ let ListenersModule = class ListenersModule {
37
38
  this.reflector = reflector;
38
39
  }
39
40
  onModuleInit() {
40
- return this.explorerService
41
- .explore(decorators_1.Listener.KEY)
42
- .forEach((listener) => this.client[listener.getType()](listener.getEvent(), (...args) => listener.execute(args)));
41
+ const explorer = this.explorerService.explore(decorators_1.Listener.KEY);
42
+ explorer.forEach((listener) => {
43
+ const eventType = listener.getType();
44
+ const event = listener.getEvent();
45
+ if (Array.isArray(event)) {
46
+ event.forEach((e) => {
47
+ this.client[eventType](e, (...args) => listener.execute(args));
48
+ });
49
+ }
50
+ else {
51
+ this.client[eventType](event, (...args) => listener.execute(args));
52
+ }
53
+ });
43
54
  }
44
55
  onApplicationBootstrap() {
45
56
  const wrappers = this.discoveryService.getProviders({
@@ -13,5 +13,5 @@ export declare class MessageComponentDiscovery extends NestCordBaseDiscovery<Mes
13
13
  getCustomId(): string;
14
14
  execute(interaction: MessageComponentInteraction): any;
15
15
  isMessageComponent(): this is MessageComponentDiscovery;
16
- toJSON(): Record<string, any>;
16
+ toJSON(): MessageComponentMeta;
17
17
  }
@@ -1 +1 @@
1
- export type TranslationFn = (key: string, ...args: any[]) => string;
1
+ export type TranslationFn = (key: string, ...args: unknown[]) => string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@globalart/nestcord",
3
3
  "description": "A module for creating Discord bots using NestJS, based on Discord.js",
4
- "version": "1.4.2",
4
+ "version": "1.5.0",
5
5
  "private": false,
6
6
  "scripts": {
7
7
  "build": "rimraf dist && tsc -p tsconfig.build.json",
@@ -58,20 +58,20 @@
58
58
  "@commitlint/cli": "19.3.0",
59
59
  "@commitlint/config-angular": "19.3.0",
60
60
  "@favware/npm-deprecate": "1.0.7",
61
- "@nestjs/common": "10.3.8",
62
- "@nestjs/core": "10.3.8",
61
+ "@nestjs/common": "10.3.9",
62
+ "@nestjs/core": "10.3.9",
63
63
  "@nestjs/platform-express": "^10.3.8",
64
- "@types/node": "20.13.0",
64
+ "@types/node": "20.14.2",
65
65
  "@typescript-eslint/eslint-plugin": "7.0.0",
66
66
  "@typescript-eslint/parser": "6.21.0",
67
- "discord-api-types": "0.37.86",
68
- "discord.js": "14.15.2",
67
+ "discord-api-types": "0.37.89",
68
+ "discord.js": "14.15.3",
69
69
  "eslint": "8.57.0",
70
70
  "eslint-config-prettier": "9.1.0",
71
71
  "eslint-plugin-prettier": "5.1.3",
72
72
  "husky": "9.0.11",
73
- "lint-staged": "15.2.5",
74
- "prettier": "3.2.5",
73
+ "lint-staged": "15.2.7",
74
+ "prettier": "3.3.2",
75
75
  "reflect-metadata": "0.2.2",
76
76
  "release-it": "17.3.0",
77
77
  "rimraf": "5.0.7",