From a933b1a092590064cb2d8693f2141238b86ce56c Mon Sep 17 00:00:00 2001 From: nin0 Date: Mon, 21 Apr 2025 18:20:13 -0400 Subject: [PATCH] init --- index.tsx | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ style.css | 43 +++++++++++++++++++++ 2 files changed, 152 insertions(+) create mode 100644 index.tsx create mode 100644 style.css diff --git a/index.tsx b/index.tsx new file mode 100644 index 0000000..11ef42e --- /dev/null +++ b/index.tsx @@ -0,0 +1,109 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2025 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import "./style.css"; + +import { classNameFactory } from "@api/Styles"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { findComponentByCodeLazy } from "@webpack"; +import { ChannelStore, DateUtils, GuildStore, IconUtils, NavigationRouter, Popout, SnowflakeUtils, Text, UserStore, useStateFromStores } from "@webpack/common"; +import { Channel, Guild } from "discord-types/general"; + +const ServerProfileComponent = findComponentByCodeLazy("{guildProfile:v,fetchGuildProfile:O,fetchStatus:I}"); +const cl = classNameFactory("vc-serverprofileforward-"); + +const ArrowSvg = () => ; + +const checkForIconExistence = (guild: Guild) => { + if (!guild) return false; + if (!guild.icon) return false; + return true; +}; +const isDM = (channel: Channel) => channel.flags === 1; + +export default definePlugin({ + name: "MoreForwardMeta", + description: "Show 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 && } + > + {popoutProps =>
+ { + checkForIconExistence(guild) && {`Server + } + {guild ? guild.name : "View server"} + +
+ } +
+ } + { + channel &&
NavigationRouter.transitionTo(`/channels/${guild_id ?? "@me"}/${channel_id}/${message_id}`)} > + {(() => { + /* + - Text channel + - Voice channel + - Announcement channel + - Stage channel + - Directory channel + - Forum channel + - Media channel + */ + if ([0, 2, 5, 13, 14, 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)" + } + } + ] +}); diff --git a/style.css b/style.css new file mode 100644 index 0000000..c82fbbb --- /dev/null +++ b/style.css @@ -0,0 +1,43 @@ +.vc-serverprofileforward-footer { + margin-top: 3px; + + .vc-serverprofileforward-footer-text { + font-weight: 400; + font-size: 14px; + color: var(--text-low-contrast); + } + + .vc-serverprofileforward-guild-icon { + margin-top: 0; + margin-bottom: 0; + position: absolute; + border-radius: 4px; + width: 16px; + } + + .vc-serverprofileforward-footer-element { + &:hover { + .vc-serverprofileforward-footer-text { + color: var(--interactive-hover); + } + + svg path { + fill: var(--interactive-hover) !important; + } + + background-color: var(--background-modifier-hover); + cursor: pointer; + } + + &:first-of-type { + margin-left: 0; + } + + align-items: center; + align-self: flex-start; + display: inline-flex; + padding: 1px 0; + border-radius: 4px; + margin-left: 4px; + } +}