Skip to content

Commit

Permalink
feat: add ApplicationCommandRegistriesRegistered event (#587)
Browse files Browse the repository at this point in the history
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
Co-authored-by: Jeroen Claassens <support@favware.tech>
  • Loading branch information
3 people committed Jan 6, 2023
1 parent 9f0ef5e commit b49fd2a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/lib/types/Events.ts
Expand Up @@ -20,6 +20,7 @@ import type {
} from '../structures/Command';
import type { InteractionHandler } from '../structures/InteractionHandler';
import type { Listener } from '../structures/Listener';
import type { ApplicationCommandRegistry } from '../utils/application-commands/ApplicationCommandRegistry';
import type { PluginHook } from './Enums';

export const Events = {
Expand Down Expand Up @@ -195,6 +196,12 @@ export const Events = {
*/
CommandApplicationCommandRegistryError: 'commandApplicationCommandRegistryError' as const,

/**
* Emitted once the application command registries have been initialized.
* @param {Map<string, ApplicationCommandRegistry>} registries The initialised registries
*/
ApplicationCommandRegistriesRegistered: 'applicationCommandRegistriesRegistered' as const,

// Piece store?
/**
* Emitted after a piece is loaded.
Expand Down Expand Up @@ -541,6 +548,7 @@ declare module 'discord.js' {

[Events.ListenerError]: [error: unknown, payload: ListenerErrorPayload];
[Events.CommandApplicationCommandRegistryError]: [error: unknown, command: Command];
[Events.ApplicationCommandRegistriesRegistered]: [registries: Map<string, ApplicationCommandRegistry>];

[Events.PreMessageParsed]: [message: Message];
[Events.MentionPrefixOnly]: [message: Message];
Expand Down
Expand Up @@ -4,6 +4,7 @@ import type { ApplicationCommandManager } from 'discord.js';
import type { Command } from '../../structures/Command';
import type { CommandStore } from '../../structures/CommandStore';
import { RegisterBehavior } from '../../types/Enums';
import { Events } from '../../types/Events';
import { ApplicationCommandRegistry } from './ApplicationCommandRegistry';
import { emitRegistryError } from './emitRegistryError';
import { getNeededRegistryParameters } from './getNeededParameters';
Expand Down Expand Up @@ -184,6 +185,8 @@ async function handleAppendOrUpdate(
}
}
}

container.client.emit(Events.ApplicationCommandRegistriesRegistered, registries);
}

interface BulkOverwriteData {
Expand Down

0 comments on commit b49fd2a

Please sign in to comment.