decord/source/modules/interaction_components/SearchableSelectActionComponentUtils.tsx

254 lines
9.4 KiB
TypeScript
Raw Normal View History

2026-08-03 11:20:01 +00:00
// Module ID: 8022
// Function ID: 8023
2026-07-29 08:29:29 +00:00
// Name: MIN_REREQUEST_TIME
2026-08-03 11:20:01 +00:00
// Dependencies: [1372, 1942, 1935, 1862, 3892, 1874, 8015, 1906, 5097, 4445, 4483, 4446, 8023, 1351, 2]
2026-07-29 08:29:29 +00:00
// Exports: getInitialSnowflakeSelectOptions, getSnowflakeSelectDefaultValues, queryChannels, queryMentionables
2026-07-20 16:05:17 +00:00
2026-08-03 11:20:01 +00:00
// Module 8022 (MIN_REREQUEST_TIME)
2026-07-29 08:29:29 +00:00
import ensureGuildLoaded from "ensureGuildLoaded";
import trackCommunicationDisabled from "trackCommunicationDisabled";
import createGuildRoleRecordFromRust from "createGuildRoleRecordFromRust";
import createGuildRecordFromRust from "createGuildRecordFromRust";
import upsertRelationship from "upsertRelationship";
import mergeGuildAvatar from "mergeGuildAvatar";
import getInteractionComponentStates from "getInteractionComponentStates";
2026-07-23 10:11:24 +00:00
const require = arg1;
2026-07-29 08:29:29 +00:00
const result = require("createGuildRoleRecordFromRust").fileFinishedImporting("modules/interaction_components/SearchableSelectActionComponentUtils.tsx");
2026-07-20 16:05:17 +00:00
export const MIN_REREQUEST_TIME = 1000;
2026-07-29 08:29:29 +00:00
export const queryMentionables = function queryMentionables(type, arg1, channelId) {
2026-07-20 16:05:17 +00:00
let roles;
let users;
2026-07-23 10:11:24 +00:00
const _require = channelId;
2026-07-20 16:05:17 +00:00
const channel = store.getChannel(channelId);
if (null == channel) {
return [];
} else {
2026-07-29 08:29:29 +00:00
const tmp2 = type === _require(1906).ComponentType.USER_SELECT || type === _require(1906).ComponentType.MENTIONABLE_SELECT;
2026-08-03 11:20:01 +00:00
let obj = channel(5097);
2026-07-29 08:29:29 +00:00
obj = { query: null, channel: null, canMentionEveryone: false, canMentionHere: false, canMentionUsers: null, canMentionRoles: null, includeAllGuildUsers: true, includeNonMentionableRoles: true, checkRecentlyTalkedOnEmptyQuery: false, limit: 15 };
obj[0] = arg1;
obj[1] = channel;
obj[4] = tmp2;
obj[5] = type === _require(1906).ComponentType.ROLE_SELECT || type === _require(1906).ComponentType.MENTIONABLE_SELECT;
const tmp3 = type === _require(1906).ComponentType.ROLE_SELECT || type === _require(1906).ComponentType.MENTIONABLE_SELECT;
2026-07-20 16:05:17 +00:00
({ users, roles } = obj.queryMentionResults(obj));
const items = [];
let arraySpreadResult = HermesBuiltin.arraySpread(users.map((user) => {
2026-07-23 10:11:24 +00:00
let obj = channel(outer1_2[9]);
let username = obj.getNickname(channel.getGuildId(), channelId, user.user);
2026-07-29 08:29:29 +00:00
obj = { type: channelId(outer1_2[10]).SelectOptionType.USER, value: user.user.id, label: null };
if (username == null) {
2026-07-20 16:05:17 +00:00
username = user.user.globalName;
}
2026-07-29 08:29:29 +00:00
if (username == null) {
2026-07-20 16:05:17 +00:00
username = user.user.username;
}
2026-07-29 08:29:29 +00:00
obj[2] = username;
2026-07-20 16:05:17 +00:00
return obj;
}), 0);
2026-07-29 08:29:29 +00:00
arraySpreadResult = HermesBuiltin.arraySpread(roles.map((id) => ({ type: channelId(table[10]).SelectOptionType.ROLE, value: id.id, label: id.name })), arraySpreadResult);
2026-07-20 16:05:17 +00:00
return items;
}
};
2026-07-29 08:29:29 +00:00
export const queryChannels = function queryChannels(arg0, arg1, arg2) {
const channel = store.getChannel(arg1);
2026-07-20 16:05:17 +00:00
if (null == channel) {
let items = [];
} else {
2026-08-03 11:20:01 +00:00
let obj = importDefault(5097);
2026-07-29 08:29:29 +00:00
obj = { query: null, channel: null, channelTypes: null, limit: 15 };
obj[0] = arg0;
obj[1] = channel;
obj[2] = arg2;
2026-07-20 16:05:17 +00:00
const channels = obj.queryApplicationCommandChannelResults(obj).channels;
items = channels.map((id) => {
2026-08-03 11:20:01 +00:00
const obj = { type: callback(4483).SelectOptionType.CHANNEL, value: id.id, label: null };
obj[2] = callback(4446).computeChannelName(id, mergeGuildAvatar, upsertRelationship);
2026-07-20 16:05:17 +00:00
return obj;
});
}
return items;
};
export const getInitialSnowflakeSelectOptions = function getInitialSnowflakeSelectOptions(selectActionComponent, containerId, guildId) {
2026-07-23 10:11:24 +00:00
interactionComponentState = interactionComponentState.getInteractionComponentState(containerId, selectActionComponent.id);
2026-07-29 08:29:29 +00:00
const defaultValues = selectActionComponent.defaultValues;
2026-07-20 16:05:17 +00:00
let channelTypes;
2026-07-29 08:29:29 +00:00
if (selectActionComponent.type === channelTypes(1906).ComponentType.CHANNEL_SELECT) {
2026-07-20 16:05:17 +00:00
channelTypes = selectActionComponent.channelTypes;
}
2026-07-29 08:29:29 +00:00
if (channelTypes === undefined) {
channelTypes = [];
}
let guild;
if (null != defaultValues) {
guild = store2.getGuild(guildId);
const mapped = defaultValues.map((type) => {
type = type.type;
if (channelTypes(outer1_2[12]).SnowflakeSelectDefaultValueTypes.USER === type) {
const user = outer1_8.getUser(type.id);
if (null == user) {
return null;
} else {
let nick;
if (null != closure_1) {
nick = outer1_4.getNick(tmp16.id, user.id);
}
let obj = { type: null, value: null, label: null };
obj[0] = tmp(tmp2[10]).SelectOptionType.USER;
obj[1] = user.id;
if (nick == null) {
nick = user.globalName;
}
if (nick == null) {
nick = user.username;
}
obj[2] = nick;
return obj;
}
} else if (tmp(tmp2[12]).SnowflakeSelectDefaultValueTypes.ROLE === type) {
if (null == closure_1) {
return null;
} else {
const role = outer1_5.getRole(tmp8.id, type.id);
let tmp12 = null;
if (null != role) {
obj = { type: null, value: null, label: null };
obj[0] = tmp(tmp2[10]).SelectOptionType.ROLE;
({ id: obj4[1], name: obj4[2] } = role);
tmp12 = obj;
}
return tmp12;
}
} else if (tmp(tmp2[12]).SnowflakeSelectDefaultValueTypes.CHANNEL === type) {
if (null == closure_1) {
return null;
} else {
const channel = outer1_3.getChannel(type.id);
let tmp5 = null;
if (null != channel) {
tmp5 = null;
if (channel.guild_id === tmp3.id) {
obj = channelTypes;
if (channelTypes.length <= 0) {
const obj1 = { type: null, value: null, label: null };
obj1[0] = tmp(tmp2[10]).SelectOptionType.CHANNEL;
obj1[1] = channel.id;
obj1[2] = tmp(tmp2[11]).computeChannelName(channel, outer1_8, outer1_7);
tmp5 = obj1;
const tmpResult = tmp(tmp2[11]);
} else {
tmp5 = null;
}
}
}
return tmp5;
}
}
});
let found = mapped.filter(tmp2(1351).isNotNullish);
}
let type;
if (interactionComponentState != null) {
2026-07-20 16:05:17 +00:00
type = interactionComponentState.type;
}
2026-07-29 08:29:29 +00:00
if (type !== channelTypes(1906).ComponentType.USER_SELECT) {
2026-07-20 16:05:17 +00:00
let type1;
2026-07-29 08:29:29 +00:00
if (interactionComponentState != null) {
2026-07-20 16:05:17 +00:00
type1 = interactionComponentState.type;
}
2026-07-29 08:29:29 +00:00
if (type1 !== tmp2(1906).ComponentType.ROLE_SELECT) {
2026-07-20 16:05:17 +00:00
let type2;
2026-07-29 08:29:29 +00:00
if (interactionComponentState != null) {
2026-07-20 16:05:17 +00:00
type2 = interactionComponentState.type;
}
2026-07-29 08:29:29 +00:00
if (type2 !== tmp2(1906).ComponentType.MENTIONABLE_SELECT) {
2026-07-20 16:05:17 +00:00
let type3;
2026-07-29 08:29:29 +00:00
if (interactionComponentState != null) {
2026-07-20 16:05:17 +00:00
type3 = interactionComponentState.type;
}
}
2026-07-29 08:29:29 +00:00
if (found == null) {
found = [];
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return found;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
found = interactionComponentState.selectedOptions;
};
export const getSnowflakeSelectDefaultValues = function getSnowflakeSelectDefaultValues(defaultValues, guild_id) {
let items = arg2;
if (arg2 === undefined) {
items = [];
}
let guild;
if (null != defaultValues) {
guild = store2.getGuild(guild_id);
const mapped = defaultValues.map((type) => {
type = type.type;
if (channelTypes(outer1_2[12]).SnowflakeSelectDefaultValueTypes.USER === type) {
const user = outer1_8.getUser(type.id);
if (null == user) {
return null;
} else {
let nick;
if (null != closure_1) {
nick = outer1_4.getNick(tmp16.id, user.id);
}
let obj = { type: null, value: null, label: null };
obj[0] = tmp(tmp2[10]).SelectOptionType.USER;
obj[1] = user.id;
if (nick == null) {
nick = user.globalName;
}
if (nick == null) {
nick = user.username;
}
obj[2] = nick;
return obj;
}
} else if (tmp(tmp2[12]).SnowflakeSelectDefaultValueTypes.ROLE === type) {
if (null == closure_1) {
return null;
} else {
const role = outer1_5.getRole(tmp8.id, type.id);
let tmp12 = null;
if (null != role) {
obj = { type: null, value: null, label: null };
obj[0] = tmp(tmp2[10]).SelectOptionType.ROLE;
({ id: obj4[1], name: obj4[2] } = role);
tmp12 = obj;
}
return tmp12;
}
} else if (tmp(tmp2[12]).SnowflakeSelectDefaultValueTypes.CHANNEL === type) {
if (null == closure_1) {
return null;
} else {
const channel = outer1_3.getChannel(type.id);
let tmp5 = null;
if (null != channel) {
tmp5 = null;
if (channel.guild_id === tmp3.id) {
obj = channelTypes;
if (channelTypes.length <= 0) {
const obj1 = { type: null, value: null, label: null };
obj1[0] = tmp(tmp2[10]).SelectOptionType.CHANNEL;
obj1[1] = channel.id;
obj1[2] = tmp(tmp2[11]).computeChannelName(channel, outer1_8, outer1_7);
tmp5 = obj1;
const tmpResult = tmp(tmp2[11]);
} else {
tmp5 = null;
}
}
}
return tmp5;
}
}
});
return mapped.filter(items(1351).isNotNullish);
}
2026-07-20 16:05:17 +00:00
};