@sapphire/framework
Version:
Discord bot framework built for advanced and amazing bots.
40 lines (38 loc) • 1.72 kB
JavaScript
import { __name } from '../../../chunk-PAWJFY3S.mjs';
import { container } from '@sapphire/pieces';
async function getNeededRegistryParameters(guildIds = /* @__PURE__ */ new Set()) {
const { client } = container;
const applicationCommands = client.application.commands;
const globalCommands = await applicationCommands.fetch({ withLocalizations: true });
const guildCommands = await fetchGuildCommands(applicationCommands, guildIds);
return {
applicationCommands,
globalCommands,
guildCommands
};
}
__name(getNeededRegistryParameters, "getNeededRegistryParameters");
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;
}
__name(fetchGuildCommands, "fetchGuildCommands");
export { getNeededRegistryParameters };
//# sourceMappingURL=getNeededParameters.mjs.map
//# sourceMappingURL=getNeededParameters.mjs.map