Skip to content

Commit

Permalink
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/lib/structures/Command.ts
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@ import { Args } from '../parsers/Args';
import { BucketScope, RegisterBehavior } from '../types/Enums';
import { acquire, getDefaultBehaviorWhenNotIdentical } from '../utils/application-commands/ApplicationCommandRegistries';
import type { ApplicationCommandRegistry } from '../utils/application-commands/ApplicationCommandRegistry';
import { emitRegistryError } from '../utils/application-commands/emitRegistryError';
import { getNeededRegistryParameters } from '../utils/application-commands/getNeededParameters';
import { PreconditionContainerArray, PreconditionEntryResolvable } from '../utils/preconditions/PreconditionContainerArray';
import { FlagStrategyOptions, FlagUnorderedStrategy } from '../utils/strategies/FlagUnorderedStrategy';
@@ -294,6 +295,15 @@ export class Command<PreParseReturn = Args, O extends Command.Options = Command.
// Reload the command
await super.reload();

// Rerun the registry
try {
await this.registerApplicationCommands(this.applicationCommandRegistry);
} catch (err) {
emitRegistryError(err, this);
// No point on continuing
return;
}

// Re-initialize the store and the API data (insert in the store handles the register method)
const { applicationCommands, globalCommands, guildCommands } = await getNeededRegistryParameters();

2 changes: 1 addition & 1 deletion src/lib/utils/application-commands/emitRegistryError.ts
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ import { Events } from '../../types/Events';
* @param error The emitted error
* @param command The command which had the error
*/
export function emitRegistryError(error: unknown, command: Command) {
export function emitRegistryError(error: unknown, command: Command<any, any>) {
const { name, location } = command;
const { client, logger } = container;

0 comments on commit 4862928

Please sign in to comment.