decord/source/modules/application_commands/ApplicationCommandOptionUtils.tsx

363 lines
10 KiB
TypeScript
Raw Normal View History

// Module ID: 9555
// Function ID: 9556
// Name: ApplicationCommandOptionUtils
// Dependencies: [5084, 38, 9556, 4625, 1895, 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
// Module 9555 (ApplicationCommandOptionUtils)
2026-08-24 06:08:38 +00:00
import _modDef38 from "module_38" /* 38 */;
import Server from "Server" /* 1895 */;
import RegexUtilsDefault from "RegexUtils" /* 4625 */;
import ApplicationCommandConstants from "ApplicationCommandConstants" /* 5084 */;
import numberParts from "numberParts" /* 9556 */;
import size from "module_2" /* 2 */;
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 _HermesInternal4 = HermesInternal;
str = `${"<@" + tmp2.userId + ">"}`;
} else if ("channelMention" === type) {
let _HermesInternal3 = HermesInternal;
str = `${"<@" + tmp2.userId + ">"}${"<#" + tmp2.channelId + ">"}`;
} else if ("roleMention" === type) {
let _HermesInternal2 = HermesInternal;
str = `${"<@" + tmp2.userId + ">"}${"<#" + tmp2.channelId + ">"}${"<@&" + tmp2.roleId + ">"}`;
} else if ("emoji" === type) {
str = `${"<@" + tmp2.userId + ">"}${"<#" + tmp2.channelId + ">"}${"<@&" + tmp2.roleId + ">"}${tmp2.surrogate}`;
} else if ("customEmoji" === type) {
let str2 = "";
if (tmp2.animated) {
str2 = "a";
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let str3 = tmp2.name;
let str4 = str3.replace(/:/g, "");
let _HermesInternal = HermesInternal;
let str5 = "<";
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
return str;
2026-07-20 16:05:17 +00:00
}
const TRUE_OPTION_NAME = ApplicationCommandConstants.TRUE_OPTION_NAME;
const result = size.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, index) => {
2026-07-20 16:05:17 +00:00
let str = type;
if ("text" !== type.type) {
return tmp;
} else {
if (index <= 0) {
2026-07-29 08:29:29 +00:00
let tmp4 = "" !== str.text.trim();
2026-07-20 16:05:17 +00:00
}
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, index) => {
2026-07-29 08:29:29 +00:00
let str = type;
if ("text" !== type.type) {
return tmp;
} else {
if (index <= 0) {
2026-07-29 08:29:29 +00:00
let tmp4 = "" !== str.text.trim();
}
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, index) => {
2026-07-29 08:29:29 +00:00
let str = type;
if ("text" !== type.type) {
return tmp;
} else {
if (index <= 0) {
2026-07-29 08:29:29 +00:00
let tmp4 = "" !== str.text.trim();
}
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-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, index) => {
2026-07-29 08:29:29 +00:00
let str = type;
if ("text" !== type.type) {
return tmp;
} else {
if (index <= 0) {
2026-07-29 08:29:29 +00:00
let tmp4 = "" !== str.text.trim();
}
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, index) => {
2026-07-29 08:29:29 +00:00
let str = type;
if ("text" !== type.type) {
return tmp;
} else {
if (index <= 0) {
2026-07-29 08:29:29 +00:00
let tmp4 = "" !== str.text.trim();
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-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, index) => {
2026-07-29 08:29:29 +00:00
let str = type;
if ("text" !== type.type) {
return tmp;
} else {
if (index <= 0) {
2026-07-29 08:29:29 +00:00
let tmp4 = "" !== str.text.trim();
}
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, index) => {
2026-07-29 08:29:29 +00:00
let str = type;
if ("text" !== type.type) {
return tmp;
} else {
if (index <= 0) {
2026-07-29 08:29:29 +00:00
let tmp4 = "" !== str.text.trim();
}
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-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, index) => {
2026-07-29 08:29:29 +00:00
let str = type;
if ("text" !== type.type) {
return tmp;
} else {
if (index <= 0) {
2026-07-29 08:29:29 +00:00
let tmp4 = "" !== str.text.trim();
}
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, index) => {
2026-07-29 08:29:29 +00:00
let str = type;
if ("text" !== type.type) {
return tmp;
} else {
if (index <= 0) {
2026-07-29 08:29:29 +00:00
let tmp4 = "" !== str.text.trim();
}
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-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 };
export const getOptionalString = function getOptionalString(arg0, name) {
2026-07-20 16:05:17 +00:00
let tmp = null;
if (null != arg0[name]) {
tmp = getString(arg0, 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) {
if (locale !== global) {
global = locale;
let prop = numberParts.numberParts[locale];
if (prop == null) {
prop = tmp12(9556).numberParts["en-US"];
2026-07-20 16:05:17 +00:00
}
const _RegExp = RegExp;
({ group, decimal } = prop);
regExp = new RegExp(RegexUtilsDefault.escape(group), "g");
2026-07-20 16:05:17 +00:00
const _RegExp2 = RegExp;
tmp12 = require;
regExp1 = new RegExp(RegexUtilsDefault.escape(decimal), "g");
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) {
let options = command;
2026-07-20 16:05:17 +00:00
const obj = {};
2026-07-29 08:29:29 +00:00
function _loop(iter) {
options = iter;
options = options.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;
if (iter.type !== Server.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;
};