Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(plugin): voiceMuteBlockedUsers #3001

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
1653533
feat(plugin): voiceMuteBlockedUsers
Vexify4103 Nov 6, 2024
b13a5c6
Update index.tsx
Vexify4103 Nov 7, 2024
1342ff1
Update src/plugins/voiceMuteBlockedUsers/index.tsx
Vexify4103 Nov 7, 2024
49f5482
Update src/plugins/voiceMuteBlockedUsers/index.tsx
Vexify4103 Nov 7, 2024
bd4d1e7
schoeneBiene changes
Vexify4103 Nov 7, 2024
9711c46
Updated README.md
Vexify4103 Nov 7, 2024
9538ae4
Merge branch 'main' into main
Vexify4103 Nov 8, 2024
8b7b723
Merge branch 'main' into main
Vexify4103 Nov 9, 2024
c7723a0
Reviewed request changed.
Vexify4103 Nov 12, 2024
64402bb
Merge branch 'main' of https://github.com/Vendicated/Vencord into Ven…
Vexify4103 Nov 18, 2024
d8da7c6
Update constants.ts
Vexify4103 Nov 18, 2024
da243db
Merge branch 'Vendicated-main'
Vexify4103 Nov 18, 2024
fc0cdc1
Merge branch 'main' into main
Vexify4103 Nov 24, 2024
24f80fb
Optimize automaticMuteBlockedUsers Function for Improved Performance
Vexify4103 Nov 24, 2024
60bd0fd
Merge branch 'main' into main
Vexify4103 Nov 28, 2024
0084ce7
Merge branch 'main' into main
Vexify4103 Nov 30, 2024
5423c81
Merge branch 'main' into main
Vexify4103 Dec 4, 2024
062ed65
Merge branch 'main' into main
Vexify4103 Dec 9, 2024
8a1aec6
Merge branch 'main' into main
Vexify4103 Dec 11, 2024
20e99c1
Merge branch 'main' into main
Vexify4103 Dec 15, 2024
b67a008
Merge branch 'main' into main
Vexify4103 Dec 21, 2024
b7013de
Merge branch 'main' into main
Vexify4103 Jan 6, 2025
76002fb
DiscordFixes plugin
Nuckyz Jan 27, 2025
aa64267
Move CustomRPC fix
Nuckyz Jan 27, 2025
bb6d2f3
Move ShowHiddenThings fix
Nuckyz Jan 27, 2025
42628f8
Add more mod view fixes
Nuckyz Jan 28, 2025
9ddeb2c
Merge branch 'dev' into discord-fixes
Nuckyz Jan 28, 2025
d06789d
Add permission check
Nuckyz Jan 28, 2025
a15efbb
Merge branch 'dev' into discord-fixes
Nuckyz Jan 29, 2025
97b14da
Merge remote-tracking branch 'upstream/main' into vexify-main
Vexify4103 Jan 30, 2025
8fa7dd3
Merge branch 'discord-fixes' into vexify-main
Vexify4103 Jan 30, 2025
bc42031
Merge branch 'main' into main
Vexify4103 Feb 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions src/plugins/_api/dynamicImageModalApi.ts

This file was deleted.

114 changes: 114 additions & 0 deletions src/plugins/_core/discordFixes/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2025 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/

import "./styles.css";

import { classNameFactory } from "@api/Styles";
import ErrorBoundary from "@components/ErrorBoundary";
import { Devs } from "@utils/constants";
import { classes } from "@utils/misc";
import definePlugin from "@utils/types";
import { findByCodeLazy } from "@webpack";
import { GuildStore, PermissionsBits, PermissionStore, useEffect } from "@webpack/common";
import { PropsWithChildren } from "react";

const cl = classNameFactory("vc-discord-fixes-");

const fetchMemberSupplemental = findByCodeLazy('type:"FETCH_GUILD_MEMBER_SUPPLEMENTAL_SUCCESS"');

type UsernameWrapperProps = PropsWithChildren<Record<string, any> & {
className?: string;
}>;

const UsernameWrapper = ErrorBoundary.wrap((props: UsernameWrapperProps) => {
return <div {...props} className={classes(cl("username-wrapper"), props.className)} />;
}, { noop: true });

type MemberSupplementalCache = Record<string, number>;
let memberSupplementalCache = {};

function setMemberSupplementalCache(cache: MemberSupplementalCache) {
memberSupplementalCache = cache;
}

