decord/source/modules/application_commands/ApplicationCommandValidationUtils.tsx

174 lines
5.1 KiB
TypeScript
Raw Normal View History

2026-07-27 11:26:19 +00:00
// Module ID: 11270
// Function ID: 87635
2026-07-20 16:05:17 +00:00
// Name: _createForOfIteratorHelperLoose
2026-07-27 11:26:19 +00:00
// Dependencies: [4567, 5676, 7958, 1212, 11271, 2]
2026-07-20 16:05:17 +00:00
// Exports: getValidationResults
2026-07-27 11:26:19 +00:00
// Module 11270 (_createForOfIteratorHelperLoose)
2026-07-23 10:11:24 +00:00
import { getValidationErrorText } from "TRUE_OPTION_NAME";
function _createForOfIteratorHelperLoose(iterable) {
let closure_0 = iterable;
iterable = "undefined" !== typeof Symbol;
if (iterable) {
2026-07-20 16:05:17 +00:00
const _Symbol = Symbol;
2026-07-23 10:11:24 +00:00
iterable = iterable[Symbol.iterator];
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
if (!iterable) {
iterable = iterable[Symbol.iterator];
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
if (iterable) {
const iter = iterable.call(iterable);
2026-07-20 16:05:17 +00:00
const next = iter.next;
return next.bind(iter);
} else {
const _Array = Array;
2026-07-23 10:11:24 +00:00
let tmp = iterable;
if (!Array.isArray(iterable)) {
2026-07-20 16:05:17 +00:00
let tmp2;
2026-07-23 10:11:24 +00:00
if (iterable) {
if ("string" === typeof iterable) {
tmp2 = _arrayLikeToArray(iterable, undefined);
2026-07-20 16:05:17 +00:00
} else {
const toString = {}.toString;
2026-07-23 10:11:24 +00:00
const substr = toString.call(iterable).slice(8, -1);
2026-07-20 16:05:17 +00:00
let name = substr;
if (tmp3) {
2026-07-23 10:11:24 +00:00
name = iterable.constructor.name;
2026-07-20 16:05:17 +00:00
}
if ("Map" !== name) {
if ("Set" !== name) {
if ("Arguments" === name) {
2026-07-23 10:11:24 +00:00
let arr = _arrayLikeToArray(iterable, undefined);
2026-07-20 16:05:17 +00:00
} else {
2026-07-23 10:11:24 +00:00
let obj = /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/;
2026-07-20 16:05:17 +00:00
}
}
tmp2 = arr;
}
const _Array2 = Array;
2026-07-23 10:11:24 +00:00
arr = Array.from(iterable);
const callResult = toString.call(iterable);
tmp3 = "Object" === substr && iterable.constructor;
2026-07-20 16:05:17 +00:00
}
}
tmp = tmp2;
if (!tmp2) {
const _TypeError = TypeError;
const typeError = new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
throw typeError;
}
}
if (tmp) {
2026-07-23 10:11:24 +00:00
closure_0 = tmp;
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
let c1 = 0;
2026-07-20 16:05:17 +00:00
return () => {
2026-07-23 10:11:24 +00:00
if (closure_1 >= length.length) {
2026-07-20 16:05:17 +00:00
let obj = { done: true };
} else {
obj = { done: false };
closure_1 = tmp3 + 1;
2026-07-23 10:11:24 +00:00
obj.value = length[+closure_1];
2026-07-20 16:05:17 +00:00
}
return obj;
};
}
}
function _arrayLikeToArray(arg0, arg1) {
let length;
if (tmp) {
length = arg0.length;
}
const ArrayResult = Array(length);
for (let num = 0; num < length; num = num + 1) {
ArrayResult[num] = arg0[num];
}
return ArrayResult;
}
function validateOptionContent(allowEmptyValues) {
let channelId;
let commandOrigin;
let content;
let guildId;
let option;
({ option, content, guildId, channelId, commandOrigin } = allowEmptyValues);
if (commandOrigin === undefined) {
2026-07-25 08:10:48 +00:00
commandOrigin = require(5676) /* ApplicationCommandSectionType */.CommandOrigin.CHAT;
2026-07-20 16:05:17 +00:00
}
let str = "";
if (null != content) {
2026-07-25 08:10:48 +00:00
let obj = require(7958) /* _createForOfIteratorHelperLoose */;
2026-07-20 16:05:17 +00:00
obj = { content };
str = obj.getString(obj, "content").trim();
const str3 = obj.getString(obj, "content");
}
const required = option.required;
if (null == content) {
if (required) {
obj = { success: false };
2026-07-23 10:11:24 +00:00
const intl2 = require(1212) /* getSystemLocale */.intl;
obj.error = intl2.string(require(1212) /* getSystemLocale */.t.JZJQL2);
2026-07-20 16:05:17 +00:00
let obj1 = obj;
} else {
obj1 = { success: true };
}
return obj1;
} else if ("" === str) {
if (allowEmptyValues.allowEmptyValues) {
const obj2 = { success: true };
let tmp19 = obj2;
} else {
const obj3 = { success: false };
if (required) {
2026-07-23 10:11:24 +00:00
const intl = require(1212) /* getSystemLocale */.intl;
obj3.error = intl.string(require(1212) /* getSystemLocale */.t.JZJQL2);
2026-07-20 16:05:17 +00:00
tmp19 = obj3;
} else {
obj3.error = getValidationErrorText(option);
tmp19 = obj3;
}
}
return tmp19;
} else {
if (content.length > 1) {
const obj4 = { type: "text", text: str };
let first = obj4;
} else {
first = content[0];
}
2026-07-27 11:26:19 +00:00
const tmp8 = importDefault(11271);
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-07-23 10:11:24 +00:00
const result = require("_createForOfIteratorHelperLoose").fileFinishedImporting("modules/application_commands/ApplicationCommandValidationUtils.tsx");
2026-07-20 16:05:17 +00:00
export const getValidationResults = function getValidationResults(activeCommand, optionValues, guild_id, id, allowEmptyValues) {
let done;
let obj = {};
const options = activeCommand.options;
if (null == options) {
return obj;
} else {
const tmp2 = _createForOfIteratorHelperLoose(options);
let iter = tmp2();
if (!iter.done) {
do {
let value = iter.value;
2026-07-23 10:11:24 +00:00
let tmp3 = validateOptionContent;
2026-07-20 16:05:17 +00:00
obj = { option: value, content: optionValues[value.name], guildId: guild_id, channelId: id, allowEmptyValues };
2026-07-23 10:11:24 +00:00
obj[value.name] = validateOptionContent(obj);
2026-07-20 16:05:17 +00:00
let iter2 = tmp2();
iter = iter2;
done = iter2.done;
} while (!done);
}
return obj;
}
};
export { validateOptionContent };