/*
* Vencord, a Discord client mod
* Copyright (c) 2025 nin0
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import "./style.css";
import { Devs } from "@utils/constants";
import definePlugin from "@utils/types";
import { ChannelStore, DateUtils, GuildStore, IconUtils, NavigationRouter, Popout, SelectedGuildStore, SnowflakeUtils, Text, UserStore, useStateFromStores } from "@webpack/common";
import { ArrowSvg, checkForIconExistence, cl, ServerProfileComponent } from "./utils";
export default definePlugin({
name: "BetterForwardMeta",
description: "Access server profile under forwarded messages (if available) and always show time",
authors: [Devs.nin0dev],
ForwardFooter(message: any) {
const { guild_id, channel_id, message_id } = message.message.messageReference;
const guild = useStateFromStores([GuildStore], () => GuildStore.getGuild(guild_id));
const channel = useStateFromStores([ChannelStore], () => ChannelStore.getChannel(channel_id));
return
{
guild_id && <>
{
guild_id !== SelectedGuildStore.getGuildId() &&
}
>
{popoutProps =>
{
checkForIconExistence(guild) &&

}
{guild ? guild.name : "View server"}
}
}
>
}
{
channel &&
NavigationRouter.transitionTo(`/channels/${guild_id ?? "@me"}/${channel_id}/${message_id}`)} >
{(() => {
/*
- Text channel
- Voice channel
- Announcement channel
- Stage channel
- Forum channel
- Media channel
*/
if ([0, 2, 5, 13, 15, 16].includes(channel.type)) return `#${channel.name}`;
// DMs
if (channel.type === 1) return `@${(() => {
const user = UserStore.getUser(channel.recipients[0]);
// @ts-expect-error
return user.globalName || user.username;
})()}`;
// GDMs
if (channel.type === 3) return channel.name || (() => {
const users = channel.recipients.map(r => UserStore.getUser(r));
// @ts-expect-error
return users.map(u => u.globalName || u.username).join(", ");
})();
// Threads
if ([10, 11, 12].includes(channel.type)) return channel.name;
})()}
}
{DateUtils.calendarFormat(new Date(SnowflakeUtils.extractTimestamp(message_id)))}
;
},
patches: [
{
find: "originLabel,\" • \"",
replacement: {
match: /(let{message:\i,snapshot:\i,index:\i}=(\i))(.{0,400})return .+TEXT_LOW_CONTRAST}\)]}\)/,
replace: "$1$3return $self.ForwardFooter($2)"
}
}
]
});