mirror of
https://github.com/Equicord/Equicord.git
synced 2025-01-30 19:23:29 -05:00
StatusWhilePlaying
This commit is contained in:
parent
e7e298d2e7
commit
698787f4e3
3 changed files with 68 additions and 1 deletions
5
src/plugins/statusWhilePlaying.desktop/README.md
Normal file
5
src/plugins/statusWhilePlaying.desktop/README.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
# StatusWhilePlaying
|
||||
|
||||
This plugin automatically updates your online status (online, idle, dnd) when launching games.
|
||||
|
||||
It will change your status back to the prior status when the game is closed.
|
58
src/plugins/statusWhilePlaying.desktop/index.ts
Normal file
58
src/plugins/statusWhilePlaying.desktop/index.ts
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2024 Vendicated and contributors
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import { definePluginSettings } from "@api/Settings";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { findByCodeLazy } from "@webpack";
|
||||
import { PresenceStore, UserStore } from "@webpack/common";
|
||||
|
||||
let savedStatus = "";
|
||||
const updateAsync = findByCodeLazy("updateAsync", "status");
|
||||
const settings = definePluginSettings({
|
||||
statusToSet: {
|
||||
type: OptionType.SELECT,
|
||||
description: "Status to set while playing a game",
|
||||
options: [
|
||||
{
|
||||
label: "Online",
|
||||
value: "online",
|
||||
},
|
||||
{
|
||||
label: "Idle",
|
||||
value: "idle",
|
||||
},
|
||||
{
|
||||
label: "Do Not Disturb",
|
||||
value: "dnd",
|
||||
default: true
|
||||
},
|
||||
{
|
||||
label: "Invisible",
|
||||
value: "invisible",
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
export default definePlugin({
|
||||
name: "StatusWhilePlaying",
|
||||
description: "Automatically updates your online status (online, idle, dnd) when launching games",
|
||||
authors: [Devs.thororen],
|
||||
settings,
|
||||
flux: {
|
||||
RUNNING_GAMES_CHANGE(event) {
|
||||
const status = PresenceStore.getStatus(UserStore.getCurrentUser().id);
|
||||
if (event.games.length > 0 && status !== settings.store.statusToSet) {
|
||||
savedStatus = status;
|
||||
updateAsync(settings.store.statusToSet);
|
||||
} else {
|
||||
if (savedStatus !== "" && savedStatus !== settings.store.statusToSet)
|
||||
updateAsync(savedStatus);
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
|
@ -579,6 +579,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({
|
|||
name: "SomeAspy",
|
||||
id: 516750892372852754n,
|
||||
},
|
||||
thororen: {
|
||||
name: "thororen",
|
||||
id: 848339671629299742n,
|
||||
},
|
||||
} satisfies Record<string, Dev>);
|
||||
|
||||
// iife so #__PURE__ works correctly
|
||||
|
|
Loading…
Reference in a new issue