@sapphire/framework
Version:
Discord bot framework built for advanced and amazing bots.
49 lines (46 loc) • 1.56 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
// 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++;
}
}
}
}
__name(checkInteractionContextTypes, "checkInteractionContextTypes");
exports.checkInteractionContextTypes = checkInteractionContextTypes;
//# sourceMappingURL=contexts.cjs.map
//# sourceMappingURL=contexts.cjs.map