decord/source/modules/interaction_components/SearchableSelectActionComponentUtils.tsx
github-actions da5b5e5efe chore: update source for alpha 346.6
Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/04xxx/module_4821.js (118.4 MB)
2026-09-12 13:45:10 +00:00

234 lines
9.1 KiB
TypeScript

// Module ID: 8237
// Function ID: 8238
// Name: SearchableSelectActionComponentUtils
// Dependencies: [1957, 2021, 2015, 1979, 4285, 1371, 8230, 1894, 5523, 4788, 4868, 4789, 8238, 1369, 2]
// Exports: getInitialSnowflakeSelectOptions, getSnowflakeSelectDefaultValues, queryChannels, queryMentionables
// Module 8237 (SearchableSelectActionComponentUtils)
import NicknameUtilsDefault from "NicknameUtils" /* 4788 */;
import InteractionComponentTypes from "InteractionComponentTypes" /* 4868 */;
import AutocompleteUtilsDefault from "AutocompleteUtils" /* 5523 */;
import SnowflakeSelectDefaultValueTypes from "SnowflakeSelectDefaultValueTypes" /* 8238 */;
import ChannelStore from "ChannelStore" /* 1957 */;
import GuildMemberStore from "GuildMemberStore" /* 2021 */;
import GuildRoleStore from "GuildRoleStore" /* 2015 */;
import GuildStore from "GuildStore" /* 1979 */;
import RelationshipStore from "RelationshipStore" /* 4285 */;
import UserStore from "UserStore" /* 1371 */;
import LocalInteractionComponentStateStore from "LocalInteractionComponentStateStore" /* 8230 */;
const require = globalThis.__r;
require = fn;
const size = fn(2);
const result = size.fileFinishedImporting("modules/interaction_components/SearchableSelectActionComponentUtils.tsx");
export const MIN_REREQUEST_TIME = 1000;
export const queryMentionables = function queryMentionables(type, query, channelId) {
_require = channelId;
const channel = ChannelStore.getChannel(channelId);
if (null == channel) {
return [];
} else {
const tmp2 = type === require("Server").ComponentType.USER_SELECT || type === require("Server").ComponentType.MENTIONABLE_SELECT;
const tmp3 = type === require("Server").ComponentType.ROLE_SELECT || type === require("Server").ComponentType.MENTIONABLE_SELECT;
let obj2 = { query, channel, canMentionEveryone: false, canMentionHere: false, canMentionUsers: tmp2, canMentionRoles: tmp3, includeAllGuildUsers: true, includeNonMentionableRoles: true, checkRecentlyTalkedOnEmptyQuery: false, limit: 15 };
const obj = channel(5523);
({ users, roles } = channel(5523).queryMentionResults(obj2));
const items = [];
const queryMentionResultsResult = channel(5523).queryMentionResults(obj2);
HermesBuiltin.arraySpread(roles.map((id) => ({ type: channelId(dependencyMap[10]).SelectOptionType.ROLE, value: id.id, label: id.name })), HermesBuiltin.arraySpread(users.map((user) => {
let username = NicknameUtilsDefault.getNickname(channel.getGuildId(), closure_0, user.user);
const obj2 = { type: InteractionComponentTypes.SelectOptionType.USER, value: user.user.id, label: null };
if (username == null) {
username = user.user.globalName;
}
if (username == null) {
username = user.user.username;
}
obj2.label = username;
return obj2;
}), 0));
return items;
}
};
export const queryChannels = function queryChannels(query, arg1, channelTypes) {
const channel = ChannelStore.getChannel(arg1);
if (null == channel) {
let items = [];
} else {
const obj2 = { query, channel, channelTypes, limit: 15 };
const channels = AutocompleteUtilsDefault.queryApplicationCommandChannelResults(obj2).channels;
items = channels.map((id) => {
const obj = { type: require("InteractionComponentTypes").SelectOptionType.CHANNEL, value: id.id, label: require("useChannelName").computeChannelName(id, UserStore, RelationshipStore) };
return obj;
});
}
return items;
};
export const getInitialSnowflakeSelectOptions = function getInitialSnowflakeSelectOptions(selectActionComponent, containerId, guildId) {
const interactionComponentState = LocalInteractionComponentStateStore.getInteractionComponentState(containerId, selectActionComponent.id);
const defaultValues = selectActionComponent.defaultValues;
let channelTypes;
if (selectActionComponent.type === channelTypes(1894).ComponentType.CHANNEL_SELECT) {
channelTypes = selectActionComponent.channelTypes;
}
if (channelTypes === undefined) {
channelTypes = [];
}
let guild;
if (null != defaultValues) {
guild = GuildStore.getGuild(guildId);
const mapped = defaultValues.map((type) => {
type = type.type;
if (SnowflakeSelectDefaultValueTypes.SnowflakeSelectDefaultValueTypes.USER === type) {
const user = UserStore.getUser(type.id);
if (null == user) {
return null;
} else {
let nick;
if (null != closure_1) {
nick = GuildMemberStore.getNick(tmp16.id, user.id);
}
const obj2 = { type: tmp(4868).SelectOptionType.USER, value: user.id, label: null };
if (nick == null) {
nick = user.globalName;
}
if (nick == null) {
nick = user.username;
}
obj2.label = nick;
return obj2;
}
} else if (tmp(8238).SnowflakeSelectDefaultValueTypes.ROLE === type) {
if (null == closure_1) {
return null;
} else {
const role = GuildRoleStore.getRole(tmp8.id, type.id);
let tmp12 = null;
if (null != role) {
const obj3 = { type: tmp(4868).SelectOptionType.ROLE, value: null, label: null };
({ id: obj4.value, name: obj4.label } = role);
tmp12 = obj3;
}
return tmp12;
}
} else if (tmp(8238).SnowflakeSelectDefaultValueTypes.CHANNEL === type) {
if (null == closure_1) {
return null;
} else {
const channel = ChannelStore.getChannel(type.id);
let tmp5 = null;
if (null != channel) {
tmp5 = null;
if (channel.guild_id === tmp3.id) {
if (channelTypes.length <= 0) {
const obj5 = { type: tmp(4868).SelectOptionType.CHANNEL, value: channel.id, label: tmp(4789).computeChannelName(channel, UserStore, RelationshipStore) };
tmp5 = obj5;
const tmpResult = tmp(4789);
} else {
tmp5 = null;
}
}
}
return tmp5;
}
}
});
let found = mapped.filter(tmp2(1369).isNotNullish);
}
let type;
if (interactionComponentState != null) {
type = interactionComponentState.type;
}
if (type !== channelTypes(1894).ComponentType.USER_SELECT) {
let type1;
if (interactionComponentState != null) {
type1 = interactionComponentState.type;
}
if (type1 !== tmp2(1894).ComponentType.ROLE_SELECT) {
let type2;
if (interactionComponentState != null) {
type2 = interactionComponentState.type;
}
if (type2 !== tmp2(1894).ComponentType.MENTIONABLE_SELECT) {
let type3;
if (interactionComponentState != null) {
type3 = interactionComponentState.type;
}
}
if (found == null) {
found = [];
}
return found;
}
}
found = interactionComponentState.selectedOptions;
};
export const getSnowflakeSelectDefaultValues = function getSnowflakeSelectDefaultValues(defaultValues, guild_id) {
let items = arg2;
if (arg2 === undefined) {
items = [];
}
let guild;
if (null != defaultValues) {
guild = GuildStore.getGuild(guild_id);
const mapped = defaultValues.map((type) => {
type = type.type;
if (SnowflakeSelectDefaultValueTypes.SnowflakeSelectDefaultValueTypes.USER === type) {
const user = UserStore.getUser(type.id);
if (null == user) {
return null;
} else {
let nick;
if (null != closure_1) {
nick = GuildMemberStore.getNick(tmp16.id, user.id);
}
const obj2 = { type: tmp(4868).SelectOptionType.USER, value: user.id, label: null };
if (nick == null) {
nick = user.globalName;
}
if (nick == null) {
nick = user.username;
}
obj2.label = nick;
return obj2;
}
} else if (tmp(8238).SnowflakeSelectDefaultValueTypes.ROLE === type) {
if (null == closure_1) {
return null;
} else {
const role = GuildRoleStore.getRole(tmp8.id, type.id);
let tmp12 = null;
if (null != role) {
const obj3 = { type: tmp(4868).SelectOptionType.ROLE, value: null, label: null };
({ id: obj4.value, name: obj4.label } = role);
tmp12 = obj3;
}
return tmp12;
}
} else if (tmp(8238).SnowflakeSelectDefaultValueTypes.CHANNEL === type) {
if (null == closure_1) {
return null;
} else {
const channel = ChannelStore.getChannel(type.id);
let tmp5 = null;
if (null != channel) {
tmp5 = null;
if (channel.guild_id === tmp3.id) {
if (channelTypes.length <= 0) {
const obj5 = { type: tmp(4868).SelectOptionType.CHANNEL, value: channel.id, label: tmp(4789).computeChannelName(channel, UserStore, RelationshipStore) };
tmp5 = obj5;
const tmpResult = tmp(4789);
} else {
tmp5 = null;
}
}
}
return tmp5;
}
}
});
return mapped.filter(items(1369).isNotNullish);
}
};