@sapphire/framework
Version:
Discord bot framework built for advanced and amazing bots.
76 lines (74 loc) • 4.12 kB
JavaScript
import { __name } from '../../../chunk-PAWJFY3S.mjs';
import { ApplicationCommandType } from 'discord-api-types/v10';
import { contextMenuTypes } from './compute-differences/_shared.mjs';
import { checkDefaultMemberPermissions } from './compute-differences/default_member_permissions.mjs';
import { checkDescription } from './compute-differences/description.mjs';
import { checkDMPermission } from './compute-differences/dm_permission.mjs';
import { checkLocalizations } from './compute-differences/localizations.mjs';
import { checkName } from './compute-differences/name.mjs';
import { checkOptions } from './compute-differences/options.mjs';
import { checkIntegrationTypes } from './compute-differences/integration_types.mjs';
import { checkInteractionContextTypes } from './compute-differences/contexts.mjs';
function getCommandDifferencesFast(existingCommand, apiData, guildCommand) {
for (const _ of getCommandDifferences(existingCommand, apiData, guildCommand)) {
return true;
}
return false;
}
__name(getCommandDifferencesFast, "getCommandDifferencesFast");
function* getCommandDifferences(existingCommand, apiData, guildCommand) {
if (existingCommand.type !== ApplicationCommandType.ChatInput && existingCommand.type) {
if (contextMenuTypes.includes(existingCommand.type ?? ApplicationCommandType.ChatInput)) {
const casted2 = apiData;
yield* checkName({ oldName: existingCommand.name, newName: casted2.name });
if (!guildCommand) {
yield* checkDMPermission(existingCommand.dm_permission, casted2.dm_permission);
}
yield* checkDefaultMemberPermissions(existingCommand.default_member_permissions, casted2.default_member_permissions);
const originalLocalizedNames2 = existingCommand.name_localizations;
const expectedLocalizedNames2 = casted2.name_localizations;
yield* checkLocalizations({
localeMapName: "nameLocalizations",
localePresentMessage: "localized names",
localeMissingMessage: "no localized names",
originalLocalizedDescriptions: originalLocalizedNames2,
expectedLocalizedDescriptions: expectedLocalizedNames2
});
yield* checkIntegrationTypes(existingCommand.integration_types, casted2.integration_types);
yield* checkInteractionContextTypes(existingCommand.contexts, casted2.contexts);
}
return;
}
const casted = apiData;
yield* checkName({ oldName: existingCommand.name.toLowerCase(), newName: casted.name.toLowerCase() });
const originalLocalizedNames = existingCommand.name_localizations;
const expectedLocalizedNames = casted.name_localizations;
yield* checkLocalizations({
localeMapName: "nameLocalizations",
localePresentMessage: "localized names",
localeMissingMessage: "no localized names",
originalLocalizedDescriptions: originalLocalizedNames,
expectedLocalizedDescriptions: expectedLocalizedNames
});
if (!guildCommand) {
yield* checkDMPermission(existingCommand.dm_permission, casted.dm_permission);
}
yield* checkDefaultMemberPermissions(existingCommand.default_member_permissions, casted.default_member_permissions);
yield* checkDescription({ oldDescription: existingCommand.description, newDescription: casted.description });
const originalLocalizedDescriptions = existingCommand.description_localizations;
const expectedLocalizedDescriptions = casted.description_localizations;
yield* checkLocalizations({
localeMapName: "descriptionLocalizations",
localePresentMessage: "localized descriptions",
localeMissingMessage: "no localized descriptions",
originalLocalizedDescriptions,
expectedLocalizedDescriptions
});
yield* checkIntegrationTypes(existingCommand.integration_types, casted.integration_types);
yield* checkInteractionContextTypes(existingCommand.contexts, casted.contexts);
yield* checkOptions(existingCommand.options, casted.options);
}
__name(getCommandDifferences, "getCommandDifferences");
export { getCommandDifferences, getCommandDifferencesFast };
//# sourceMappingURL=computeDifferences.mjs.map
//# sourceMappingURL=computeDifferences.mjs.map