2024-05-05 21:07:28 -04:00
|
|
|
/*
|
|
|
|
* Vencord, a Discord client mod
|
|
|
|
* Copyright (c) 2024 Vendicated and contributors
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
*/
|
|
|
|
|
2024-08-15 00:58:55 -04:00
|
|
|
import { definePluginSettings } from "@api/Settings";
|
2024-05-05 21:07:28 -04:00
|
|
|
import { EquicordDevs } from "@utils/constants";
|
2024-07-19 13:37:41 -04:00
|
|
|
import definePlugin, { OptionType } from "@utils/types";
|
2024-05-05 21:07:28 -04:00
|
|
|
import { findByCodeLazy } from "@webpack";
|
2024-08-15 00:58:55 -04:00
|
|
|
import { PresenceStore, UserStore } from "@webpack/common";
|
2024-05-05 21:07:28 -04:00
|
|
|
|
2024-08-15 00:58:55 -04:00
|
|
|
let savedStatus = "";
|
2024-07-19 13:37:41 -04:00
|
|
|
const updateAsync = findByCodeLazy("updateAsync", "status");
|
|
|
|
const settings = definePluginSettings({
|
|
|
|
statusToSet: {
|
|
|
|
type: OptionType.SELECT,
|
2024-07-19 13:51:16 -04:00
|
|
|
description: "Status to set while playing a game",
|
2024-07-19 13:37:41 -04:00
|
|
|
options: [
|
|
|
|
{
|
|
|
|
label: "Online",
|
|
|
|
value: "online",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Idle",
|
|
|
|
value: "idle",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Do Not Disturb",
|
|
|
|
value: "dnd",
|
2024-07-19 13:40:26 -04:00
|
|
|
default: true
|
2024-07-19 13:37:41 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Invisible",
|
|
|
|
value: "invisible",
|
|
|
|
}
|
|
|
|
]
|
2024-05-05 21:07:28 -04:00
|
|
|
}
|
2024-07-19 13:37:41 -04:00
|
|
|
});
|
2024-05-05 21:07:28 -04:00
|
|
|
|
|
|
|
export default definePlugin({
|
2024-07-19 13:37:41 -04:00
|
|
|
name: "StatusWhilePlaying",
|
2024-08-15 00:58:55 -04:00
|
|
|
description: "Automatically updates your online status (online, idle, dnd) when launching games",
|
2024-05-05 21:07:28 -04:00
|
|
|
authors: [EquicordDevs.thororen],
|
2024-07-19 13:37:41 -04:00
|
|
|
settings,
|
2024-08-15 00:58:55 -04:00
|
|
|
flux: {
|
|
|
|
RUNNING_GAMES_CHANGE(event) {
|
2024-07-19 13:51:16 -04:00
|
|
|
const status = PresenceStore.getStatus(UserStore.getCurrentUser().id);
|
2024-08-15 00:58:55 -04:00
|
|
|
if (event.games.length > 0) {
|
|
|
|
if (status !== settings.store.statusToSet) {
|
|
|
|
savedStatus = status;
|
|
|
|
updateAsync(settings.store.statusToSet);
|
|
|
|
}
|
2024-08-21 21:39:41 -04:00
|
|
|
} else {
|
|
|
|
if (savedStatus !== "" && savedStatus !== settings.store.statusToSet)
|
|
|
|
updateAsync(savedStatus);
|
2024-08-15 00:58:55 -04:00
|
|
|
}
|
|
|
|
},
|
2024-05-05 21:07:28 -04:00
|
|
|
}
|
|
|
|
});
|