decord/source/modules/messages/useMessageAuthor.tsx

316 lines
9.5 KiB
TypeScript
Raw Normal View History

2026-08-25 06:04:03 +00:00
// Module ID: 4634
// Function ID: 4635
2026-07-20 16:05:17 +00:00
// Name: useNullableMessageAuthor
2026-08-25 06:04:03 +00:00
// Dependencies: [1391, 1992, 1985, 1910, 4034, 1922, 38, 589, 4224, 4635, 2]
2026-07-20 16:05:17 +00:00
// Exports: default, getMessageAuthor, useUserNickAndColor
2026-08-25 06:04:03 +00:00
// Module 4634 (useNullableMessageAuthor)
2026-08-24 06:08:38 +00:00
import _modDef38 from "module_38" /* 38 */;
2026-08-25 06:04:03 +00:00
import nameFromUserDefault from "nameFromUser" /* 4224 */;
2026-08-24 06:08:38 +00:00
import closure_3 from "ensureGuildLoaded" /* 1391 */;
2026-08-25 06:04:03 +00:00
import closure_4 from "trackCommunicationDisabled" /* 1992 */;
import closure_5 from "createGuildRoleRecordFromRust" /* 1985 */;
2026-08-24 06:08:38 +00:00
import closure_6 from "createGuildRecordFromRust" /* 1910 */;
2026-08-25 06:04:03 +00:00
import closure_7 from "markAllUserIdListsStale" /* 4034 */;
2026-08-24 06:08:38 +00:00
import closure_8 from "mergeGuildAvatar" /* 1922 */;
2026-07-23 10:11:24 +00:00
const require = arg1;
2026-07-20 16:05:17 +00:00
function useNullableMessageAuthor(message) {
2026-07-23 10:11:24 +00:00
const _require = message;
let obj = _require(id[7]);
const items = [guild_id];
2026-07-20 16:05:17 +00:00
const stateFromStores = obj.useStateFromStores(items, () => {
let channel = null;
2026-07-29 08:29:29 +00:00
if (null != closure_0) {
channel = guild_id.getChannel(tmp.channel_id);
2026-07-20 16:05:17 +00:00
}
return channel;
});
2026-07-23 10:11:24 +00:00
id = undefined;
2026-07-29 08:29:29 +00:00
if (message != null) {
2026-07-20 16:05:17 +00:00
let author = message.author;
2026-07-29 08:29:29 +00:00
if (author != null) {
2026-07-20 16:05:17 +00:00
id = author.id;
}
}
2026-07-23 10:11:24 +00:00
guild_id = undefined;
2026-07-29 08:29:29 +00:00
if (stateFromStores != null) {
2026-07-20 16:05:17 +00:00
guild_id = stateFromStores.guild_id;
}
2026-07-29 08:29:29 +00:00
let tmpResult = tmp(tmp2[7]);
2026-07-23 10:11:24 +00:00
const items1 = [colorRoleId];
2026-07-29 08:29:29 +00:00
const stateFromStores1 = tmpResult.useStateFromStores(items1, () => {
2026-07-20 16:05:17 +00:00
let member = null;
if (null != guild_id) {
member = null;
if (null != id) {
2026-07-29 08:29:29 +00:00
member = colorRoleId.getMember(tmp, tmp3);
2026-07-20 16:05:17 +00:00
}
}
return member;
});
2026-07-29 08:29:29 +00:00
tmpResult = tmp(tmp2[7]);
2026-08-24 06:08:38 +00:00
const items2 = [closure_8];
2026-07-20 16:05:17 +00:00
const items3 = [id];
2026-08-24 06:08:38 +00:00
let stateFromStores2 = tmpResult.useStateFromStores(items2, () => closure_1_8.getUser(id), items3);
2026-07-29 08:29:29 +00:00
let bot;
if (message != null) {
bot = message.author.bot;
}
if (bot) {
author = undefined;
if (message != null) {
author = message.author;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
stateFromStores2 = author;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
const name = stateFromStores(id[8]).useName(stateFromStores2);
2026-07-23 10:11:24 +00:00
const obj4 = stateFromStores(id[8]);
2026-08-24 06:08:38 +00:00
const items4 = [closure_6];
2026-07-20 16:05:17 +00:00
const items5 = [guild_id];
2026-07-23 10:11:24 +00:00
colorRoleId = undefined;
2026-08-24 06:08:38 +00:00
const stateFromStores3 = _require(id[7]).useStateFromStores(items4, () => closure_1_6.getGuild(guild_id), items5);
2026-07-29 08:29:29 +00:00
if (stateFromStores1 != null) {
2026-07-20 16:05:17 +00:00
colorRoleId = stateFromStores1.colorRoleId;
}
2026-07-29 08:29:29 +00:00
const tmpResult1 = _require(id[7]);
2026-08-24 06:08:38 +00:00
const items6 = [closure_5];
2026-07-20 16:05:17 +00:00
const items7 = [guild_id, colorRoleId];
2026-07-23 10:11:24 +00:00
const stateFromStores4 = _require(id[7]).useStateFromStores(items6, () => {
2026-07-20 16:05:17 +00:00
let role;
if (null != guild_id) {
if (null != colorRoleId) {
2026-08-24 06:08:38 +00:00
role = closure_1_5.getRole(tmp, tmp3);
2026-07-20 16:05:17 +00:00
}
}
return role;
}, items7);
2026-07-29 08:29:29 +00:00
const tmpResult2 = _require(id[7]);
2026-08-24 06:08:38 +00:00
const items8 = [closure_7];
2026-07-23 10:11:24 +00:00
const stateFromStores5 = _require(id[7]).useStateFromStores(items8, () => {
2026-07-20 16:05:17 +00:00
let nickname = null;
if (null != id) {
2026-07-29 08:29:29 +00:00
let isPrivateResult;
if (stateFromStores != null) {
isPrivateResult = obj.isPrivate();
}
2026-07-20 16:05:17 +00:00
nickname = null;
2026-07-29 08:29:29 +00:00
if (isPrivateResult) {
2026-08-24 06:08:38 +00:00
nickname = closure_1_7.getNickname(tmp);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj = stateFromStores;
2026-07-20 16:05:17 +00:00
}
return nickname;
});
2026-07-29 08:29:29 +00:00
let tmp16 = null;
2026-07-20 16:05:17 +00:00
if (null != message) {
2026-07-29 08:29:29 +00:00
obj = { user: null, channel: null, guild: null, memberColorRole: null, userName: null, member: null, friendNickname: null, displayNameStyles: null };
obj[0] = message.author;
obj[1] = stateFromStores;
obj[2] = stateFromStores3;
obj[3] = stateFromStores4;
obj[4] = name;
obj[5] = stateFromStores1;
obj[6] = stateFromStores5;
obj[7] = tmp15;
tmp16 = computeMessageAuthor(obj);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return tmp16;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
function useNullableUserAuthor(author, channel) {
2026-07-23 10:11:24 +00:00
const _require = channel;
2026-07-20 16:05:17 +00:00
let id;
2026-07-29 08:29:29 +00:00
if (author != null) {
id = author.id;
2026-07-20 16:05:17 +00:00
}
let guild_id;
2026-07-29 08:29:29 +00:00
if (channel != null) {
2026-07-20 16:05:17 +00:00
guild_id = channel.guild_id;
}
2026-07-23 10:11:24 +00:00
let obj = _require(guild_id[7]);
2026-08-24 06:08:38 +00:00
const items = [closure_4];
2026-07-20 16:05:17 +00:00
const stateFromStores = obj.useStateFromStores(items, () => {
let member = null;
if (null != guild_id) {
member = null;
if (null != id) {
2026-08-24 06:08:38 +00:00
member = closure_1_4.getMember(tmp, tmp3);
2026-07-20 16:05:17 +00:00
}
}
return member;
});
2026-08-24 06:08:38 +00:00
const items1 = [closure_6];
2026-07-20 16:05:17 +00:00
const items2 = [guild_id];
let colorRoleId;
2026-08-24 06:08:38 +00:00
const stateFromStores1 = _require(guild_id[7]).useStateFromStores(items1, () => closure_1_6.getGuild(guild_id), items2);
2026-07-29 08:29:29 +00:00
if (stateFromStores != null) {
2026-07-20 16:05:17 +00:00
colorRoleId = stateFromStores.colorRoleId;
}
2026-07-29 08:29:29 +00:00
let tmp3Result = tmp3(tmp4[7]);
2026-08-24 06:08:38 +00:00
const items3 = [closure_5];
2026-07-20 16:05:17 +00:00
const items4 = [guild_id, colorRoleId];
2026-07-29 08:29:29 +00:00
const stateFromStores2 = tmp3Result.useStateFromStores(items3, () => {
2026-07-20 16:05:17 +00:00
let role;
if (null != guild_id) {
if (null != colorRoleId) {
2026-08-24 06:08:38 +00:00
role = closure_1_5.getRole(tmp, tmp3);
2026-07-20 16:05:17 +00:00
}
}
return role;
}, items4);
2026-07-29 08:29:29 +00:00
tmp3Result = tmp3(tmp4[7]);
2026-08-24 06:08:38 +00:00
const items5 = [closure_7];
2026-07-29 08:29:29 +00:00
const stateFromStores3 = tmp3Result.useStateFromStores(items5, () => {
2026-07-20 16:05:17 +00:00
let nickname = null;
if (null != id) {
2026-07-29 08:29:29 +00:00
let isPrivateResult;
if (closure_0 != null) {
isPrivateResult = obj.isPrivate();
}
2026-07-20 16:05:17 +00:00
nickname = null;
2026-07-29 08:29:29 +00:00
if (isPrivateResult) {
2026-08-24 06:08:38 +00:00
nickname = closure_1_7.getNickname(tmp);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj = closure_0;
2026-07-20 16:05:17 +00:00
}
return nickname;
});
2026-07-29 08:29:29 +00:00
const obj2 = _require(guild_id[7]);
obj = { user: author, channel, guild: stateFromStores1, memberColorRole: stateFromStores2, member: stateFromStores, userName: id(guild_id[8]).useName(author), friendNickname: stateFromStores3, displayNameStyles: null };
2026-07-20 16:05:17 +00:00
let displayNameStyles;
2026-07-29 08:29:29 +00:00
if (author != null) {
displayNameStyles = author.displayNameStyles;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj[7] = displayNameStyles;
2026-07-20 16:05:17 +00:00
return computeMessageAuthor(obj);
}
function getUserAuthor(user, channel) {
let id;
2026-07-29 08:29:29 +00:00
if (user != null) {
2026-07-20 16:05:17 +00:00
id = user.id;
}
let guild_id;
2026-07-29 08:29:29 +00:00
if (channel != null) {
2026-07-20 16:05:17 +00:00
guild_id = channel.guild_id;
}
let member = null;
2026-07-23 10:11:24 +00:00
guild = guild.getGuild(guild_id);
2026-07-20 16:05:17 +00:00
if (null != guild_id) {
member = null;
if (null != id) {
member = member.getMember(guild_id, id);
}
}
let role;
if (null != guild_id) {
let colorRoleId;
2026-07-29 08:29:29 +00:00
if (member != null) {
2026-07-20 16:05:17 +00:00
colorRoleId = member.colorRoleId;
}
if (null != colorRoleId) {
role = role.getRole(guild_id, member.colorRoleId);
}
}
let nickname = null;
if (null != id) {
nickname = null;
if (null != channel) {
nickname = null;
if (channel.isPrivate()) {
nickname = nickname.getNickname(id);
}
}
}
2026-07-29 08:29:29 +00:00
const obj = { user, channel, guild, memberColorRole: role, member, friendNickname: nickname, displayNameStyles: null };
2026-07-20 16:05:17 +00:00
let displayNameStyles;
2026-07-29 08:29:29 +00:00
if (user != null) {
2026-07-20 16:05:17 +00:00
displayNameStyles = user.displayNameStyles;
}
2026-07-29 08:29:29 +00:00
obj[6] = displayNameStyles;
2026-07-20 16:05:17 +00:00
return computeMessageAuthor(obj);
}
function computeMessageAuthor(channel) {
({ user, guild, memberColorRole, member, userName, friendNickname, displayNameStyles } = channel);
let str = "???";
if (null != user) {
2026-07-29 08:29:29 +00:00
if (userName == null) {
2026-08-24 06:08:38 +00:00
let obj = nameFromUserDefault;
2026-07-20 16:05:17 +00:00
userName = obj.getName(user);
}
str = userName;
}
let id;
2026-07-29 08:29:29 +00:00
if (user != null) {
2026-07-20 16:05:17 +00:00
id = user.id;
}
if (null != id) {
if (null != channel.channel) {
let id1;
2026-07-29 08:29:29 +00:00
if (guild != null) {
2026-07-20 16:05:17 +00:00
id1 = guild.id;
}
if (null == id1) {
2026-07-29 08:29:29 +00:00
if (friendNickname == null) {
friendNickname = str;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj = { nick: null, colorString: null, colorStrings: null, displayNameStyles: null };
obj[0] = friendNickname;
obj[3] = displayNameStyles;
2026-08-24 06:08:38 +00:00
obj1 = obj;
2026-07-20 16:05:17 +00:00
} else if (null == member) {
2026-07-29 08:29:29 +00:00
obj = { nick: null, colorString: null, colorStrings: null, displayNameStyles: null };
obj[0] = str;
obj[3] = displayNameStyles;
2026-07-20 16:05:17 +00:00
obj1 = obj;
} else {
2026-07-29 08:29:29 +00:00
let nick = member.nick;
if (nick == null) {
nick = str;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj1 = { nick: null, colorString: null, colorStrings: null, colorRoleName: null, colorRoleId: null, iconRoleId: null, guildMemberAvatar: null, guildMemberAvatarDecoration: null, primaryGuild: null, guildId: null, authorId: null, displayNameStyles: null };
obj1[0] = nick;
({ colorString: obj2[1], colorStrings: obj2[2] } = member);
2026-07-20 16:05:17 +00:00
let name;
2026-07-29 08:29:29 +00:00
if (memberColorRole != null) {
2026-07-20 16:05:17 +00:00
name = memberColorRole.name;
}
2026-07-29 08:29:29 +00:00
obj1[3] = name;
2026-07-20 16:05:17 +00:00
let id2;
2026-07-29 08:29:29 +00:00
if (memberColorRole != null) {
2026-07-20 16:05:17 +00:00
id2 = memberColorRole.id;
}
2026-07-29 08:29:29 +00:00
obj1[4] = id2;
({ iconRoleId: obj2[5], avatar: obj2[6], avatarDecoration: obj2[7] } = member);
2026-07-20 16:05:17 +00:00
const primaryGuild = user.primaryGuild;
2026-07-29 08:29:29 +00:00
obj1[8] = primaryGuild;
obj1[9] = guild.id;
obj1[10] = user.id;
obj1[11] = displayNameStyles;
2026-07-20 16:05:17 +00:00
}
}
return obj1;
}
2026-07-29 08:29:29 +00:00
obj1 = { nick: str, colorString: null, colorStrings: null, displayNameStyles };
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
const result = require("set").fileFinishedImporting("modules/messages/useMessageAuthor.tsx");
2026-07-20 16:05:17 +00:00
export default function useMessageNickAndColor(message) {
2026-07-29 08:29:29 +00:00
let tmp = arg1;
const tmp2 = useNullableMessageAuthor(message);
2026-08-24 06:08:38 +00:00
_modDef38(null != tmp2, "Result cannot be null because the message is not null");
2026-07-29 08:29:29 +00:00
if (arg1 == null) {
tmp = tmp2;
2026-07-20 16:05:17 +00:00
}
return tmp;
};
export { useNullableMessageAuthor };
export const getMessageAuthor = function getMessageAuthor(message) {
return getUserAuthor(message.author, channel.getChannel(message.channel_id));
};
2026-07-29 08:29:29 +00:00
export const useUserNickAndColor = function useUserNickAndColor(author, channel) {
2026-08-24 06:08:38 +00:00
_modDef38(true, "Result cannot be null because user and channel are not null");
2026-07-29 08:29:29 +00:00
return useNullableUserAuthor(author, channel);
2026-07-20 16:05:17 +00:00
};
export { useNullableUserAuthor };
export { getUserAuthor };