UNPKG

@sapphire/framework

Version:

Discord bot framework built for advanced and amazing bots.

41 lines (39 loc) 1.2 kB
"use strict"; //#region src/lib/utils/application-commands/compute-differences/contexts.ts function* checkInteractionContextTypes(existingContexts, newContexts) { if (!existingContexts && newContexts?.length) yield { key: "contexts", original: "no contexts present", expected: "contexts present" }; else if (existingContexts?.length && !newContexts?.length) yield { key: "contexts", original: "contexts present", expected: "no contexts present" }; else if (newContexts?.length) { let index = 0; for (const newContext of newContexts) { const currentIndex = index++; if (existingContexts[currentIndex] !== newContext) yield { key: `contexts[${currentIndex}]`, original: `contexts type ${existingContexts?.[currentIndex]}`, expected: `contexts type ${newContext}` }; } if (index < existingContexts.length) { let type; while ((type = existingContexts[index]) !== void 0) { yield { key: `contexts[${index}]`, original: `context ${type} present`, expected: `no context present` }; index++; } } } } //#endregion exports.checkInteractionContextTypes = checkInteractionContextTypes; //# sourceMappingURL=contexts.cjs.map