Plugin

UserVoiceShow

Shows an indicator when a user is in a Voice Channel

Voice Appearance Friends
index.tsx
Download

Source

src/plugins/userVoiceShow/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 "./style.css";
8
9import { addMemberListDecorator, removeMemberListDecorator } from "@api/MemberListDecorators";
10import { addMessageDecoration, removeMessageDecoration } from "@api/MessageDecorations";
11import { definePluginSettings } from "@api/Settings";
12import { Devs } from "@utils/constants";
13import definePlugin, { OptionType } from "@utils/types";
14
15import { VoiceChannelIndicator } from "./components";
16
17const settings = definePluginSettings({
18 showInUserProfileModal: {
19 type: OptionType.BOOLEAN,
20 description: "Show a user's Voice Channel indicator in their profile next to the name",
21 default: true,
22 restartNeeded: true
23 },
24 showInMemberList: {
25 type: OptionType.BOOLEAN,
26 description: "Show a user's Voice Channel indicator in the member and DMs list",
27 default: true,
28 restartNeeded: true
29 },
30 showInMessages: {
31 type: OptionType.BOOLEAN,
32 description: "Show a user's Voice Channel indicator in messages",
33 default: true,
34 restartNeeded: true
35 }
36});
37
38export default definePlugin({
39 name: "UserVoiceShow",
40 description: "Shows an indicator when a user is in a Voice Channel",
41 tags: ["Voice", "Appearance", "Friends"],
42 authors: [Devs.Nuckyz, Devs.LordElias],
43 dependencies: ["MemberListDecoratorsAPI", "MessageDecorationsAPI"],
44 settings,
45
46 patches: [
47 // User Popout, User Profile Modal, Direct Messages Side Profile
48 {
49 find: "#{intl::USER_PROFILE_PRONOUNS}",
50 replacement: {
51 match: /(?<=children:\[\i," ",\i)(?=\])/,
52 replace: ",$self.VoiceChannelIndicator({userId:arguments[0]?.user?.id,isProfile:true})"
53 },
54 predicate: () => settings.store.showInUserProfileModal
55 },
56 // To use without the MemberList decorator API
57 /* // Guild Members List
58 {
59 find: ".lostPermission)",
60 replacement: {
61 match: /\.lostPermission\).+?(?=avatar:)/,
62 replace: "$&children:[$self.VoiceChannelIndicator({userId:arguments[0]?.user?.id})],"
63 },
64 predicate: () => settings.store.showVoiceChannelIndicator
65 },
66 // Direct Messages List
67 {
68 find: "PrivateChannel.renderAvatar",
69 replacement: {
70 match: /#{intl::CLOSE_DM}.+?}\)(?=])/,
71 replace: "$&,$self.VoiceChannelIndicator({userId:arguments[0]?.user?.id})"
72 },
73 predicate: () => settings.store.showVoiceChannelIndicator
74 }, */
75 // Friends List
76 {
77 find: "null!=this.peopleListItemRef.current",
78 replacement: {
79 match: /\.isProvisional.{0,50}?className:\i\.\i,children:\[(?<=isFocused:(\i).+?)/,
80 replace: "$&$self.VoiceChannelIndicator({userId:this?.props?.user?.id,isActionButton:true,shouldHighlight:$1}),"
81 },
82 predicate: () => settings.store.showInMemberList
83 }
84 ],
85
86 start() {
87 if (settings.store.showInMemberList) {
88 addMemberListDecorator("UserVoiceShow", ({ user }) => user == null ? null : <VoiceChannelIndicator userId={user.id} />);
89 }
90 if (settings.store.showInMessages) {
91 addMessageDecoration("UserVoiceShow", ({ message }) => message?.author == null ? null : <VoiceChannelIndicator userId={message.author.id} />);
92 }
93 },
94
95 stop() {
96 removeMemberListDecorator("UserVoiceShow");
97 removeMessageDecoration("UserVoiceShow");
98 },
99
100 VoiceChannelIndicator
101});
102