@sapphire/framework
Version:
Discord bot framework built for advanced and amazing bots.
1 lines • 3 kB
Source Map (JSON)
{"version":3,"sources":["../../../../../src/lib/utils/application-commands/getNeededParameters.ts"],"names":["container"],"mappings":";;;;;;AAGA,eAAsB,2BAA4B,CAAA,QAAA,mBAA4B,IAAA,GAAA,EAAO,EAAA;AACpF,EAAM,MAAA,EAAE,QAAW,GAAAA,gBAAA;AAEnB,EAAM,MAAA,mBAAA,GAAsB,OAAO,WAAa,CAAA,QAAA;AAChD,EAAA,MAAM,iBAAiB,MAAM,mBAAA,CAAoB,MAAM,EAAE,iBAAA,EAAmB,MAAM,CAAA;AAClF,EAAA,MAAM,aAAgB,GAAA,MAAM,kBAAmB,CAAA,mBAAA,EAAqB,QAAQ,CAAA;AAE5E,EAAO,OAAA;AAAA,IACN,mBAAA;AAAA,IACA,cAAA;AAAA,IACA;AAAA,GACD;AACD;AAZsB,MAAA,CAAA,2BAAA,EAAA,6BAAA,CAAA;AActB,eAAe,kBAAA,CAAmB,UAAqC,QAAuB,EAAA;AAC7F,EAAM,MAAA,GAAA,uBAAU,GAAoD,EAAA;AAEpE,EAAA,KAAA,MAAW,WAAW,QAAU,EAAA;AAC/B,IAAI,IAAA;AACH,MAAM,MAAA,aAAA,GAAgB,MAAM,QAAS,CAAA,KAAA,CAAM,EAAE,OAAS,EAAA,iBAAA,EAAmB,MAAM,CAAA;AAC/E,MAAI,GAAA,CAAA,GAAA,CAAI,SAAS,aAAa,CAAA;AAAA,aACtB,GAAK,EAAA;AACb,MAAA,MAAM,EAAE,gCAAA,EAAqC,GAAAA,gBAAA,CAAU,MAAO,CAAA,OAAA;AAE9D,MAAA,IAAI,qCAAqC,IAAM,EAAA;AAE/C,MAAI,IAAA,KAAA,CAAM,QAAQ,gCAAgC,CAAA,IAAK,CAAC,gCAAkC,EAAA,QAAA,CAAS,OAAO,CAAG,EAAA;AAC5G,QAAM,MAAA,KAAA,GAAQA,iBAAU,MAAO,CAAA,MAAA,CAAO,QAAQ,OAAO,CAAA,IAAK,EAAE,IAAA,EAAM,oBAAqB,EAAA;AACvF,QAAAA,gBAAA,CAAU,MAAO,CAAA,IAAA;AAAA,UAChB,CAA2E,wEAAA,EAAA,KAAA,CAAM,IAAI,CAAA,GAAA,EAAM,OAAO,CAAA,EAAA,CAAA;AAAA,UAClG;AAAA,SACD;AAAA;AACD;AACD;AAGD,EAAO,OAAA,GAAA;AACR;AAvBe,MAAA,CAAA,kBAAA,EAAA,oBAAA,CAAA","file":"getNeededParameters.cjs","sourcesContent":["import { container } from '@sapphire/pieces';\nimport type { ApplicationCommand, ApplicationCommandManager, Collection } from 'discord.js';\n\nexport async function getNeededRegistryParameters(guildIds: Set<string> = new Set()) {\n\tconst { client } = container;\n\n\tconst applicationCommands = client.application!.commands;\n\tconst globalCommands = await applicationCommands.fetch({ withLocalizations: true });\n\tconst guildCommands = await fetchGuildCommands(applicationCommands, guildIds);\n\n\treturn {\n\t\tapplicationCommands,\n\t\tglobalCommands,\n\t\tguildCommands\n\t};\n}\n\nasync function fetchGuildCommands(commands: ApplicationCommandManager, guildIds: Set<string>) {\n\tconst map = new Map<string, Collection<string, ApplicationCommand>>();\n\n\tfor (const guildId of guildIds) {\n\t\ttry {\n\t\t\tconst guildCommands = await commands.fetch({ guildId, withLocalizations: true });\n\t\t\tmap.set(guildId, guildCommands);\n\t\t} catch (err) {\n\t\t\tconst { preventFailedToFetchLogForGuilds } = container.client.options;\n\n\t\t\tif (preventFailedToFetchLogForGuilds === true) continue;\n\n\t\t\tif (Array.isArray(preventFailedToFetchLogForGuilds) && !preventFailedToFetchLogForGuilds?.includes(guildId)) {\n\t\t\t\tconst guild = container.client.guilds.resolve(guildId) ?? { name: 'Guild not in cache' };\n\t\t\t\tcontainer.logger.warn(\n\t\t\t\t\t`ApplicationCommandRegistries: Failed to fetch guild commands for guild \"${guild.name}\" (${guildId}).`,\n\t\t\t\t\t'Make sure to authorize your application with the \"applications.commands\" scope in that guild.'\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn map;\n}\n"]}