@sapphire/framework
Version:
Discord bot framework built for advanced and amazing bots.
33 lines (31 loc) • 1.88 kB
JavaScript
;
const require_lib_types_Events = require('../../types/Events.cjs');
const require_lib_utils_application_commands_registriesLog = require('./registriesLog.cjs');
let __sapphire_pieces = require("@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 } = __sapphire_pieces.container;
if (client.listenerCount(require_lib_types_Events.Events.CommandApplicationCommandRegistryError)) client.emit(require_lib_types_Events.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 } = __sapphire_pieces.container;
if (client.listenerCount(require_lib_types_Events.Events.ApplicationCommandRegistriesBulkOverwriteError)) client.emit(require_lib_types_Events.Events.ApplicationCommandRegistriesBulkOverwriteError, error, guildId);
else if (guildId) require_lib_utils_application_commands_registriesLog.bulkOverwriteError(`Failed to overwrite guild application commands for guild ${guildId}`, error);
else require_lib_utils_application_commands_registriesLog.bulkOverwriteError(`Failed to overwrite global application commands`, error);
}
//#endregion
exports.emitBulkOverwriteError = emitBulkOverwriteError;
exports.emitPerRegistryError = emitPerRegistryError;
//# sourceMappingURL=registriesErrors.cjs.map