UNPKG

@sapphire/framework

Version:

Discord bot framework built for advanced and amazing bots.

1 lines 2.15 kB
{"version":3,"file":"registriesErrors.mjs","names":[],"sources":["../../../../../src/lib/utils/application-commands/registriesErrors.ts"],"sourcesContent":["import { container } from '@sapphire/pieces';\nimport type { Command } from '../../structures/Command';\nimport { Events } from '../../types/Events';\nimport { bulkOverwriteError } from './registriesLog';\n\n/**\n * Opinionatedly logs the encountered registry error.\n * @param error The emitted error\n * @param command The command which had the error\n */\nexport function emitPerRegistryError(error: unknown, command: Command<any, any>) {\n\tconst { name, location } = command;\n\tconst { client, logger } = container;\n\n\tif (client.listenerCount(Events.CommandApplicationCommandRegistryError)) {\n\t\tclient.emit(Events.CommandApplicationCommandRegistryError, error, command);\n\t} else {\n\t\tlogger.error(\n\t\t\t`Encountered error while handling the command application command registry for command \"${name}\" at path \"${location.full}\"`,\n\t\t\terror\n\t\t);\n\t}\n}\n\n/**\n * Opinionatedly logs any bulk overwrite registries error.\n * @param error The emitted error\n * @param guildId The guild id in which the error was caused\n */\nexport function emitBulkOverwriteError(error: unknown, guildId: string | null) {\n\tconst { client } = container;\n\n\tif (client.listenerCount(Events.ApplicationCommandRegistriesBulkOverwriteError)) {\n\t\tclient.emit(Events.ApplicationCommandRegistriesBulkOverwriteError, error, guildId);\n\t} else if (guildId) {\n\t\tbulkOverwriteError(`Failed to overwrite guild application commands for guild ${guildId}`, error);\n\t} else {\n\t\tbulkOverwriteError(`Failed to overwrite global application commands`, error);\n\t}\n}\n"],"mappings":";;;;;;;;;;AAUA,SAAgB,qBAAqB,OAAgB,SAA4B;CAChF,MAAM,EAAE,MAAM,aAAa;CAC3B,MAAM,EAAE,QAAQ,WAAW;AAE3B,KAAI,OAAO,cAAc,OAAO,uCAAuC,CACtE,QAAO,KAAK,OAAO,wCAAwC,OAAO,QAAQ;KAE1E,QAAO,MACN,0FAA0F,KAAK,aAAa,SAAS,KAAK,IAC1H,MACA;;;;;;;AASH,SAAgB,uBAAuB,OAAgB,SAAwB;CAC9E,MAAM,EAAE,WAAW;AAEnB,KAAI,OAAO,cAAc,OAAO,+CAA+C,CAC9E,QAAO,KAAK,OAAO,gDAAgD,OAAO,QAAQ;UACxE,QACV,oBAAmB,4DAA4D,WAAW,MAAM;KAEhG,oBAAmB,mDAAmD,MAAM"}