Compare commits

...

12 commits

Author SHA1 Message Date
v
97765d7d85
Merge 0a51a865d3 into f12335a371 2024-09-16 14:52:24 -04:00
Nuckyz
f12335a371
UserVoiceShow: Fix for simplified profiles
Some checks are pending
Sync to Codeberg / codeberg (push) Waiting to run
test / test (push) Waiting to run
2024-09-16 15:16:41 -03:00
Nuckyz
640d99dcda
delete NoDefaultHangStatus ~ Removed feature
Some checks are pending
Sync to Codeberg / codeberg (push) Waiting to run
test / test (push) Waiting to run
2024-09-16 07:51:10 -03:00
vee
0a51a865d3
Merge branch 'dev' into edit-users 2024-07-06 19:05:58 +02:00
Vendicated
560fb982e6
BetterNotes: fix crashing 2024-07-03 21:38:21 +02:00
Vendicated
f4572d0377
fix overriding avatars in guilds 2024-07-03 18:07:11 +02:00
Vendicated
3a7499644e
add pronouns, add nicks (kinda) 2024-07-03 17:24:29 +02:00
vee
1a2033e137
Merge branch 'dev' into edit-users 2024-07-03 16:49:17 +02:00
Vendicated
1bdde745e2
Merge branch 'dev' into edit-users 2024-07-02 22:10:35 +02:00
Vendicated
b333deb731
improve settings ui (again) 2024-07-02 18:51:51 +02:00
Vendicated
e0bb9bf77d
add ui and stuffs 2024-07-02 17:39:48 +02:00
Vendicated
c73c3fa636
sajidfjiasdjiodjioasjiod 2024-07-02 00:17:40 +02:00
12 changed files with 625 additions and 177 deletions

View file

@ -0,0 +1,42 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2024 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { definePluginSettings } from "@api/Settings";
export const enum OverrideFlags {
None = 0,
PreferServerNicks = 1 << 0,
DisableNicks = 1 << 1,
KeepServerAvatar = 1 << 2,
DisableServerAvatars = 1 << 3,
KeepServerBanner = 1 << 4,
DisableServerBanners = 1 << 5,
}
export interface UserOverride {
username: string;
avatarUrl: string;
bannerUrl: string;
pronouns: string;
flags: OverrideFlags;
}
export const emptyOverride: UserOverride = Object.freeze({
username: "",
avatarUrl: "",
bannerUrl: "",
pronouns: "",
flags: OverrideFlags.None,
});
export const settings = definePluginSettings({})
.withPrivateSettings<{
users?: Record<string, UserOverride>;
}>();
export const getUserOverride = (userId: string) => settings.store.users?.[userId] ?? emptyOverride;
export const hasFlag = (field: OverrideFlags, flag: OverrideFlags) => (field & flag) === flag;

View file

