@sapphire/framework
Version:
Discord bot framework built for advanced and amazing bots.
39 lines (38 loc) • 1.16 kB
JavaScript
//#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
export { checkInteractionContextTypes };
//# sourceMappingURL=contexts.mjs.map