function useFetchMemberSupplemental(guildId: string, userId: string) {
useEffect(() => {
if (!PermissionStore.can(PermissionsBits.MANAGE_GUILD, GuildStore.getGuild(guildId))) {
return;
}

// Set this member as unfetched in the member supplemental cache
memberSupplementalCache[`${guildId}-${userId}`] ??= 1;
fetchMemberSupplemental(guildId, [userId]);
}, [guildId, userId]);
}

export default definePlugin({
name: "DiscordFixes",
description: "Fixes Discord issues required or not for Vencord plugins to work properly",
authors: [Devs.Nuckyz],
required: true,

patches: [
// Make username wrapper a div instead of a span, to align items to center easier with flex
{
find: '"Message Username"',
replacement: {
match: /"span"(?=,{id:)/,
replace: "$self.UsernameWrapper"
}
},
// Make MediaModal use the Discord media component instead of a simple "img" component,
// if any of height or width exists and is not 0. Default behavior is to only use the component if both exist.
{
find: "SCALE_DOWN:",
replacement: {
match: /!\(null==(\i)\|\|0===\i\|\|null==(\i)\|\|0===\i\)/,
replace: (_, width, height) => `!((null==${width}||0===${width})&&(null==${height}||0===${height}))`
}
},
// Make buttons show up for your own activities
{
find: ".party?(0",
all: true,
replacement: {
match: /\i\.id===\i\.id\?null:/,
replace: ""
}
},
// Fixes mod view depending on Members page being loaded to acquire the member highest role
{
find: "#{intl::GUILD_MEMBER_MOD_VIEW_PERMISSION_GRANTED_BY_ARIA_LABEL}),allowOverflow:",
replacement: {
match: /(role:)\i(?=,guildId.{0,100}role:(\i\[))/,
replace: "$1$2arguments[0].member.highestRoleId]"
}
},
// Fix mod view join method depending on loading the member in the Members page
{
find: ".MANUAL_MEMBER_VERIFICATION]:",
replacement: {
match: /useEffect\(.{0,50}\.requestMembersById\(.+?\[\i,\i\]\);(?<=userId:(\i),guildId:(\i).+?)/,
replace: (m, userId, guildId) => `${m}$self.useFetchMemberSupplemental(${guildId},${userId});`
}
},
// Fix member supplemental caching code and export cache object to use within the plugin code,
// there is no other way around it besides patching again
{
find: ".MEMBER_SAFETY_SUPPLEMENTAL(",
replacement: [
{
match: /(let (\i)={};)(function \i\(\i,\i\){return \i\+)(\i})/,
replace: (_, rest1, cache, rest2, rest3) => `${rest1}$self.setMemberSupplementalCache(${cache});${rest2}"-"+${rest3}`
}
]
}
],

UsernameWrapper,
setMemberSupplementalCache,
useFetchMemberSupplemental
});
11 changes: 11 additions & 0 deletions src/plugins/_core/discordFixes/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.vc-discord-fixes-username-wrapper {
display: inline-flex;
align-items: center;
justify-content: center;
}

/* Remove top gap from chat tags, because the plugin makes it use a div to center instead */
[class*="botTag"][class*="rem"] {
margin-top: unset;
top: unset;
}
11 changes: 0 additions & 11 deletions src/plugins/customRPC/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -399,17 +399,6 @@ export default definePlugin({
stop: () => setRpc(true),
settings,

patches: [
{
find: ".party?(0",
all: true,
replacement: {
match: /\i\.id===\i\.id\?null:/,
replace: ""
}
}
],

settingsAboutComponent: () => {
const activity = useAwaiter(createActivity);
const gameActivityEnabled = ShowCurrentGame.useSetting();
Expand Down
7 changes: 5 additions & 2 deletions src/plugins/platformIndicators/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function getBadges({ userId }: BadgeUserArgs): ProfileBadge[] {
}));
}

const PlatformIndicator = ({ user, small = false }: { user: User; small?: boolean; }) => {
const PlatformIndicator = ({ user, wantMargin = true, small = false }: { user: User; wantMargin?: boolean; small?: boolean; }) => {
if (!user || user.bot) return null;

ensureOwnStatus(user);
Expand All @@ -155,7 +155,10 @@ const PlatformIndicator = ({ user, small = false }: { user: User; small?: boolea
return (
<span
className="vc-platform-indicator"
style={{ gap: "2px" }}
style={{
marginLeft: wantMargin ? 4 : 0,
gap: 2
}}
>
{icons}
</span>
Expand Down
1 change: 0 additions & 1 deletion src/plugins/serverInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export default definePlugin({
name: "ServerInfo",
description: "Allows you to view info about a server",
authors: [Devs.Ven, Devs.Nuckyz],
dependencies: ["DynamicImageModalAPI"],
tags: ["guild", "info", "ServerProfile"],

contextMenus: {
Expand Down
11 changes: 1 addition & 10 deletions src/plugins/showHiddenThings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,7 @@ export default definePlugin({
replace: "return true",
}
},
// fixes a bug where Members page must be loaded to see highest role, why is Discord depending on MemberSafetyStore.getEnhancedMember for something that can be obtained here?
{
find: "#{intl::GUILD_MEMBER_MOD_VIEW_PERMISSION_GRANTED_BY_ARIA_LABEL}),allowOverflow:",
predicate: () => settings.store.showModView,
replacement: {
match: /(role:)\i(?=,guildId.{0,100}role:(\i\[))/,
replace: "$1$2arguments[0].member.highestRoleId]",
}
},
// allows you to open mod view on yourself
// Allows you to open mod view on yourself
{
find: 'action:"PRESS_MOD_VIEW",icon:',
predicate: () => settings.store.showModView,
Expand Down
5 changes: 3 additions & 2 deletions src/plugins/userVoiceShow/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,14 @@ function VoiceChannelTooltip({ channel, isLocked }: VoiceChannelTooltipProps) {

interface VoiceChannelIndicatorProps {
userId: string;
isProfile?: boolean;
isActionButton?: boolean;
shouldHighlight?: boolean;
}

const clickTimers = {} as Record<string, any>;

export const VoiceChannelIndicator = ErrorBoundary.wrap(({ userId, isActionButton, shouldHighlight }: VoiceChannelIndicatorProps) => {
export const VoiceChannelIndicator = ErrorBoundary.wrap(({ userId, isProfile, isActionButton, shouldHighlight }: VoiceChannelIndicatorProps) => {
const channelId = useStateFromStores([VoiceStateStore], () => VoiceStateStore.getVoiceStateForUser(userId)?.channelId as string | undefined);

const channel = channelId == null ? undefined : ChannelStore.getChannel(channelId);
Expand Down Expand Up @@ -180,7 +181,7 @@ export const VoiceChannelIndicator = ErrorBoundary.wrap(({ userId, isActionButto
{props => {
const iconProps: IconProps = {
...props,
className: classes(isActionButton && ActionButtonClasses.actionButton, shouldHighlight && ActionButtonClasses.highlight),
className: classes((!isProfile && !isActionButton) && cl("speaker-margin"), isActionButton && ActionButtonClasses.actionButton, shouldHighlight && ActionButtonClasses.highlight),
size: isActionButton ? 20 : undefined,
onClick
};
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/userVoiceShow/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
color: var(--interactive-hover);
}

.vc-uvs-speaker-margin {
margin-left: 4px;
}

.vc-uvs-tooltip-container {
max-width: 300px;
}
Expand Down
1 change: 0 additions & 1 deletion src/plugins/viewIcons/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ export default definePlugin({
authors: [Devs.Ven, Devs.TheKodeToad, Devs.Nuckyz, Devs.nyx],
description: "Makes avatars and banners in user profiles clickable, adds View Icon/Banner entries in the user, server and group channel context menu.",
tags: ["ImageUtilities"],
dependencies: ["DynamicImageModalAPI"],

settings,

Expand Down
21 changes: 21 additions & 0 deletions src/plugins/voiceMuteBlockedUsers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Voice Mute Blocked Users

The **Voice Mute Blocked Users** plugin automatically mutes users that you have blocked on Discord, enhancing visibility and manageability in your communication environment. This plugin transforms normal blocks into effective voice mutes, ensuring a smoother experience.

## Functionality

- **Block/Unblock Logic**:

- When a user is blocked, they are automatically muted if not already muted.
- When a user is unblocked, they are unmuted if they were previously muted.

- **User Context Menu**:
- Adds a menu item to mute/unmute users directly from their context menu.

Before:

![Before Image](https://github.com/user-attachments/assets/53278a50-86cb-4f17-a6cb-db5ac380e267)

After:

![After Image](https://github.com/user-attachments/assets/886ec3dd-1b63-4028-bb9e-4c3148e903e8)
Loading