decord/source/modules/application_commands/ApplicationCommandValidationUtils.tsx

94 lines
3 KiB
TypeScript
Raw Normal View History

2026-08-25 06:04:03 +00:00
// Module ID: 11740
// Function ID: 11741
2026-07-29 08:29:29 +00:00
// Name: validateOptionContent
2026-08-25 06:04:03 +00:00
// Dependencies: [4838, 7129, 10146, 1236, 11741, 2]
2026-07-20 16:05:17 +00:00
// Exports: getValidationResults
2026-08-25 06:04:03 +00:00
// Module 11740 (validateOptionContent)
2026-08-24 06:08:38 +00:00
import set from "set" /* 2 */;
import getSystemLocale from "getSystemLocale" /* 1236 */;
2026-08-25 06:04:03 +00:00
import TRUE_OPTION_NAME from "TRUE_OPTION_NAME" /* 4838 */;
import ApplicationCommandSectionType from "ApplicationCommandSectionType" /* 7129 */;
import getString from "getString" /* 10146 */;
import validateNumericOptionRangeDefault from "validateNumericOptionRange" /* 11741 */;
2026-07-23 10:11:24 +00:00
2026-07-20 16:05:17 +00:00
function validateOptionContent(allowEmptyValues) {
({ option, content, guildId, channelId, commandOrigin } = allowEmptyValues);
if (commandOrigin === undefined) {
2026-08-24 06:08:38 +00:00
commandOrigin = ApplicationCommandSectionType.CommandOrigin.CHAT;
2026-07-20 16:05:17 +00:00
}
let str = "";
if (null != content) {
2026-08-24 06:08:38 +00:00
let obj = getString;
2026-07-29 08:29:29 +00:00
obj = { content: null };
obj[0] = content;
2026-07-20 16:05:17 +00:00
str = obj.getString(obj, "content").trim();
const str3 = obj.getString(obj, "content");
}
const required = option.required;
if (null == content) {
if (required) {
2026-07-29 08:29:29 +00:00
obj = { success: false, error: null };
2026-08-24 06:08:38 +00:00
const intl2 = getSystemLocale.intl;
obj[1] = intl2.string(getSystemLocale.t.JZJQL2);
obj1 = obj;
2026-07-20 16:05:17 +00:00
} else {
obj1 = { success: true };
}
return obj1;
} else if ("" === str) {
if (allowEmptyValues.allowEmptyValues) {
2026-07-29 08:29:29 +00:00
let obj2 = { success: true };
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
const obj3 = { success: false, error: null };
2026-07-20 16:05:17 +00:00
if (required) {
2026-08-24 06:08:38 +00:00
const intl = getSystemLocale.intl;
obj3[1] = intl.string(getSystemLocale.t.JZJQL2);
2026-07-29 08:29:29 +00:00
obj2 = obj3;
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
obj3[1] = getValidationErrorText(option);
obj2 = obj3;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
return obj2;
2026-07-20 16:05:17 +00:00
} else {
if (content.length > 1) {
2026-07-29 08:29:29 +00:00
const obj4 = { type: "text", text: null };
obj4[1] = str;
2026-07-20 16:05:17 +00:00
let first = obj4;
} else {
first = content[0];
}
2026-08-24 06:08:38 +00:00
const tmp8 = validateNumericOptionRangeDefault;
2026-07-20 16:05:17 +00:00
const tmp15 = tmp8[option.type](first, option, channelId, guildId, commandOrigin);
if (!tmp16) {
tmp15.error = getValidationErrorText(option);
}
return tmp15;
}
}
2026-08-24 06:08:38 +00:00
const getValidationErrorText = TRUE_OPTION_NAME.getValidationErrorText;
const result = set.fileFinishedImporting("modules/application_commands/ApplicationCommandValidationUtils.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export const getValidationResults = function getValidationResults(activeCommand, optionValues, guild_id, id, arg4) {
2026-07-20 16:05:17 +00:00
let obj = {};
const options = activeCommand.options;
if (null == options) {
return obj;
} else {
2026-07-29 08:29:29 +00:00
for (const item10012 of options) {
let tmp3 = validateOptionContent;
obj = { option: null, content: null, guildId: null, channelId: null, allowEmptyValues: null };
obj[0] = item10012;
obj[1] = arg1[item10012.name];
obj[2] = arg2;
obj[3] = arg3;
obj[4] = arg4;
obj[item10012.name] = validateOptionContent(obj);
continue;
2026-07-20 16:05:17 +00:00
}
return obj;
}
};
export { validateOptionContent };