Plugin
UserVoiceShow
Shows an indicator when a user is in a Voice Channel
1
/*2
* FiveCord — a Discord client mod3
* Copyright (c) 2025 FiveCord4
* SPDX-License-Identifier: GPL-3.0-or-later5
*/6
7
import "./style.css";8
9
import { addMemberListDecorator, removeMemberListDecorator } from "@api/MemberListDecorators";10
import { addMessageDecoration, removeMessageDecoration } from "@api/MessageDecorations";11
import { definePluginSettings } from "@api/Settings";12
import { Devs } from "@utils/constants";13
import definePlugin, { OptionType } from "@utils/types";14
15
import { VoiceChannelIndicator } from "./components";16
17
const settings = definePluginSettings({18
showInUserProfileModal: {19
type: OptionType.BOOLEAN,20
description: "Show a user039;s Voice Channel indicator in their profile next to the name",21
default: true,22
restartNeeded: true23
},24
showInMemberList: {25
type: OptionType.BOOLEAN,26
description: "Show a user039;s Voice Channel indicator in the member and DMs list",27
default: true,28
restartNeeded: true29
},30
showInMessages: {31
type: OptionType.BOOLEAN,32
description: "Show a user039;s Voice Channel indicator in messages",33
default: true,34
restartNeeded: true35
}36
});37
38
export 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 Profile48
{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.showInUserProfileModal55
},56
// To use without the MemberList decorator API57
/* // Guild Members List58
{59
find: ".lostPermission)",60
replacement: {61
match: /\.lostPermission\).+?(?=avatar:)/,62
replace: "$&children:[$self.VoiceChannelIndicator({userId:arguments[0]?.user?.id})],"63
},64
predicate: () => settings.store.showVoiceChannelIndicator65
},66
// Direct Messages List67
{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.showVoiceChannelIndicator74
}, */75
// Friends List76
{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.showInMemberList83
}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
VoiceChannelIndicator101
});102