decord/source/modules/messages/useMessageAuthor.tsx

299 lines
9.5 KiB
TypeScript
Raw Normal View History

// Module ID: 4807
// Function ID: 4808
// Name: useMessageAuthor
// Dependencies: [1957, 2021, 2015, 1979, 4222, 1371, 38, 504, 4418, 4808, 2]
2026-07-20 16:05:17 +00:00
// Exports: default, getMessageAuthor, useUserNickAndColor
// Module 4807 (useMessageAuthor)
2026-08-24 06:08:38 +00:00
import _modDef38 from "module_38" /* 38 */;
import UserUtilsDefault from "UserUtils" /* 4418 */;
import ChannelStore from "ChannelStore" /* 1957 */;
import GuildMemberStore from "GuildMemberStore" /* 2021 */;
import GuildRoleStore from "GuildRoleStore" /* 2015 */;
import GuildStore from "GuildStore" /* 1979 */;
import RelationshipStore from "RelationshipStore" /* 4222 */;
import UserStore from "UserStore" /* 1371 */;
2026-07-23 10:11:24 +00:00
const require = fn;
2026-07-20 16:05:17 +00:00
function useNullableMessageAuthor(message) {
_require = message;
2026-07-23 10:11:24 +00:00
const items = [guild_id];
const stateFromStores = require("initialize").useStateFromStores(items, () => {
2026-07-20 16:05:17 +00:00
let channel = null;
2026-07-29 08:29:29 +00:00
if (null != closure_0) {
channel = ChannelStore.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) {
const 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;
}
let obj = require("initialize");
2026-07-23 10:11:24 +00:00
const items1 = [colorRoleId];
const stateFromStores1 = require("initialize").useStateFromStores(items1, () => {
2026-07-20 16:05:17 +00:00
let member = null;
if (null != guild_id) {
member = null;
if (null != id) {
member = GuildMemberStore.getMember(tmp, tmp3);
2026-07-20 16:05:17 +00:00
}
}
return member;
});
const tmpResult = require("initialize");
const items2 = [UserStore];
2026-07-20 16:05:17 +00:00
const items3 = [id];
let stateFromStores2 = require("initialize").useStateFromStores(items2, () => UserStore.getUser(id), items3);
const tmpResult5 = require("initialize");
2026-07-29 08:29:29 +00:00
let bot;
if (message != null) {
bot = message.author.bot;
}
if (bot) {
let author1;
2026-07-29 08:29:29 +00:00
if (message != null) {
author1 = message.author;
2026-07-20 16:05:17 +00:00
}
stateFromStores2 = author1;
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]);
const items4 = [GuildStore];
2026-07-20 16:05:17 +00:00
const items5 = [guild_id];
2026-07-23 10:11:24 +00:00
colorRoleId = undefined;
const stateFromStores3 = require("initialize").useStateFromStores(items4, () => GuildStore.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;
}
const tmpResult6 = require("initialize");
const items6 = [GuildRoleStore];
2026-07-20 16:05:17 +00:00
const items7 = [guild_id, colorRoleId];
const stateFromStores4 = require("initialize").useStateFromStores(items6, () => {
2026-07-20 16:05:17 +00:00
let role;
if (null != guild_id) {
if (null != colorRoleId) {
role = GuildRoleStore.getRole(tmp, tmp3);
2026-07-20 16:05:17 +00:00
}
}
return role;
}, items7);
const tmpResult7 = require("initialize");
const items8 = [RelationshipStore];
const stateFromStores5 = require("initialize").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) {
nickname = RelationshipStore.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) {
const obj2 = { user: message.author, channel: stateFromStores, guild: stateFromStores3, memberColorRole: stateFromStores4, userName: name, member: stateFromStores1, friendNickname: stateFromStores5, displayNameStyles: tmp15 };
tmp16 = computeMessageAuthor(obj2);
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) {
_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;
}
const items = [GuildMemberStore];
const stateFromStores = require("initialize").useStateFromStores(items, () => {
2026-07-20 16:05:17 +00:00
let member = null;
if (null != guild_id) {
member = null;
if (null != id) {
member = GuildMemberStore.getMember(tmp, tmp3);
2026-07-20 16:05:17 +00:00
}
}
return member;
});
let obj = require("initialize");
const items1 = [GuildStore];
2026-07-20 16:05:17 +00:00
const items2 = [guild_id];
let colorRoleId;
const stateFromStores1 = require("initialize").useStateFromStores(items1, () => GuildStore.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;
}
const obj2 = require("initialize");
const items3 = [GuildRoleStore];
2026-07-20 16:05:17 +00:00
const items4 = [guild_id, colorRoleId];
const stateFromStores2 = require("initialize").useStateFromStores(items3, () => {
2026-07-20 16:05:17 +00:00
let role;
if (null != guild_id) {
if (null != colorRoleId) {
role = GuildRoleStore.getRole(tmp, tmp3);
2026-07-20 16:05:17 +00:00
}
}
return role;
}, items4);
const tmp3Result = require("initialize");
const items5 = [RelationshipStore];
const stateFromStores3 = require("initialize").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) {
nickname = RelationshipStore.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;
});
const tmp3Result2 = require("initialize");
const name = id(guild_id[8]).useName(author);
const obj5 = id(guild_id[8]);
return computeMessageAuthor({ user: author, channel, guild: stateFromStores1, memberColorRole: stateFromStores2, member: stateFromStores, userName: name, friendNickname: stateFromStores3, displayNameStyles: id(guild_id[9])({ userId: id, guildId: guild_id }) });
2026-07-20 16:05:17 +00:00
}
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;
const guild = GuildStore.getGuild(guild_id);
2026-07-20 16:05:17 +00:00
if (null != guild_id) {
member = null;
if (null != id) {
member = GuildMemberStore.getMember(guild_id, id);
2026-07-20 16:05:17 +00:00
}
}
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 = GuildRoleStore.getRole(guild_id, member.colorRoleId);
2026-07-20 16:05:17 +00:00
}
}
let nickname = null;
if (null != id) {
nickname = null;
if (null != channel) {
nickname = null;
if (channel.isPrivate()) {
nickname = RelationshipStore.getNickname(id);
2026-07-20 16:05:17 +00:00
}
}
}
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;
}
obj.displayNameStyles = 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) {
userName = UserUtilsDefault.getName(user);
2026-07-20 16:05:17 +00:00
}
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
}
const obj3 = { nick: friendNickname, colorString: null, colorStrings: null, displayNameStyles };
let obj7 = obj3;
2026-07-20 16:05:17 +00:00
} else if (null == member) {
const obj4 = { nick: str, colorString: null, colorStrings: null, displayNameStyles };
obj7 = obj4;
2026-07-20 16:05:17 +00:00
} 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
}
obj7 = { nick, colorString: null, colorStrings: null, colorRoleName: null, colorRoleId: null, iconRoleId: null, guildMemberAvatar: null, guildMemberAvatarDecoration: null, primaryGuild: null, guildId: null, authorId: null, displayNameStyles: null };
({ colorString: obj2.colorString, colorStrings: obj2.colorStrings } = 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;
}
obj7.colorRoleName = 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;
}
obj7.colorRoleId = id2;
({ iconRoleId: obj2.iconRoleId, avatar: obj2.guildMemberAvatar, avatarDecoration: obj2.guildMemberAvatarDecoration } = member);
2026-07-20 16:05:17 +00:00
const primaryGuild = user.primaryGuild;
obj7.primaryGuild = primaryGuild;
obj7.guildId = guild.id;
obj7.authorId = user.id;
obj7.displayNameStyles = displayNameStyles;
2026-07-20 16:05:17 +00:00
}
}
return obj7;
2026-07-20 16:05:17 +00:00
}
obj7 = { nick: str, colorString: null, colorStrings: null, displayNameStyles };
2026-07-20 16:05:17 +00:00
}
const size = fn(2);
const result = size.fileFinishedImporting("modules/messages/useMessageAuthor.tsx");
2026-07-20 16:05:17 +00:00
export default function useMessageNickAndColor(message, arg1) {
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, ChannelStore.getChannel(message.channel_id));
2026-07-20 16:05:17 +00:00
};
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 };