From fd461045b9254d7b11c34d7e9b85f787cc692ba3 Mon Sep 17 00:00:00 2001 From: thororen <78185467+thororen1234@users.noreply.github.com> Date: Mon, 29 Sep 2025 20:51:37 -0400 Subject: [PATCH] new plugin AutoDNDWhilePlaying (#3652) Co-authored-by: Vendicated --- .../README.md | 5 ++ .../index.ts | 61 +++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 src/plugins/autoDndWhilePlaying.discordDesktop/README.md create mode 100644 src/plugins/autoDndWhilePlaying.discordDesktop/index.ts diff --git a/src/plugins/autoDndWhilePlaying.discordDesktop/README.md b/src/plugins/autoDndWhilePlaying.discordDesktop/README.md new file mode 100644 index 000000000..52a611801 --- /dev/null +++ b/src/plugins/autoDndWhilePlaying.discordDesktop/README.md @@ -0,0 +1,5 @@ +# AutoDNDWhilePlaying + +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. diff --git a/src/plugins/autoDndWhilePlaying.discordDesktop/index.ts b/src/plugins/autoDndWhilePlaying.discordDesktop/index.ts new file mode 100644 index 000000000..faf238cd8 --- /dev/null +++ b/src/plugins/autoDndWhilePlaying.discordDesktop/index.ts @@ -0,0 +1,61 @@ +/* + * 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 { getUserSettingLazy } from "@api/UserSettings"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; + +let savedStatus: string | null; + +const StatusSettings = getUserSettingLazy("status", "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: "AutoDNDWhilePlaying", + description: "Automatically updates your online status (online, idle, dnd) when launching games", + authors: [Devs.thororen], + settings, + flux: { + RUNNING_GAMES_CHANGE({ games }) { + const status = StatusSettings.getSetting(); + + if (games.length > 0) { + if (status !== settings.store.statusToSet) { + savedStatus = status; + StatusSettings.updateSetting(settings.store.statusToSet); + } + } else if (savedStatus && savedStatus !== settings.store.statusToSet) { + StatusSettings.updateSetting(savedStatus); + } + } + } +});