Plugin

DeadMembers

Shows when the sender of a message has left the guild

index.tsx
Download

Source

src/plugins/deadMembers/index.tsx
1/*
2 * FiveCord — a Discord client mod
3 * Copyright (c) 2025 FiveCord
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 */
6
7import { Devs } from "@utils/constants";
8import definePlugin from "@utils/types";
9import { ChannelStore, GuildMemberStore, useStateFromStores } from "@webpack/common";
10
11export default definePlugin({
12 name: "DeadMembers",
13 description: "Shows when the sender of a message has left the guild",
14 authors: [Devs.FiveCord],
15
16 patches: [
17 {
18 find: "UsernameDecorationTypes:function()",
19 replacement: {
20 match: /(\i)=\{className:\i.username,style:.*?onContextMenu:\i,children:.*?\}/,
21 replace: "$&,{}=$1.children=$self.wrapMessageAuthor(arguments[0],$1.children)"
22 }
23 },
24 {
25 find: "Messages.FORUM_POST_AUTHOR_A11Y_LABEL",
26 replacement: {
27 match: /(?<=\}=(\i),\{(user:\i,author:\i)\}=.{0,400}?\(\i\.Fragment,{children:)\i(?=}\),)/,
28 replace: "$self.wrapForumAuthor({...$1,$2},$&)"
29 }
30 },
31 ],
32
33 wrapMessageAuthor({ message }, text) {
34 const channel = ChannelStore.getChannel(message.channel_id);
35 return message.webhookId
36 ? text
37 : <DeadIndicator
38 channel={channel}
39 userId={message.author.id}
40 text={text}
41 />;
42 },
43
44 wrapForumAuthor({ channel, user }, text) {
45 return !user
46 ? text
47 : <DeadIndicator
48 channel={channel}
49 userId={user.id}
50 text={text}
51 />;
52 },
53});
54
55
56function DeadIndicator({ channel, userId, text }) {
57 const isMember = useStateFromStores(
58 [GuildMemberStore],
59 () => GuildMemberStore.isMember(channel?.guild_id, userId),
60 );
61 return channel?.guild_id && !isMember ? <s className="c98-author-dead">{text}</s> : text;
62}
63