Plugin
UserVoiceShow
Shows an indicator when a user is in a Voice Channel
1
import "./style.css";2
3
import { addMemberListDecorator, removeMemberListDecorator } from "@api/MemberListDecorators";4
import { addMessageDecoration, removeMessageDecoration } from "@api/MessageDecorations";5
import { definePluginSettings } from "@api/Settings";6
import { Devs } from "@utils/constants";7
import definePlugin, { OptionType } from "@utils/types";8
9
import { VoiceChannelIndicator } from "./components";10
11
const settings = definePluginSettings({12
showInUserProfileModal: {13
type: OptionType.BOOLEAN,14
description: "Show a user039;s Voice Channel indicator in their profile next to the name",15
default: true,16
restartNeeded: true17
},18
showInMemberList: {19
type: OptionType.BOOLEAN,20
description: "Show a user039;s Voice Channel indicator in the member and DMs list",21
default: true,22
restartNeeded: true23
},24
showInMessages: {25
type: OptionType.BOOLEAN,26
description: "Show a user039;s Voice Channel indicator in messages",27
default: true,28
restartNeeded: true29
}30
});31
32
export 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 Profile42
{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.showInUserProfileModal49
},50
// To use without the MemberList decorator API51
/* // Guild Members List52
{53
find: ".lostPermission)",54
replacement: {55
match: /\.lostPermission\).+?(?=avatar:)/,56
replace: "$&children:[$self.VoiceChannelIndicator({userId:arguments[0]?.user?.id})],"57
},58
predicate: () => settings.store.showVoiceChannelIndicator59
},60
// Direct Messages List61
{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.showVoiceChannelIndicator68
}, */69
// Friends List70
{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.showInMemberList77
}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
VoiceChannelIndicator95
});96