UNPKG

@sapphire/framework

Version:

Discord bot framework built for advanced and amazing bots.

34 lines (32 loc) 1.45 kB
import { container } from "@sapphire/pieces"; //#region src/lib/utils/application-commands/getNeededParameters.ts async function getNeededRegistryParameters(guildIds = /* @__PURE__ */ new Set()) { const { client } = container; const applicationCommands = client.application.commands; return { applicationCommands, globalCommands: await applicationCommands.fetch({ withLocalizations: true }), guildCommands: await fetchGuildCommands(applicationCommands, guildIds) }; } async function fetchGuildCommands(commands, guildIds) { const map = /* @__PURE__ */ new Map(); for (const guildId of guildIds) try { const guildCommands = await commands.fetch({ guildId, withLocalizations: true }); map.set(guildId, guildCommands); } catch (err) { const { preventFailedToFetchLogForGuilds } = container.client.options; if (preventFailedToFetchLogForGuilds === true) continue; if (Array.isArray(preventFailedToFetchLogForGuilds) && !preventFailedToFetchLogForGuilds?.includes(guildId)) { const guild = container.client.guilds.resolve(guildId) ?? { name: "Guild not in cache" }; container.logger.warn(`ApplicationCommandRegistries: Failed to fetch guild commands for guild "${guild.name}" (${guildId}).`, "Make sure to authorize your application with the \"applications.commands\" scope in that guild."); } } return map; } //#endregion export { getNeededRegistryParameters }; //# sourceMappingURL=getNeededParameters.mjs.map