From 202a5355de6b5485cf8718d91962603e5f51d969 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Fri, 19 Jul 2024 13:37:41 -0400 Subject: [PATCH] Updates --- src/equicordplugins/dndWhilePlaying/index.ts | 75 +++++++++++++------- src/plugins/showHiddenThings/index.ts | 9 +++ 2 files changed, 59 insertions(+), 25 deletions(-) diff --git a/src/equicordplugins/dndWhilePlaying/index.ts b/src/equicordplugins/dndWhilePlaying/index.ts index 646ca905..486a6728 100644 --- a/src/equicordplugins/dndWhilePlaying/index.ts +++ b/src/equicordplugins/dndWhilePlaying/index.ts @@ -4,35 +4,60 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ +import { definePluginSettings, migratePluginSettings } from "@api/Settings"; import { EquicordDevs } from "@utils/constants"; -import definePlugin from "@utils/types"; +import definePlugin, { OptionType } from "@utils/types"; import { findByCodeLazy } from "@webpack"; import { FluxDispatcher, PresenceStore, UserStore } from "@webpack/common"; -const updateAsync = findByCodeLazy("updateAsync"); +const updateAsync = findByCodeLazy("updateAsync", "status"); -async function runningGamesChange(event) { - const { games } = event; - let savedStatus; - if (games.length > 0) { - const currentUser = UserStore.getCurrentUser(); - const status = PresenceStore.getStatus(currentUser.id); - savedStatus = status; - if (status === "invisible") return; - if (status !== "dnd") updateAsync("dnd"); - } else if (games.length === 0) { - updateAsync(savedStatus); - } -} - -export default definePlugin({ - name: "DNDWhilePlaying", - description: "Automatically updates your status to Do Not Disturb when playing games and resets it back when stopped playing", - authors: [EquicordDevs.thororen], - start() { - FluxDispatcher.subscribe("RUNNING_GAMES_CHANGE", runningGamesChange); - }, - stop() { - FluxDispatcher.unsubscribe("RUNNING_GAMES_CHANGE", runningGamesChange); +const settings = definePluginSettings({ + statusToSet: { + type: OptionType.SELECT, + description: "Status set while playing a game", + options: [ + { + label: "Online", + value: "online", + }, + { + label: "Idle", + value: "idle", + }, + { + label: "Do Not Disturb", + value: "dnd", + }, + { + label: "Invisible", + value: "invisible", + } + ] + } +}); + +migratePluginSettings("StatusWhilePlaying", "DNDWhilePlaying"); +export default definePlugin({ + name: "StatusWhilePlaying", + description: "Automatically updates your status when playing games", + authors: [EquicordDevs.thororen], + settings, + runningGamesChange(event) { + let savedStatus = ""; + if (event.games.length > 0) { + const currentUser = UserStore.getCurrentUser(); + const status = PresenceStore.getStatus(currentUser.id); + savedStatus = status; + updateAsync(settings.store.statusToSet); + } else if (event.games.length === 0) { + updateAsync(savedStatus); + } + }, + start() { + FluxDispatcher.subscribe("RUNNING_GAMES_CHANGE", this.runningGamesChange); + }, + stop() { + FluxDispatcher.unsubscribe("RUNNING_GAMES_CHANGE", this.runningGamesChange); } }); diff --git a/src/plugins/showHiddenThings/index.ts b/src/plugins/showHiddenThings/index.ts index 90bb345e..b6c8e410 100644 --- a/src/plugins/showHiddenThings/index.ts +++ b/src/plugins/showHiddenThings/index.ts @@ -66,6 +66,15 @@ 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: "Messages.GUILD_MEMBER_MOD_VIEW_PERMISSION_GRANTED_BY_ARIA_LABEL,tooltipContentClassName", + predicate: () => settings.store.showModView, + replacement: { + match: /(role:)\i(?=,guildId.{0,100}role:(\i\[))/, + replace: "$1$2arguments[0].member.highestRoleId]", + } + }, { find: "prod_discoverable_guilds", predicate: () => settings.store.disableDiscoveryFilters,