decord/source/modules/chat_input/native/ApplicationCommandOptionValueParser.tsx

513 lines
18 KiB
TypeScript
Raw Normal View History

2026-08-25 06:04:03 +00:00
// Module ID: 11564
// Function ID: 11565
2026-07-29 08:29:29 +00:00
// Name: getUsers
2026-08-25 06:04:03 +00:00
// Dependencies: [19, 5329, 1395, 1982, 1992, 1985, 4034, 1922, 4839, 12, 1370, 4574, 5266, 1955, 7287, 2]
2026-07-29 08:29:29 +00:00
// Exports: getRoles, parseOptionValuesForSend, useApplicationCommandOptionValueParser
2026-07-20 16:05:17 +00:00
2026-08-25 06:04:03 +00:00
// Module 11564 (getUsers)
2026-08-24 06:08:38 +00:00
import applyDefault from "apply" /* 12 */;
import isDiscordFrontendDevelopment from "isDiscordFrontendDevelopment" /* 1370 */;
2026-08-25 06:04:03 +00:00
import PermissionOverwriteType from "PermissionOverwriteType" /* 1955 */;
import rebuild from "rebuild" /* 7287 */;
import rebuildDefault from "rebuild" /* 7287 */;
2026-08-24 06:08:38 +00:00
import closure_3 from "noop" /* 19 */;
2026-08-25 06:04:03 +00:00
import closure_4 from "rebuild" /* 5329 */;
2026-08-24 06:08:38 +00:00
import { isGuildSelectableChannelType as closure_5 } from "createChannelRecord" /* 1395 */;
2026-08-25 06:04:03 +00:00
import closure_6 from "comparator" /* 1982 */;
import closure_7 from "trackCommunicationDisabled" /* 1992 */;
import closure_8 from "createGuildRoleRecordFromRust" /* 1985 */;
import closure_9 from "markAllUserIdListsStale" /* 4034 */;
2026-08-24 06:08:38 +00:00
import closure_10 from "mergeGuildAvatar" /* 1922 */;
2026-08-25 06:04:03 +00:00
import regExp from "regExp" /* 4839 */;
2026-07-23 10:11:24 +00:00
2026-08-24 06:08:38 +00:00
require = arg1;
2026-07-20 16:05:17 +00:00
function getUsers(getGuildId) {
const guildId = getGuildId.getGuildId();
if (getGuildId.isPrivate()) {
2026-08-24 06:08:38 +00:00
let mapped = applyDefault(getGuildId.recipients).map((userId) => ({ userId }));
const arr3 = applyDefault(getGuildId.recipients);
2026-07-20 16:05:17 +00:00
} else if (null != guildId) {
2026-08-24 06:08:38 +00:00
const tmp7 = applyDefault;
mapped = applyDefault(members.getMembers(guildId)).map((userId) => ({ userId: userId.userId }));
const tmp7Result = applyDefault(members.getMembers(guildId));
2026-07-20 16:05:17 +00:00
} else {
2026-08-24 06:08:38 +00:00
mapped = applyDefault([]);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
const mapped1 = mapped.map((userId) => user.getUser(userId.userId));
2026-08-24 06:08:38 +00:00
const found = mapped1.filter(isDiscordFrontendDevelopment.isNotNullish);
2026-07-20 16:05:17 +00:00
return found.map((id) => ({ id: id.id, text: id.tag }));
}
function getChannels(getGuildId, arr) {
2026-07-23 10:11:24 +00:00
const _require = arr;
2026-07-20 16:05:17 +00:00
const guildId = getGuildId.getGuildId();
if (null == guildId) {
const items = [];
if (tmp2) {
items.push(getGuildId);
}
2026-07-23 10:11:24 +00:00
tmp2 = null == arr || arr.includes(getGuildId.type);
2026-07-29 08:29:29 +00:00
return guildId(12)(items).map((id) => {
2026-08-25 06:04:03 +00:00
const obj = { id: id.id, text: arr(4574).computeChannelName(id, closure_10, closure_9) };
2026-07-20 16:05:17 +00:00
return obj;
});
} else {
2026-08-24 06:08:38 +00:00
dependencyMap = textChannelNameDisambiguations.getTextChannelNameDisambiguations(guildId);
2026-07-29 08:29:29 +00:00
const tmp9 = guildId(12);
2026-08-25 06:04:03 +00:00
const tmp9Result = guildId(12)(_require(5266).COMMAND_SUPPORTED_CHANNEL_TYPE_KEYS);
const combined = guildId(12)(_require(5266).COMMAND_SUPPORTED_CHANNEL_TYPE_KEYS).flatMap((arg0) => closure_1_6.getChannels(guildId)[arg0].map((channel) => channel.channel)).concat(closure_4.computeAllActiveJoinedThreads(guildId));
2026-07-20 16:05:17 +00:00
const found = combined.filter((type) => {
2026-07-29 08:29:29 +00:00
let hasItem = null == closure_0;
2026-07-20 16:05:17 +00:00
if (!hasItem) {
2026-07-29 08:29:29 +00:00
hasItem = closure_0.includes(type.type);
2026-07-20 16:05:17 +00:00
}
return hasItem;
});
return found.map((id) => {
2026-07-29 08:29:29 +00:00
const obj = { id: id.id, text: null };
2026-08-24 06:08:38 +00:00
if (closure_1_5(id.type)) {
2026-07-29 08:29:29 +00:00
let name;
if (dependencyMap[id.id] != null) {
name = tmp7.name;
}
if (name == null) {
2026-08-25 06:04:03 +00:00
name = arr(4574).computeChannelName(id, closure_1_10, closure_1_9);
const obj3 = arr(4574);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let channelName = name;
} else {
2026-08-25 06:04:03 +00:00
channelName = arr(4574).computeChannelName(id, closure_1_10, closure_1_9);
const obj2 = arr(4574);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj[1] = channelName;
2026-07-20 16:05:17 +00:00
return obj;
});
}
}
2026-07-29 08:29:29 +00:00
({ MENTION_SENTINEL: unpackModuleId, CHANNEL_SENTINEL: closure_12 } = regExp);
const re13 = /^@(([^@#:]+)#([0-9]{4}))$/i;
function matchPrefix(arg0, arg1, arg2) {
}
const prototype = function ApplicationCommandOptionValueParser(channel) {
const obj = Object.create(new.target.prototype);
obj.parse = function parse(text, type) {
const str = text.trim();
let arr6 = str;
2026-08-24 06:08:38 +00:00
let arr = closure_1_15(arr6.channel);
closure_1 = arr;
2026-07-29 08:29:29 +00:00
const guild_id = arr6.channel.guild_id;
if (null != guild_id) {
2026-08-24 06:08:38 +00:00
let sortedRoles = closure_1_8.getSortedRoles(guild_id);
2026-07-29 08:29:29 +00:00
} else {
sortedRoles = [];
}
2026-08-24 06:08:38 +00:00
closure_2 = closure_1_1(closure_1_2[9])(sortedRoles).map((id) => ({ id: id.id, text: id.name }));
closure_3 = arr.map((text) => {
obj = {};
2026-07-29 08:29:29 +00:00
const merged = Object.assign(text);
obj.text = text.text.split("#")[0];
return obj;
2026-07-20 16:05:17 +00:00
});
2026-07-29 08:29:29 +00:00
function matchUser() {
2026-08-24 06:08:38 +00:00
const arr = closure_1_11;
obj = closure_1;
if (typeof closure_1_14 !== "function") {
2026-07-29 08:29:29 +00:00
HermesBuiltin.throwTypeError();
}
let firstResult = null;
if (arr[0] === arr) {
closure_1 = str.substr(arr.length);
const found = obj.sortBy((text) => -text.text.length).filter((text) => {
const formatted = closure_1.toLowerCase();
return formatted === text.text.toLowerCase();
});
const mapped = found.map((id) => ({ text: arr + id.text, id: id.id }));
firstResult = mapped.first();
const sortByResult = obj.sortBy((text) => -text.text.length);
}
let id;
if (firstResult != null) {
id = firstResult.id;
}
if (null != id) {
obj = { type: "userMention", userId: null };
obj[1] = firstResult.id;
let tmp6 = obj;
} else {
2026-08-24 06:08:38 +00:00
if (typeof closure_1_14 !== "function") {
2026-07-29 08:29:29 +00:00
HermesBuiltin.throwTypeError();
}
let firstResult1 = null;
if (str[0] === arr) {
closure_1 = str.substr(arr.length);
const found1 = obj6.sortBy((text) => -text.text.length).filter((text) => {
const formatted = closure_1.toLowerCase();
return formatted === text.text.toLowerCase();
});
const mapped1 = found1.map((id) => ({ text: arr + id.text, id: id.id }));
firstResult1 = mapped1.first();
const sortByResult1 = obj6.sortBy((text) => -text.text.length);
}
let id1;
if (firstResult1 != null) {
id1 = firstResult1.id;
}
if (null != id1) {
obj = { type: "userMention", userId: null };
obj[1] = firstResult1.id;
tmp6 = obj;
}
2026-08-24 06:08:38 +00:00
obj6 = closure_3;
2026-07-29 08:29:29 +00:00
}
return tmp6;
}
2026-08-24 06:08:38 +00:00
if (type.type === obj(closure_1_2[13]).ApplicationCommandOptionType.USER) {
2026-07-29 08:29:29 +00:00
const matchUserResult = matchUser();
if (null != matchUserResult) {
return matchUserResult;
} else {
2026-08-24 06:08:38 +00:00
closure_1_13.lastIndex = 0;
const match = closure_1_13.exec(str);
2026-07-29 08:29:29 +00:00
if (null != match) {
2026-08-24 06:08:38 +00:00
const findByTagResult = closure_1_10.findByTag(match[2], match[3]);
2026-07-29 08:29:29 +00:00
if (null != findByTagResult) {
obj = { type: "userMention", userId: null };
obj[1] = findByTagResult.id;
return obj;
}
}
}
}
function matchRole() {
2026-08-24 06:08:38 +00:00
const arr = closure_1_11;
obj = closure_2;
if (typeof closure_1_14 !== "function") {
2026-07-29 08:29:29 +00:00
HermesBuiltin.throwTypeError();
}
let firstResult = null;
if (arr[0] === arr) {
2026-08-24 06:08:38 +00:00
closure_1 = str.substr(arr.length);
2026-07-29 08:29:29 +00:00
const found = obj.sortBy((text) => -text.text.length).filter((text) => {
const formatted = closure_1.toLowerCase();
return formatted === text.text.toLowerCase();
});
const mapped = found.map((id) => ({ text: arr + id.text, id: id.id }));
firstResult = mapped.first();
const sortByResult = obj.sortBy((text) => -text.text.length);
}
let id;
if (firstResult != null) {
id = firstResult.id;
}
if (null != id) {
obj = { type: "roleMention", roleId: null };
obj[1] = firstResult.id;
} else if ("@everyone" === str) {
obj = { type: "textMention", text: "@everyone" };
}
return obj;
}
2026-08-24 06:08:38 +00:00
if (type.type === obj(closure_1_2[13]).ApplicationCommandOptionType.ROLE) {
2026-07-29 08:29:29 +00:00
const matchRoleResult = matchRole();
if (null != matchRoleResult) {
return matchRoleResult;
}
}
2026-08-24 06:08:38 +00:00
if (type.type === obj(closure_1_2[13]).ApplicationCommandOptionType.CHANNEL) {
arr6 = closure_1_12;
if (typeof closure_1_14 !== "function") {
2026-07-29 08:29:29 +00:00
HermesBuiltin.throwTypeError();
}
let firstResult = null;
if (str[0] === arr6) {
closure_1 = str.substr(arr6.length);
let found = obj6.sortBy((text) => -text.text.length).filter((text) => {
const formatted = closure_1.toLowerCase();
return formatted === text.text.toLowerCase();
});
let mapped = found.map((id) => ({ text: arr + id.text, id: id.id }));
firstResult = mapped.first();
let sortByResult = obj6.sortBy((text) => -text.text.length);
}
if (null != firstResult) {
if (null != firstResult.id) {
obj = { type: "channelMention", channelId: null };
obj[1] = firstResult.id;
return obj;
}
}
2026-08-24 06:08:38 +00:00
obj6 = closure_1_16(arr6.channel, type.channelTypes);
2026-07-29 08:29:29 +00:00
}
2026-08-24 06:08:38 +00:00
if (type.type === obj(closure_1_2[13]).ApplicationCommandOptionType.MENTIONABLE) {
2026-07-29 08:29:29 +00:00
const matchRoleResult1 = matchRole();
if (null != matchRoleResult1) {
return matchRoleResult1;
} else {
const matchUserResult1 = matchUser();
if (null != matchUserResult1) {
return matchUserResult1;
} else {
2026-08-24 06:08:38 +00:00
closure_1_13.lastIndex = 0;
const match1 = closure_1_13.exec(str);
2026-07-29 08:29:29 +00:00
if (null != match1) {
2026-08-24 06:08:38 +00:00
const findByTagResult1 = closure_1_10.findByTag(match1[2], match1[3]);
2026-07-29 08:29:29 +00:00
if (null != findByTagResult1) {
2026-08-24 06:08:38 +00:00
obj1 = { type: "userMention", userId: null };
2026-07-29 08:29:29 +00:00
obj1[1] = findByTagResult1.id;
return obj1;
}
}
}
}
}
return { type: "text", text };
};
obj.channel = channel;
return obj;
}.prototype;
2026-08-24 06:08:38 +00:00
const result = require("set").fileFinishedImporting("modules/chat_input/native/ApplicationCommandOptionValueParser.tsx");
2026-07-29 08:29:29 +00:00
export { getUsers };
export const getRoles = function getRoles(guild_id) {
guild_id = guild_id.guild_id;
if (null != guild_id) {
sortedRoles = sortedRoles.getSortedRoles(guild_id);
} else {
sortedRoles = [];
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
return applyDefault(sortedRoles).map((id) => ({ id: id.id, text: id.name }));
2026-07-29 08:29:29 +00:00
};
export { getChannels };
export const ApplicationCommandOptionValueParser = prototype;
export const parseOptionValuesForSend = function parseOptionValuesForSend(channel, activeCommand, current) {
if (null == activeCommand.options) {
return {};
} else {
let obj = {};
const options = activeCommand.options;
2026-08-24 06:08:38 +00:00
const parserState = rebuild.createParserState(channel);
2026-07-29 08:29:29 +00:00
const iter = options[Symbol.iterator]();
const nextResult = iter.next();
while (iter !== undefined) {
let tmp4 = nextResult;
let tmp5 = current[nextResult.name];
let tmp6 = tmp5;
if (null != tmp5) {
let tmp21 = tmp5;
if ("text" === tmp6[0].type) {
let tmp22 = nextResult;
let tmp23 = require;
let tmp24 = dependencyMap;
let tmp25 = dependencyMap;
2026-08-24 06:08:38 +00:00
if (tmp4.type === PermissionOverwriteType.ApplicationCommandOptionType.STRING) {
2026-07-29 08:29:29 +00:00
let tmp7 = nextResult;
if (null == tmp4.choices) {
let tmp8 = nextResult;
if (!tmp4.autocomplete) {
let tmp9 = nextResult;
obj = { type: "text", text: null };
let tmp10 = importDefault;
let tmp11 = tmp24;
2026-08-24 06:08:38 +00:00
let obj2 = rebuildDefault;
2026-07-29 08:29:29 +00:00
let tmp12 = tmp5;
obj[1] = obj2.parse(channel, tmp6[0].text, parserState).content;
let items = [obj];
obj[tmp4.name] = items;
}
}
}
}
let tmp13 = nextResult;
let tmp14 = tmp5;
obj[tmp4.name] = tmp6;
}
continue;
}
return obj;
}
};
export const useApplicationCommandOptionValueParser = function useApplicationCommandOptionValueParser(channel) {
channel = channel.channel;
const items = [channel];
return React.useMemo(() => {
2026-08-24 06:08:38 +00:00
if (typeof closure_1_17 !== "function") {
2026-07-29 08:29:29 +00:00
HermesBuiltin.throwTypeError();
}
2026-08-24 06:08:38 +00:00
let obj = Object.create(closure_1_17.prototype);
2026-07-29 08:29:29 +00:00
obj.parse = function parse(text, type) {
const str = text.trim();
let arr6 = str;
2026-08-24 06:08:38 +00:00
let arr = closure_1_15(arr6.channel);
closure_1 = arr;
2026-07-29 08:29:29 +00:00
const guild_id = arr6.channel.guild_id;
if (null != guild_id) {
2026-08-24 06:08:38 +00:00
let sortedRoles = closure_1_8.getSortedRoles(guild_id);
2026-07-29 08:29:29 +00:00
} else {
sortedRoles = [];
}
2026-08-24 06:08:38 +00:00
closure_2 = closure_1_1(closure_1_2[9])(sortedRoles).map((id) => ({ id: id.id, text: id.name }));
closure_3 = arr.map((text) => {
obj = {};
2026-07-20 16:05:17 +00:00
const merged = Object.assign(text);
2026-07-29 08:29:29 +00:00
obj.text = text.text.split("#")[0];
2026-07-20 16:05:17 +00:00
return obj;
});
function matchUser() {
2026-08-24 06:08:38 +00:00
const arr = closure_1_11;
obj = closure_1;
if (typeof closure_1_14 !== "function") {
2026-07-29 08:29:29 +00:00
HermesBuiltin.throwTypeError();
}
let firstResult = null;
if (arr[0] === arr) {
closure_1 = str.substr(arr.length);
const found = obj.sortBy((text) => -text.text.length).filter((text) => {
const formatted = closure_1.toLowerCase();
return formatted === text.text.toLowerCase();
});
const mapped = found.map((id) => ({ text: arr + id.text, id: id.id }));
firstResult = mapped.first();
const sortByResult = obj.sortBy((text) => -text.text.length);
}
2026-07-20 16:05:17 +00:00
let id;
2026-07-29 08:29:29 +00:00
if (firstResult != null) {
id = firstResult.id;
2026-07-20 16:05:17 +00:00
}
if (null != id) {
2026-07-29 08:29:29 +00:00
obj = { type: "userMention", userId: null };
obj[1] = firstResult.id;
let tmp6 = obj;
2026-07-20 16:05:17 +00:00
} else {
2026-08-24 06:08:38 +00:00
if (typeof closure_1_14 !== "function") {
2026-07-29 08:29:29 +00:00
HermesBuiltin.throwTypeError();
}
let firstResult1 = null;
if (str[0] === arr) {
closure_1 = str.substr(arr.length);
const found1 = obj6.sortBy((text) => -text.text.length).filter((text) => {
const formatted = closure_1.toLowerCase();
return formatted === text.text.toLowerCase();
});
const mapped1 = found1.map((id) => ({ text: arr + id.text, id: id.id }));
firstResult1 = mapped1.first();
const sortByResult1 = obj6.sortBy((text) => -text.text.length);
}
2026-07-20 16:05:17 +00:00
let id1;
2026-07-29 08:29:29 +00:00
if (firstResult1 != null) {
id1 = firstResult1.id;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (null != id1) {
obj = { type: "userMention", userId: null };
obj[1] = firstResult1.id;
tmp6 = obj;
}
2026-08-24 06:08:38 +00:00
obj6 = closure_3;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return tmp6;
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
if (type.type === obj(closure_1_2[13]).ApplicationCommandOptionType.USER) {
2026-07-20 16:05:17 +00:00
const matchUserResult = matchUser();
if (null != matchUserResult) {
return matchUserResult;
} else {
2026-08-24 06:08:38 +00:00
closure_1_13.lastIndex = 0;
const match = closure_1_13.exec(str);
2026-07-20 16:05:17 +00:00
if (null != match) {
2026-08-24 06:08:38 +00:00
const findByTagResult = closure_1_10.findByTag(match[2], match[3]);
2026-07-20 16:05:17 +00:00
if (null != findByTagResult) {
2026-07-29 08:29:29 +00:00
obj = { type: "userMention", userId: null };
obj[1] = findByTagResult.id;
2026-07-20 16:05:17 +00:00
return obj;
}
}
}
}
2026-07-29 08:29:29 +00:00
function matchRole() {
2026-08-24 06:08:38 +00:00
const arr = closure_1_11;
obj = closure_2;
if (typeof closure_1_14 !== "function") {
2026-07-29 08:29:29 +00:00
HermesBuiltin.throwTypeError();
}
let firstResult = null;
if (arr[0] === arr) {
2026-08-24 06:08:38 +00:00
closure_1 = str.substr(arr.length);
2026-07-29 08:29:29 +00:00
const found = obj.sortBy((text) => -text.text.length).filter((text) => {
const formatted = closure_1.toLowerCase();
return formatted === text.text.toLowerCase();
});
const mapped = found.map((id) => ({ text: arr + id.text, id: id.id }));
firstResult = mapped.first();
const sortByResult = obj.sortBy((text) => -text.text.length);
}
let id;
if (firstResult != null) {
id = firstResult.id;
}
if (null != id) {
obj = { type: "roleMention", roleId: null };
obj[1] = firstResult.id;
} else if ("@everyone" === str) {
obj = { type: "textMention", text: "@everyone" };
}
return obj;
}
2026-08-24 06:08:38 +00:00
if (type.type === obj(closure_1_2[13]).ApplicationCommandOptionType.ROLE) {
2026-07-20 16:05:17 +00:00
const matchRoleResult = matchRole();
if (null != matchRoleResult) {
return matchRoleResult;
}
}
2026-08-24 06:08:38 +00:00
if (type.type === obj(closure_1_2[13]).ApplicationCommandOptionType.CHANNEL) {
arr6 = closure_1_12;
if (typeof closure_1_14 !== "function") {
2026-07-29 08:29:29 +00:00
HermesBuiltin.throwTypeError();
}
let firstResult = null;
if (str[0] === arr6) {
closure_1 = str.substr(arr6.length);
let found = obj6.sortBy((text) => -text.text.length).filter((text) => {
const formatted = closure_1.toLowerCase();
return formatted === text.text.toLowerCase();
});
let mapped = found.map((id) => ({ text: arr + id.text, id: id.id }));
firstResult = mapped.first();
let sortByResult = obj6.sortBy((text) => -text.text.length);
}
if (null != firstResult) {
if (null != firstResult.id) {
obj = { type: "channelMention", channelId: null };
obj[1] = firstResult.id;
2026-07-20 16:05:17 +00:00
return obj;
}
}
2026-08-24 06:08:38 +00:00
obj6 = closure_1_16(arr6.channel, type.channelTypes);
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
if (type.type === obj(closure_1_2[13]).ApplicationCommandOptionType.MENTIONABLE) {
2026-07-20 16:05:17 +00:00
const matchRoleResult1 = matchRole();
if (null != matchRoleResult1) {
return matchRoleResult1;
} else {
const matchUserResult1 = matchUser();
if (null != matchUserResult1) {
return matchUserResult1;
} else {
2026-08-24 06:08:38 +00:00
closure_1_13.lastIndex = 0;
const match1 = closure_1_13.exec(str);
2026-07-20 16:05:17 +00:00
if (null != match1) {
2026-08-24 06:08:38 +00:00
const findByTagResult1 = closure_1_10.findByTag(match1[2], match1[3]);
2026-07-20 16:05:17 +00:00
if (null != findByTagResult1) {
2026-08-24 06:08:38 +00:00
obj1 = { type: "userMention", userId: null };
2026-07-29 08:29:29 +00:00
obj1[1] = findByTagResult1.id;
2026-07-20 16:05:17 +00:00
return obj1;
}
}
}
}
}
2026-07-29 08:29:29 +00:00
return { type: "text", text };
2026-07-20 16:05:17 +00:00
};
2026-07-29 08:29:29 +00:00
obj.channel = obj;
2026-07-20 16:05:17 +00:00
return obj;
2026-07-29 08:29:29 +00:00
}, items);
2026-07-20 16:05:17 +00:00
};