decord/beta/source/modules/application_commands/ApplicationCommandValidationUtils.tsx

96 lines
3.1 KiB
TypeScript
Raw Permalink Normal View History

2026-10-12 16:32:48 +00:00
// Module ID: 11843
// Function ID: 11844
// Name: ApplicationCommandValidationUtils
2026-10-12 16:32:48 +00:00
// Dependencies: [5403, 7247, 9803, 1126, 11844, 2]
// Exports: getValidationResults
2026-10-12 16:32:48 +00:00
// Module 11843 (ApplicationCommandValidationUtils)
2026-10-07 22:43:51 +00:00
import intl3 from "intl" /* 1126 */;
2026-10-12 16:32:48 +00:00
import ApplicationCommandConstants from "ApplicationCommandConstants" /* 5403 */;
import ApplicationCommandTypes from "ApplicationCommandTypes" /* 7247 */;
import ApplicationCommandOptionUtils from "ApplicationCommandOptionUtils" /* 9803 */;
import ApplicationCommandValidatorsDefault from "ApplicationCommandValidators" /* 11844 */;
import size from "module_2" /* 2 */;
function validateOptionContent(allowEmptyValues) {
2026-10-01 14:13:23 +00:00
let channelId;
let commandOrigin;
let content;
let guildId;
let intl2;
let option;
({ option, content, guildId, channelId, commandOrigin } = allowEmptyValues);
2026-10-01 14:13:23 +00:00
allowEmptyValues = allowEmptyValues.allowEmptyValues;
if (commandOrigin === undefined) {
commandOrigin = ApplicationCommandTypes.CommandOrigin.CHAT;
}
let str = "";
if (null != content) {
const obj2 = { content };
2026-10-01 14:13:23 +00:00
const obj = ApplicationCommandOptionUtils;
const str3 = obj.getString(obj2, "content");
str = str3.trim();
}
const required = option.required;
if (null == content) {
2026-10-01 14:13:23 +00:00
let obj4;
if (required) {
2026-10-01 14:13:23 +00:00
const obj3 = { success: false, error: intl2.string(intl3.t.JZJQL2) };
intl2 = intl3.intl;
obj4 = obj3;
} else {
obj4 = { success: true };
}
return obj4;
} else if ("" === str) {
2026-10-01 14:13:23 +00:00
let obj5;
if (allowEmptyValues) {
obj5 = { success: true };
} else {
const obj6 = { success: false, error: null };
if (required) {
2026-10-01 14:13:23 +00:00
const intl = intl3.intl;
obj6.error = intl.string(intl3.t.JZJQL2);
obj5 = obj6;
} else {
obj6.error = getValidationErrorText(option);
obj5 = obj6;
}
}
return obj5;
} else {
2026-10-01 14:13:23 +00:00
let first;
if (content.length > 1) {
2026-10-01 14:13:23 +00:00
first = { type: "text", text: str };
const obj7 = { type: "text", text: str };
} else {
first = content[0];
}
const tmp8 = ApplicationCommandValidatorsDefault;
const tmp15 = tmp8[option.type](first, option, channelId, guildId, commandOrigin);
2026-10-01 14:13:23 +00:00
const tmp16 = tmp15.success || null != tmp15.error;
if (!tmp16) {
tmp15.error = getValidationErrorText(option);
}
return tmp15;
}
}
const getValidationErrorText = ApplicationCommandConstants.getValidationErrorText;
const result = size.fileFinishedImporting("modules/application_commands/ApplicationCommandValidationUtils.tsx");
export const getValidationResults = function getValidationResults(activeCommand, optionValues, guild_id, id, allowEmptyValues) {
const obj = {};
const options = activeCommand.options;
if (null == options) {
return obj;
} else {
for (const item10012 of options) {
2026-10-01 14:13:23 +00:00
let obj2 = { option: item10012, content: optionValues[item10012.name], guildId: guild_id, channelId: id, allowEmptyValues };
obj[item10012.name] = validateOptionContent(obj2);
continue;
}
return obj;
}
};
export { validateOptionContent };