@sapphire/framework
Version:
Discord bot framework built for advanced and amazing bots.
31 lines (29 loc) • 1.51 kB
JavaScript
import { Events } from "../../types/Events.mjs";
import { bulkOverwriteError } from "./registriesLog.mjs";
import { container } from "@sapphire/pieces";
//#region src/lib/utils/application-commands/registriesErrors.ts
/**
* Opinionatedly logs the encountered registry error.
* @param error The emitted error
* @param command The command which had the error
*/
function emitPerRegistryError(error, command) {
const { name, location } = command;
const { client, logger } = container;
if (client.listenerCount(Events.CommandApplicationCommandRegistryError)) client.emit(Events.CommandApplicationCommandRegistryError, error, command);
else logger.error(`Encountered error while handling the command application command registry for command "${name}" at path "${location.full}"`, error);
}
/**
* Opinionatedly logs any bulk overwrite registries error.
* @param error The emitted error
* @param guildId The guild id in which the error was caused
*/
function emitBulkOverwriteError(error, guildId) {
const { client } = container;
if (client.listenerCount(Events.ApplicationCommandRegistriesBulkOverwriteError)) client.emit(Events.ApplicationCommandRegistriesBulkOverwriteError, error, guildId);
else if (guildId) bulkOverwriteError(`Failed to overwrite guild application commands for guild ${guildId}`, error);
else bulkOverwriteError(`Failed to overwrite global application commands`, error);
}
//#endregion
export { emitBulkOverwriteError, emitPerRegistryError };
//# sourceMappingURL=registriesErrors.mjs.map