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