NewGuildSettings: Collapsed VCs

* Add VC collapse feature

* Remove comments

* default false

---------

Co-authored-by: thororen1234 <78185467+thororen1234@users.noreply.github.com>
Co-authored-by: justjxke <Jake0300@protonmai.com>
This commit is contained in:
Jake 2025-09-13 06:29:36 +01:00 • committed by GitHub
parent 8e8449b1e2
commit 37ff06f928
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -26,7 +26,7 @@ import { Devs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types";
import { Guild } from "@vencord/discord-types";
import { findByCodeLazy, findByPropsLazy, mapMangledModuleLazy } from "@webpack";
import { Menu } from "@webpack/common";
import { FluxDispatcher, GuildChannelStore, Menu } from "@webpack/common";
const { updateGuildNotificationSettings } = findByPropsLazy("updateGuildNotificationSettings");
const { toggleShowAllChannels } = mapMangledModuleLazy(".onboardExistingMember(", {
@ -82,6 +82,11 @@ const settings = definePluginSettings({
description: "Mute Mobile Push Notifications automatically",
type: OptionType.BOOLEAN,
default: true
},
voiceChannels: {
description: "Hide names in Voice channels automatically",
type: OptionType.BOOLEAN,
default: false
}
});
@ -99,8 +104,30 @@ const makeContextMenuPatch: (shouldAddIcon: boolean) => NavContextMenuPatchCallb
);
};
function applyVoiceNameHidingToGuild(guildId: string) {
if (!settings.store.voiceChannels) return;
try {
const channels = GuildChannelStore.getChannels(guildId);
if (!channels?.VOCAL) return;
channels.VOCAL.forEach(({ channel }: { channel: { id: string; type: number; }; }) => {
if (channel.type === 2) {
FluxDispatcher.dispatch({
type: "CHANNEL_COLLAPSE",
channelId: channel.id,
collapsed: true
});
}
});
} catch (error) {
console.warn("[NewGuildSettings] Error applying voice name hiding:", error);
}
}
function applyDefaultSettings(guildId: string | null) {
if (guildId === "@me" || guildId === "null" || guildId == null) return;
updateGuildNotificationSettings(guildId,
{
muted: settings.store.guild,
@ -110,15 +137,21 @@ function applyDefaultSettings(guildId: string | null) {
mute_scheduled_events: settings.store.events,
notify_highlights: settings.store.highlights ? 1 : 0
});
if (settings.store.messages !== 3) {
updateGuildNotificationSettings(guildId,
{
message_notifications: settings.store.messages,
});
}
if (settings.store.showAllChannels && isOptInEnabledForGuild(guildId)) {
toggleShowAllChannels(guildId);
}
if (settings.store.voiceChannels) {
applyVoiceNameHidingToGuild(guildId);
}
}
export default definePlugin({