decord/source/modules/application_commands/ApplicationCommandOptionUtils.tsx

391 lines
11 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 10295
// Function ID: 10296
2026-07-29 08:29:29 +00:00
// Name: getString
2026-08-24 06:08:38 +00:00
// Dependencies: [5251, 38, 10296, 4366, 1954, 2]
2026-07-29 08:29:29 +00:00
// Exports: filterEmpty, getBoolean, getChannelId, getInitialValuesFromInteractionOptions, getOptionalBoolean, getOptionalChannelId, getOptionalRoleId, getOptionalString, getOptionalUserId, getRoleId, getUserId, normalizeNumericString
2026-07-20 16:05:17 +00:00
2026-08-24 06:08:38 +00:00
// Module 10295 (getString)
import set from "set" /* 2 */;
import _modDef38 from "module_38" /* 38 */;
import setDefault from "set" /* 4366 */;
import TRUE_OPTION_NAME2 from "TRUE_OPTION_NAME" /* 5251 */;
import numberParts from "numberParts" /* 10296 */;
2026-07-23 10:11:24 +00:00
2026-07-29 08:29:29 +00:00
function getString(arg0, arg1) {
let str = "";
const iter = arg0[arg1][Symbol.iterator]();
const nextResult = iter.next();
for (; iter !== undefined; str = str + tmp2.text) {
tmp2 = nextResult;
let type = nextResult.type;
if ("text" !== type) {
if ("textMention" !== type) {
if ("userMention" === type) {
let tmp11 = str;
let tmp12 = nextResult;
let _HermesInternal4 = HermesInternal;
str = `${"<@" + tmp2.userId + ">"}`;
} else if ("channelMention" === type) {
let tmp9 = str;
let tmp10 = nextResult;
let _HermesInternal3 = HermesInternal;
str = `${"<@" + tmp2.userId + ">"}${"<#" + tmp2.channelId + ">"}`;
} else if ("roleMention" === type) {
let tmp7 = str;
let tmp8 = nextResult;
let _HermesInternal2 = HermesInternal;
str = `${"<@" + tmp2.userId + ">"}${"<#" + tmp2.channelId + ">"}${"<@&" + tmp2.roleId + ">"}`;
} else if ("emoji" === type) {
let tmp5 = str;
let tmp6 = nextResult;
str = `${"<@" + tmp2.userId + ">"}${"<#" + tmp2.channelId + ">"}${"<@&" + tmp2.roleId + ">"}${tmp2.surrogate}`;
} else if ("customEmoji" === type) {
let tmp15 = str;
let tmp16 = nextResult;
let str2 = "";
if (tmp2.animated) {
str2 = "a";
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let tmp3 = nextResult;
let str3 = tmp2.name;
let str4 = str3.replace(/:/g, "");
let _HermesInternal = HermesInternal;
let str5 = "<";
let tmp4 = str2;
let str6 = ":";
let str7 = ":";
let str8 = ">";
str = str + "<" + str2 + ":" + str4.split("~")[0] + ":" + tmp2.emojiId + ">";
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
continue;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let tmp13 = str;
let tmp14 = nextResult;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return str;
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
const TRUE_OPTION_NAME = TRUE_OPTION_NAME2.TRUE_OPTION_NAME;
const result = set.fileFinishedImporting("modules/application_commands/ApplicationCommandOptionUtils.tsx");
2026-07-29 08:29:29 +00:00
export const filterEmpty = function filterEmpty(arr) {
2026-08-24 06:08:38 +00:00
closure_0 = arr;
2026-07-20 16:05:17 +00:00
if (null == arr) {
let items = [];
} else {
items = arr.filter((type) => {
let str = type;
if ("text" !== type.type) {
return tmp;
} else {
if (arg1 <= 0) {
2026-07-29 08:29:29 +00:00
let tmp4 = "" !== str.text.trim();
2026-07-20 16:05:17 +00:00
const str2 = str.text;
}
str = "";
2026-07-29 08:29:29 +00:00
tmp4 = "" !== str.text;
2026-07-20 16:05:17 +00:00
}
});
}
return items;
2026-07-29 08:29:29 +00:00
};
export const getBoolean = function getBoolean(arg0, arg1) {
const arr = arg0[arg1];
if (null == arr) {
let items = [];
} else {
items = arr.filter((type) => {
let str = type;
if ("text" !== type.type) {
return tmp;
} else {
if (arg1 <= 0) {
let tmp4 = "" !== str.text.trim();
const str2 = str.text;
}
str = "";
tmp4 = "" !== str.text;
}
});
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
_modDef38(1 === items.length, "Contains multiple values");
2026-07-29 08:29:29 +00:00
const first = items[0];
2026-07-20 16:05:17 +00:00
let type;
2026-07-29 08:29:29 +00:00
if (first != null) {
2026-07-20 16:05:17 +00:00
type = first.type;
}
2026-08-24 06:08:38 +00:00
_modDef38("text" === type, "First value is not text");
2026-07-29 08:29:29 +00:00
return items[0].text === TRUE_OPTION_NAME;
};
export const getOptionalBoolean = function getOptionalBoolean(arg0, arg1) {
let tmp = null;
if (null != arg0[arg1]) {
const arr = arg0[arg1];
if (null == arr) {
let items = [];
} else {
items = arr.filter((type) => {
let str = type;
if ("text" !== type.type) {
return tmp;
} else {
if (arg1 <= 0) {
let tmp4 = "" !== str.text.trim();
const str2 = str.text;
}
str = "";
tmp4 = "" !== str.text;
}
});
}
2026-08-24 06:08:38 +00:00
_modDef38(1 === items.length, "Contains multiple values");
2026-07-29 08:29:29 +00:00
const first = items[0];
let type;
if (first != null) {
type = first.type;
}
2026-08-24 06:08:38 +00:00
_modDef38("text" === type, "First value is not text");
2026-07-29 08:29:29 +00:00
tmp = items[0].text === TRUE_OPTION_NAME;
2026-08-24 06:08:38 +00:00
const tmp5 = _modDef38;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return tmp;
};
export const getChannelId = function getChannelId(arg0, arg1) {
const arr = arg0[arg1];
if (null == arr) {
let items = [];
} else {
items = arr.filter((type) => {
let str = type;
if ("text" !== type.type) {
return tmp;
} else {
if (arg1 <= 0) {
let tmp4 = "" !== str.text.trim();
const str2 = str.text;
}
str = "";
tmp4 = "" !== str.text;
}
});
}
2026-08-24 06:08:38 +00:00
_modDef38(1 === items.length, "Contains multiple values");
2026-07-29 08:29:29 +00:00
const first = items[0];
2026-07-20 16:05:17 +00:00
let type;
2026-07-29 08:29:29 +00:00
if (first != null) {
2026-07-20 16:05:17 +00:00
type = first.type;
}
2026-08-24 06:08:38 +00:00
_modDef38("channelMention" === type, "First value is not a channel mention");
2026-07-29 08:29:29 +00:00
return items[0].channelId;
};
export const getOptionalChannelId = function getOptionalChannelId(arg0, arg1) {
let channelId = null;
if (null != arg0[arg1]) {
const arr = arg0[arg1];
if (null == arr) {
let items = [];
} else {
items = arr.filter((type) => {
let str = type;
if ("text" !== type.type) {
return tmp;
} else {
if (arg1 <= 0) {
let tmp4 = "" !== str.text.trim();
const str2 = str.text;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
str = "";
tmp4 = "" !== str.text;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
});
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
_modDef38(1 === items.length, "Contains multiple values");
2026-07-29 08:29:29 +00:00
const first = items[0];
let type;
if (first != null) {
type = first.type;
}
2026-08-24 06:08:38 +00:00
_modDef38("channelMention" === type, "First value is not a channel mention");
2026-07-29 08:29:29 +00:00
channelId = items[0].channelId;
2026-08-24 06:08:38 +00:00
const tmp5 = _modDef38;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return channelId;
2026-07-20 16:05:17 +00:00
};
2026-07-29 08:29:29 +00:00
export const getUserId = function getUserId(arg0, arg1) {
const arr = arg0[arg1];
if (null == arr) {
let items = [];
} else {
items = arr.filter((type) => {
let str = type;
if ("text" !== type.type) {
return tmp;
} else {
if (arg1 <= 0) {
let tmp4 = "" !== str.text.trim();
const str2 = str.text;
}
str = "";
tmp4 = "" !== str.text;
}
});
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
_modDef38(1 === items.length, "Contains multiple values");
2026-07-29 08:29:29 +00:00
const first = items[0];
let type;
if (first != null) {
type = first.type;
}
2026-08-24 06:08:38 +00:00
_modDef38("userMention" === type, "First value is not a user mention");
2026-07-29 08:29:29 +00:00
return items[0].userId;
2026-07-20 16:05:17 +00:00
};
export const getOptionalUserId = function getOptionalUserId(arg0, arg1) {
2026-07-29 08:29:29 +00:00
let userId = null;
2026-07-20 16:05:17 +00:00
if (null != arg0[arg1]) {
2026-07-29 08:29:29 +00:00
const arr = arg0[arg1];
if (null == arr) {
let items = [];
} else {
items = arr.filter((type) => {
let str = type;
if ("text" !== type.type) {
return tmp;
} else {
if (arg1 <= 0) {
let tmp4 = "" !== str.text.trim();
const str2 = str.text;
}
str = "";
tmp4 = "" !== str.text;
}
});
}
2026-08-24 06:08:38 +00:00
_modDef38(1 === items.length, "Contains multiple values");
2026-07-29 08:29:29 +00:00
const first = items[0];
let type;
if (first != null) {
type = first.type;
}
2026-08-24 06:08:38 +00:00
_modDef38("userMention" === type, "First value is not a user mention");
2026-07-29 08:29:29 +00:00
userId = items[0].userId;
2026-08-24 06:08:38 +00:00
const tmp5 = _modDef38;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return userId;
};
export const getRoleId = function getRoleId(arg0, arg1) {
const arr = arg0[arg1];
if (null == arr) {
let items = [];
} else {
items = arr.filter((type) => {
let str = type;
if ("text" !== type.type) {
return tmp;
} else {
if (arg1 <= 0) {
let tmp4 = "" !== str.text.trim();
const str2 = str.text;
}
str = "";
tmp4 = "" !== str.text;
}
});
}
2026-08-24 06:08:38 +00:00
_modDef38(1 === items.length, "Contains multiple values");
2026-07-29 08:29:29 +00:00
const first = items[0];
let type;
if (first != null) {
type = first.type;
}
2026-08-24 06:08:38 +00:00
_modDef38("roleMention" === type, "First value is not a role mention");
2026-07-29 08:29:29 +00:00
return items[0].roleId;
2026-07-20 16:05:17 +00:00
};
export const getOptionalRoleId = function getOptionalRoleId(arg0, arg1) {
2026-07-29 08:29:29 +00:00
let roleId = null;
2026-07-20 16:05:17 +00:00
if (null != arg0[arg1]) {
2026-07-29 08:29:29 +00:00
const arr = arg0[arg1];
if (null == arr) {
let items = [];
} else {
items = arr.filter((type) => {
let str = type;
if ("text" !== type.type) {
return tmp;
} else {
if (arg1 <= 0) {
let tmp4 = "" !== str.text.trim();
const str2 = str.text;
}
str = "";
tmp4 = "" !== str.text;
}
});
}
2026-08-24 06:08:38 +00:00
_modDef38(1 === items.length, "Contains multiple values");
2026-07-29 08:29:29 +00:00
const first = items[0];
let type;
if (first != null) {
type = first.type;
}
2026-08-24 06:08:38 +00:00
_modDef38("roleMention" === type, "First value is not a role mention");
2026-07-29 08:29:29 +00:00
roleId = items[0].roleId;
2026-08-24 06:08:38 +00:00
const tmp5 = _modDef38;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return roleId;
2026-07-20 16:05:17 +00:00
};
export { getString };
2026-07-29 08:29:29 +00:00
export const getOptionalString = function getOptionalString(closure_1, name) {
2026-07-20 16:05:17 +00:00
let tmp = null;
2026-07-29 08:29:29 +00:00
if (null != closure_1[name]) {
tmp = getString(closure_1, name);
2026-07-20 16:05:17 +00:00
}
return tmp;
};
2026-07-29 08:29:29 +00:00
export const normalizeNumericString = function normalizeNumericString(locale, trimmed) {
2026-07-23 10:11:24 +00:00
if (locale !== closure_5) {
closure_5 = locale;
2026-08-24 06:08:38 +00:00
en_US = numberParts.numberParts[locale];
2026-07-29 08:29:29 +00:00
if (en_US == null) {
2026-08-24 06:08:38 +00:00
en_US = tmp11(10296).numberParts["en-US"];
2026-07-20 16:05:17 +00:00
}
const _RegExp = RegExp;
({ group, decimal } = en_US);
2026-08-24 06:08:38 +00:00
const regExp = new RegExp(setDefault.escape(group), "g");
2026-07-20 16:05:17 +00:00
const _RegExp2 = RegExp;
2026-08-24 06:08:38 +00:00
const obj = setDefault;
2026-07-29 08:29:29 +00:00
tmp11 = require;
2026-08-24 06:08:38 +00:00
const regExp1 = new RegExp(setDefault.escape(decimal), "g");
const obj2 = setDefault;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return trimmed.replace(regExp, "").replace(regExp1, ".");
2026-07-20 16:05:17 +00:00
};
export const getInitialValuesFromInteractionOptions = function getInitialValuesFromInteractionOptions(command, interactionOptions) {
2026-08-24 06:08:38 +00:00
closure_0 = command;
2026-07-20 16:05:17 +00:00
const obj = {};
2026-07-29 08:29:29 +00:00
function _loop(iter) {
2026-08-24 06:08:38 +00:00
command = iter;
2026-07-23 10:11:24 +00:00
const options = command.options;
2026-07-29 08:29:29 +00:00
if (options != null) {
const found = options.find((name) => name.name === iter.name);
2026-07-20 16:05:17 +00:00
}
let num = 0;
2026-08-24 06:08:38 +00:00
if (iter.type !== command(closure_1_2[4]).ApplicationCommandOptionType.ATTACHMENT) {
2026-07-29 08:29:29 +00:00
let autocomplete;
if (found != null) {
autocomplete = found.autocomplete;
}
num = 0;
if (!autocomplete) {
obj[iter.name] = iter;
2026-07-20 16:05:17 +00:00
}
}
return num;
}
2026-07-29 08:29:29 +00:00
const iter = interactionOptions[Symbol.iterator]();
while (iter !== undefined) {
let _loopResult = _loop(iter.next());
continue;
2026-07-20 16:05:17 +00:00
}
return obj;
};