@ -0,0 +1,125 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2024 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import "./styles.css";
import { Devs } from "@utils/constants";
import definePlugin from "@utils/types";
import { Menu } from "@webpack/common";
import { User } from "discord-types/general";
import { getUserOverride, hasFlag, OverrideFlags, settings } from "./data";
import { openUserEditModal } from "./modal";
export default definePlugin({
name: "EditUsers",
description: "Edit users",
authors: [Devs.Ven],
settings,
contextMenus: {
"user-context"(children, { user }: { user?: User; }) {
if (!user) return;
children.push(
<Menu.MenuItem
id="vc-edit-user"
label="Edit User"
action={() => openUserEditModal(user)}
/>
);
}
},
patches: [
{
find: ",getUserTag:",
replacement: {
match: /if\(\i\((\i)\.global_name\)\)return(?=.{0,100}return"\?\?\?")/,
replace: "const vcEuName=$self.getUsername($1);if(vcEuName)return vcEuName;$&"
}
},
{
find: "=this.guildMemberAvatars[",
replacement: [
{
match: /&&null!=this\.guildMemberAvatars\[\i\]/,
replace: "$& && !$self.shouldIgnoreGuildAvatar(this)"
},
{
match: /(?<=null!=(\i))\?(\i\.\i\.getGuildMemberAvatarURLSimple.+?):(?=\i\.\i\.getUserAvatarURL\(this)/,
replace: "&& this.hasAvatarForGuild?.($1) ? $2 : $self.getAvatarUrl(this)||"
}
]
},
{
find: "this.isUsingGuildMemberBanner()",
replacement: [
{
match: /:\i\.banner\)!=null/,
replace: "$& && !$self.shouldIgnoreGuildBanner(this.userId)"
},
{
match: /(?<=:).{0,10}\(\{id:this\.userId,banner/,
replace: "$self.getBannerUrl(this.userId)||$&"
},
{
match: /isUsingGuildMemberPronouns\(\)\{/,
replace:
"set pronouns(v){this._vcPronouns=v}" +
"get pronouns(){return $self.getPronouns(this.userId)||this._vcPronouns}" +
"isUsingGuildMemberPronouns(){"
},
{
match: /\i\(this,"pronouns",void 0\),/,
replace: ""
}
]
},
{
find: '"GuildMemberStore"',
replacement: {
match: /getNick\(\i,(\i)\)\{/,
replace: "$& if ($self.shouldIgnoreNick($1)) return null;"
}
}
],
getUsername: (user: User) => getUserOverride(user.id).username,
getAvatarUrl: (user: User) => getUserOverride(user.id).avatarUrl,
getBannerUrl: (userId: string) => getUserOverride(userId).bannerUrl,
getPronouns: (userId: string) => getUserOverride(userId).pronouns,
shouldIgnoreGuildAvatar(user: User) {
const { avatarUrl, flags } = getUserOverride(user.id);
if (avatarUrl && !hasFlag(flags, OverrideFlags.KeepServerAvatar))
return true;
return hasFlag(flags, OverrideFlags.DisableServerAvatars);
},
shouldIgnoreGuildBanner(userId: string) {
const { bannerUrl, flags } = getUserOverride(userId);
if (bannerUrl && !hasFlag(flags, OverrideFlags.KeepServerBanner))
return true;
return hasFlag(flags, OverrideFlags.DisableServerBanners);
},
shouldIgnoreNick(userId?: string) {
if (!userId) return false;
const { username, flags } = getUserOverride(userId);
if (username && !hasFlag(flags, OverrideFlags.PreferServerNicks))
return true;
return hasFlag(flags, OverrideFlags.DisableNicks);
}
});

View file

@ -0,0 +1,170 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2024 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { classNameFactory } from "@api/Styles";
import { Flex } from "@components/Flex";
import { Margins } from "@utils/margins";
import { ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal";
import { Button, DisplayProfileUtils, showToast, Switch, TabBar, Text, TextInput, Toasts, UsernameUtils, useState } from "@webpack/common";
import { User } from "discord-types/general";
import type { Dispatch, SetStateAction } from "react";
import { emptyOverride, hasFlag, OverrideFlags, settings, UserOverride } from "./data";
const cl = classNameFactory("vc-editUsers-");
interface OverrideProps {
override: UserOverride;
setOverride: Dispatch<SetStateAction<UserOverride>>;
}
interface SettingsRowProps extends OverrideProps {
overrideKey: keyof Omit<UserOverride, "flags">;
name: string;
flagDisable: OverrideFlags;
flagPrefer: OverrideFlags;
placeholder: string;
}
function SettingsRow(props: SettingsRowProps) {
const { name, override, setOverride, overrideKey, placeholder, flagDisable, flagPrefer } = props;
const namePlural = name + "s";
const { flags } = override;
const toggleFlag = (on: boolean, flag: OverrideFlags) =>
on
? flags | flag
: flags & ~flag;
return (
<>
<TextInput
className={Margins.bottom16}
value={override[overrideKey]}
onChange={v => setOverride(o => ({ ...o, [overrideKey]: v }))}
placeholder={placeholder}
autoFocus
/>
<Switch
value={hasFlag(flags, flagDisable)}
onChange={v => setOverride(o => ({ ...o, flags: toggleFlag(v, flagDisable) }))}
note={`Will use the user's global ${name} (or your EditUser configured ${name}) over server specific ${namePlural}`}
>
Disable server specific {namePlural}
</Switch>
<Switch
value={hasFlag(flags, flagPrefer)}
onChange={v => setOverride(o => ({ ...o, flags: toggleFlag(v, flagPrefer) }))}
note={`Will use server specific ${namePlural} over the EditUser configured ${name}`}
hideBorder
>
Prefer server specific {namePlural}
</Switch>
</>
);
}
const Tabs = {
username: {
name: "Username",
flagDisable: OverrideFlags.DisableNicks,
flagPrefer: OverrideFlags.PreferServerNicks,
placeholder: (user: User) => UsernameUtils.getName(user),
},
avatarUrl: {
name: "Avatar",
flagDisable: OverrideFlags.DisableServerAvatars,
flagPrefer: OverrideFlags.KeepServerAvatar,
placeholder: (user: User) => user.getAvatarURL(),
},
bannerUrl: {
name: "Banner",
flagDisable: OverrideFlags.DisableServerBanners,
flagPrefer: OverrideFlags.KeepServerBanner,
placeholder: (user: User) => DisplayProfileUtils.getDisplayProfile(user.id)?.getBannerURL({ canAnimate: true, size: 64 }) ?? "",
},
} as const;
const TabKeys = Object.keys(Tabs) as (keyof typeof Tabs)[];
function EditTabs({ user, override, setOverride }: { user: User; } & OverrideProps) {
const [currentTabName, setCurrentTabName] = useState(TabKeys[0]);
const currentTab = Tabs[currentTabName];
return (
<>
<TabBar
type="top"
look="brand"
className={cl("tabBar")}
selectedItem={currentTabName}
onItemSelect={setCurrentTabName}
>
{TabKeys.map(key => (
<TabBar.Item
id={key}
key={key}
className={cl("tab")}
>
{Tabs[key].name}
</TabBar.Item>
))}
</TabBar>
<SettingsRow
{...currentTab}
override={override}
overrideKey={currentTabName}
setOverride={setOverride}
placeholder={currentTab.placeholder(user)}
/>
</>
);
}
function EditModal({ user, modalProps }: { user: User; modalProps: ModalProps; }) {
const [override, setOverride] = useState(() => ({ ...settings.store.users?.[user.id] ?? emptyOverride }));
return (
<ModalRoot {...modalProps} size={ModalSize.MEDIUM}>
<ModalHeader>
<Text variant="heading-lg/semibold" style={{ flexGrow: 1 }}>Edit User {user.username}</Text>
<ModalCloseButton onClick={modalProps.onClose} />
</ModalHeader>
<ModalContent>
<div className={cl("modal")}>
<EditTabs user={user} override={override} setOverride={setOverride} />
</div>
</ModalContent>
<ModalFooter>
<Flex>
<Button
color={Button.Colors.RED}
onClick={() => setOverride({ ...emptyOverride })}
>
Reset All
</Button>
<Button
onClick={() => {
const s = settings.store.users ??= {};
s[user.id] = override;
modalProps.onClose();
showToast("Saved! Switch chats for changes to apply everywhere", Toasts.Type.SUCCESS, { position: Toasts.Position.BOTTOM });
}}
>
Save
</Button>
</Flex>
</ModalFooter>
</ModalRoot>
);
}
export function openUserEditModal(user: User) {
openModal(props => <EditModal user={user} modalProps={props} />);
}

View file

@ -0,0 +1,14 @@
.vc-editUsers-modal {
padding: 1em 0;
}
.vc-editUsers-tabBar {
gap: 1em;
margin-bottom: 16px;
border-bottom: 2px solid var(--background-modifier-accent);
}
.vc-editUsers-tab {
padding-bottom: 8px;
}

View file

@ -1,5 +0,0 @@
# NoDefaultHangStatus
Disable the default hang status when joining voice channels
![Visualization](https://github.com/Vendicated/Vencord/assets/24937357/329a9742-236f-48f7-94ff-c3510eca505a)

View file

@ -1,24 +0,0 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2024 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { Devs } from "@utils/constants";
import definePlugin from "@utils/types";
export default definePlugin({
name: "NoDefaultHangStatus",
description: "Disable the default hang status when joining voice channels",
authors: [Devs.D3SOX],
patches: [
{
find: ".CHILLING)",
replacement: {
match: /{enableHangStatus:(\i),/,
replace: "{_enableHangStatus:$1=false,"
}
}
]
});

View file

@ -0,0 +1,7 @@
# User Voice Show
Shows an indicator when a user is in a Voice Channel
![a preview of the indicator in the user profile](https://github.com/user-attachments/assets/48f825e4-fad5-40d7-bb4f-41d5e595aae0)
![a preview of the indicator in the member list](https://github.com/user-attachments/assets/51be081d-7bbb-45c5-8533-d565228e50c1)

View file

@ -0,0 +1,170 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2024 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { classNameFactory } from "@api/Styles";
import ErrorBoundary from "@components/ErrorBoundary";
import { classes } from "@utils/misc";
import { findByPropsLazy, findComponentByCodeLazy, findStoreLazy } from "@webpack";
import { ChannelStore, GuildStore, IconUtils, NavigationRouter, PermissionsBits, PermissionStore, showToast, Text, Toasts, Tooltip, useCallback, useMemo, UserStore, useStateFromStores } from "@webpack/common";
import { Channel } from "discord-types/general";
const cl = classNameFactory("vc-uvs-");
const { selectVoiceChannel } = findByPropsLazy("selectChannel", "selectVoiceChannel");
const VoiceStateStore = findStoreLazy("VoiceStateStore");
const UserSummaryItem = findComponentByCodeLazy("defaultRenderUser", "showDefaultAvatarsForNullUsers");
interface IconProps extends React.HTMLAttributes<HTMLDivElement> {
size?: number;
}
function SpeakerIcon(props: IconProps) {
props.size ??= 16;
return (
<div
{...props}
role={props.onClick != null ? "button" : undefined}
className={classes(cl("speaker"), props.onClick != null ? cl("clickable") : undefined)}
>
<svg
width={props.size}
height={props.size}
viewBox="0 0 24 24"
fill="currentColor"
>
<path d="M12 3a1 1 0 0 0-1-1h-.06a1 1 0 0 0-.74.32L5.92 7H3a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h2.92l4.28 4.68a1 1 0 0 0 .74.32H11a1 1 0 0 0 1-1V3ZM15.1 20.75c-.58.14-1.1-.33-1.1-.92v-.03c0-.5.37-.92.85-1.05a7 7 0 0 0 0-13.5A1.11 1.11 0 0 1 14 4.2v-.03c0-.6.52-1.06 1.1-.92a9 9 0 0 1 0 17.5Z" />
<path d="M15.16 16.51c-.57.28-1.16-.2-1.16-.83v-.14c0-.43.28-.8.63-1.02a3 3 0 0 0 0-5.04c-.35-.23-.63-.6-.63-1.02v-.14c0-.63.59-1.1 1.16-.83a5 5 0 0 1 0 9.02Z" />
</svg>
</div>
);
}
function LockedSpeakerIcon(props: IconProps) {
props.size ??= 16;
return (
<div
{...props}
role={props.onClick != null ? "button" : undefined}
className={classes(cl("speaker"), props.onClick != null ? cl("clickable") : undefined)}
>
<svg
width={props.size}
height={props.size}
viewBox="0 0 24 24"
fill="currentColor"
>
<path fillRule="evenodd" clipRule="evenodd" d="M16 4h.5v-.5a2.5 2.5 0 0 1 5 0V4h.5a1 1 0 0 1 1 1v4a1 1 0 0 1-1 1h-6a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1Zm4-.5V4h-2v-.5a1 1 0 1 1 2 0Z" />
<path d="M11 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1h-.06a1 1 0 0 1-.74-.32L5.92 17H3a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1h2.92l4.28-4.68a1 1 0 0 1 .74-.32H11ZM20.5 12c-.28 0-.5.22-.52.5a7 7 0 0 1-5.13 6.25c-.48.13-.85.55-.85 1.05v.03c0 .6.52 1.06 1.1.92a9 9 0 0 0 6.89-8.25.48.48 0 0 0-.49-.5h-1ZM16.5 12c-.28 0-.5.23-.54.5a3 3 0 0 1-1.33 2.02c-.35.23-.63.6-.63 1.02v.14c0 .63.59 1.1 1.16.83a5 5 0 0 0 2.82-4.01c.02-.28-.2-.5-.48-.5h-1Z" />
</svg>
</div>
);
}
interface VoiceChannelTooltipProps {
channel: Channel;
}
function VoiceChannelTooltip({ channel }: VoiceChannelTooltipProps) {
const voiceStates = useStateFromStores([VoiceStateStore], () => VoiceStateStore.getVoiceStatesForChannel(channel.id));
const users = useMemo(
() => Object.values<any>(voiceStates).map(voiceState => UserStore.getUser(voiceState.userId)).filter(user => user != null),
[voiceStates]
);
const guild = useMemo(
() => channel.getGuildId() == null ? undefined : GuildStore.getGuild(channel.getGuildId()),
[channel]
);
const guildIcon = useMemo(() => {
return guild?.icon == null ? undefined : IconUtils.getGuildIconURL({
id: guild.id,
icon: guild.icon,
size: 30
});
}, [guild]);
return (
<>
{guild != null && (
<div className={cl("guild-name")}>
{guildIcon != null && <img className={cl("guild-icon")} src={guildIcon} alt="" />}
<Text variant="text-sm/bold">{guild.name}</Text>
</div>
)}
<Text variant="text-sm/semibold">{channel.name}</Text>
<div className={cl("vc-members")}>
<SpeakerIcon size={18} />
<UserSummaryItem
users={users}
renderIcon={false}
max={7}
size={18}
/>
</div>
</>
);
}
interface VoiceChannelIndicatorProps {
userId: string;
}
const clickTimers = {} as Record<string, any>;
export const VoiceChannelIndicator = ErrorBoundary.wrap(({ userId }: VoiceChannelIndicatorProps) => {
const channelId = useStateFromStores([VoiceStateStore], () => VoiceStateStore.getVoiceStateForUser(userId)?.channelId as string | undefined);
const channel = useMemo(() => channelId == null ? undefined : ChannelStore.getChannel(channelId), [channelId]);
const onClick = useCallback((e: React.MouseEvent) => {
e.preventDefault();
e.stopPropagation();
if (channel == null || channelId == null) return;
if (!PermissionStore.can(PermissionsBits.VIEW_CHANNEL, channel)) {
showToast("You cannot view the user's Voice Channel", Toasts.Type.FAILURE);
return;
}
clearTimeout(clickTimers[channelId]);
delete clickTimers[channelId];
if (e.detail > 1) {
if (!PermissionStore.can(PermissionsBits.CONNECT, channel)) {
showToast("You cannot join the user's Voice Channel", Toasts.Type.FAILURE);
return;
}
selectVoiceChannel(channelId);
} else {
clickTimers[channelId] = setTimeout(() => {
NavigationRouter.transitionTo(`/channels/${channel.getGuildId() ?? "@me"}/${channelId}`);
delete clickTimers[channelId];
}, 250);
}
}, [channelId]);
const isLocked = useMemo(() => {
return !PermissionStore.can(PermissionsBits.VIEW_CHANNEL, channel) || !PermissionStore.can(PermissionsBits.CONNECT, channel);
}, [channelId]);
if (channel == null) return null;
return (
<Tooltip
text={<VoiceChannelTooltip channel={channel} />}
tooltipClassName={cl("tooltip-container")}
>
{props =>
isLocked ?
<LockedSpeakerIcon {...props} onClick={onClick} />
: <SpeakerIcon {...props} onClick={onClick} />
}
</Tooltip>
);
}, { noop: true });

View file

@ -1,27 +0,0 @@
.vc-uvs-button>div {
white-space: normal !important;
}
.vc-uvs-button {
width: 100%;
margin: auto;
height: unset;
}
.vc-uvs-header {
color: var(--header-primary);
margin-bottom: 6px;
}
.vc-uvs-modal-margin {
margin: 0 12px;
}
.vc-uvs-modal-margin div {
margin-bottom: 0 !important;
}
.vc-uvs-popout-margin-self>[class^="section"] {
padding-top: 0;
padding-bottom: 12px;
}

View file

@ -1,61 +0,0 @@
/*
* Vencord, a modification for Discord's desktop app
* Copyright (c) 2023 Vendicated and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import "./VoiceChannelSection.css";
import { findByPropsLazy } from "@webpack";
import { Button, Forms, PermissionStore, Toasts } from "@webpack/common";
import { Channel } from "discord-types/general";
const ChannelActions = findByPropsLazy("selectChannel", "selectVoiceChannel");
const CONNECT = 1n << 20n;
interface VoiceChannelFieldProps {
channel: Channel;
label: string;
showHeader: boolean;
}
export const VoiceChannelSection = ({ channel, label, showHeader }: VoiceChannelFieldProps) => (
// @TODO The div is supposed to be a UserPopoutSection
<div>
{showHeader && <Forms.FormTitle className="vc-uvs-header">In a voice channel</Forms.FormTitle>}
<Button
className="vc-uvs-button"
color={Button.Colors.TRANSPARENT}
size={Button.Sizes.SMALL}
onClick={() => {
if (PermissionStore.can(CONNECT, channel))
ChannelActions.selectVoiceChannel(channel.id);
else
Toasts.show({
message: "Insufficient permissions to enter the channel.",
id: "user-voice-show-insufficient-permissions",
type: Toasts.Type.FAILURE,
options: {
position: Toasts.Position.BOTTOM,
}
});
}}
>
{label}
</Button>
</div>
);

View file

@ -16,85 +16,85 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import "./style.css";
import { addDecorator, removeDecorator } from "@api/MemberListDecorators";
import { definePluginSettings } from "@api/Settings"; import { definePluginSettings } from "@api/Settings";
import ErrorBoundary from "@components/ErrorBoundary";
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types"; import definePlugin, { OptionType } from "@utils/types";
import { findStoreLazy } from "@webpack";
import { ChannelStore, GuildStore, UserStore } from "@webpack/common";
import { User } from "discord-types/general";
import { VoiceChannelSection } from "./components/VoiceChannelSection"; import { VoiceChannelIndicator } from "./components";
const VoiceStateStore = findStoreLazy("VoiceStateStore");
const settings = definePluginSettings({ const settings = definePluginSettings({
showInUserProfileModal: { showInUserProfileModal: {
type: OptionType.BOOLEAN, type: OptionType.BOOLEAN,
description: "Show a user's voice channel in their profile modal", description: "Show a user's Voice Channel indicator in their profile next to the name",
default: true, default: true,
restartNeeded: true
}, },
showVoiceChannelSectionHeader: { showInVoiceMemberList: {
type: OptionType.BOOLEAN, type: OptionType.BOOLEAN,
description: 'Whether to show "IN A VOICE CHANNEL" above the join button', description: "Show a user's Voice Channel indicator in the member and DMs list",
default: true, default: true,
restartNeeded: true
} }
}); });
interface UserProps {
user: User;
}
const VoiceChannelField = ErrorBoundary.wrap(({ user }: UserProps) => {
const { channelId } = VoiceStateStore.getVoiceStateForUser(user.id) ?? {};
if (!channelId) return null;
const channel = ChannelStore.getChannel(channelId);
if (!channel) return null;
const guild = GuildStore.getGuild(channel.guild_id);
if (!guild) return null; // When in DM call
const result = `${guild.name} | ${channel.name}`;
return (
<VoiceChannelSection
channel={channel}
label={result}
showHeader={settings.store.showVoiceChannelSectionHeader}
/>
);
});
export default definePlugin({ export default definePlugin({
name: "UserVoiceShow", name: "UserVoiceShow",
description: "Shows whether a User is currently in a voice channel somewhere in their profile", description: "Shows an indicator when a user is in a Voice Channel",
authors: [Devs.LordElias], authors: [Devs.LordElias, Devs.Nuckyz],
settings, settings,
patchModal({ user }: UserProps) {
if (!settings.store.showInUserProfileModal)
return null;
return (
<div className="vc-uvs-modal-margin">
<VoiceChannelField user={user} />
</div>
);
},
patchProfilePopout: ({ user }: UserProps) => {
const isSelfUser = user.id === UserStore.getCurrentUser().id;
return (
<div className={isSelfUser ? "vc-uvs-popout-margin-self" : ""}>
<VoiceChannelField user={user} />
</div>
);
},
patches: [ patches: [
// @TODO Maybe patch UserVoiceShow in simplified profile popout // User Popout, Full Size Profile, Direct Messages Side Profile
// @TODO Patch new profile modal {
find: ".Messages.USER_PROFILE_LOAD_ERROR",
replacement: {
match: /(\.fetchError.+?\?)null/,
replace: (_, rest) => `${rest}$self.VoiceChannelIndicator({userId:arguments[0]?.userId})`
},
predicate: () => settings.store.showInUserProfileModal
},
// To use without the MemberList decorator API
/* // Guild Members List
{
find: ".lostPermission)",
replacement: {
match: /\.lostPermission\).+?(?=avatar:)/,
replace: "$&children:[$self.VoiceChannelIndicator({userId:arguments[0]?.user?.id})],"
},
predicate: () => settings.store.showVoiceChannelIndicator
},
// Direct Messages List
{
find: "PrivateChannel.renderAvatar",
replacement: {
match: /\.Messages\.CLOSE_DM.+?}\)(?=])/,
replace: "$&,$self.VoiceChannelIndicator({userId:arguments[0]?.user?.id})"
},
predicate: () => settings.store.showVoiceChannelIndicator
}, */
// Friends List
{
find: ".avatar,animate:",
replacement: {
match: /\.subtext,children:.+?}\)\]}\)(?=])/,
replace: "$&,$self.VoiceChannelIndicator({userId:arguments[0]?.user?.id})"
},
predicate: () => settings.store.showInVoiceMemberList
}
], ],
start() {
if (settings.store.showInVoiceMemberList) {
addDecorator("UserVoiceShow", ({ user }) => user == null ? null : <VoiceChannelIndicator userId={user.id} />);
}
},
stop() {
removeDecorator("UserVoiceShow");
},
VoiceChannelIndicator
}); });

View file

@ -0,0 +1,37 @@
.vc-uvs-speaker {
color: var(--interactive-normal);
padding: 0 4px;
display: flex;
align-items: center;
justify-content: center;
}
.vc-uvs-clickable {
cursor: pointer;
}
.vc-uvs-clickable:hover {
color: var(--interactive-hover);
}
.vc-uvs-tooltip-container {
max-width: 200px;
}
.vc-uvs-guild-name {
display: flex;
align-items: center;
gap: 8px;
}
.vc-uvs-guild-icon {
border-radius: 100%;
align-self: center;
}
.vc-uvs-vc-members {
display: flex;
margin: 8px 0;
flex-direction: row;
gap: 6px;
}