mirror of
https://github.com/Equicord/Equicord.git
synced 2025-02-21 15:48:52 -05:00
Updates
This commit is contained in:
parent
1122b3ebbb
commit
202a5355de
2 changed files with 59 additions and 25 deletions
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Reference in a new issue