diff --git a/src/plugins/steamStatusSync.desktop/README.md b/src/plugins/steamStatusSync.desktop/README.md new file mode 100644 index 000000000..daeed4b19 --- /dev/null +++ b/src/plugins/steamStatusSync.desktop/README.md @@ -0,0 +1,5 @@ +# SteamStatusSync + +Syncs your status on Discord to Steam via protocol URIs with configurable options + +![Animated Demo](./steamsyncdemo.webp) diff --git a/src/plugins/steamStatusSync.desktop/index.tsx b/src/plugins/steamStatusSync.desktop/index.tsx new file mode 100644 index 000000000..14287b585 --- /dev/null +++ b/src/plugins/steamStatusSync.desktop/index.tsx @@ -0,0 +1,119 @@ +/* + * 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"; + +enum SteamStatus { + Online = "online", + Away = "away", + Invisible = "invisible", + Offline = "offline", + None = "none" +} + +interface SettingsProto { + settings: { + proto: { + status?: { + status: { + value: String; + }, + showCurrentGame: { + value: Boolean; + }, + }; + }; + }; +} + +export const settings = definePluginSettings({ + onlineStatus: { + type: OptionType.SELECT, + description: "Steam status when on Online", + options: [ + { label: "Online", value: SteamStatus.Online, default: true }, + { label: "Away", value: SteamStatus.Away }, + { label: "Invisible", value: SteamStatus.Invisible }, + { label: "Offline (Disconnect Steam Chat & Friends)", value: SteamStatus.Offline }, + { label: "Disabled", value: SteamStatus.None } + ], + }, + idleStatus: { + type: OptionType.SELECT, + description: "Steam status when on Idle", + options: [ + { label: "Online", value: SteamStatus.Online }, + { label: "Away", value: SteamStatus.Away, default: true }, + { label: "Invisible", value: SteamStatus.Invisible }, + { label: "Offline (Disconnect Steam Chat & Friends)", value: SteamStatus.Offline }, + { label: "Disabled", value: SteamStatus.None } + ], + }, + dndStatus: { + type: OptionType.SELECT, + description: "Steam status when on Do Not Disturb", + options: [ + { label: "Online", value: SteamStatus.Online }, + { label: "Away", value: SteamStatus.Away, default: true }, + { label: "Invisible", value: SteamStatus.Invisible }, + { label: "Offline (Disconnect Steam Chat & Friends)", value: SteamStatus.Offline }, + { label: "Disabled", value: SteamStatus.None } + ], + }, + invisibleStatus: { + type: OptionType.SELECT, + description: "Steam status when on Invisible", + options: [ + { label: "Online", value: SteamStatus.Online }, + { label: "Away", value: SteamStatus.Away }, + { label: "Invisible", value: SteamStatus.Invisible, default: true }, + { label: "Offline (Disconnect Steam Chat & Friends)", value: SteamStatus.Offline }, + { label: "Disabled", value: SteamStatus.None } + ], + }, + hiddenActivityStatus: { + type: OptionType.SELECT, + description: "Steam status when Discord game activity is hidden", + options: [ + { label: "Online", value: SteamStatus.Online }, + { label: "Away", value: SteamStatus.Away }, + { label: "Invisible", value: SteamStatus.Invisible }, + { label: "Offline (Disconnect Steam Chat & Friends)", value: SteamStatus.Offline }, + { label: "Disabled", value: SteamStatus.None, default: true } + ], + }, +}); + +export default definePlugin({ + name: "SteamStatusSync", + description: "Sync your status to Steam!", + authors: [Devs.niko], + + settings, + + flux: { + USER_SETTINGS_PROTO_UPDATE(settingsUpdate: SettingsProto) { + const protoStatus = settingsUpdate.settings.proto.status; + + if (protoStatus !== undefined) { + const associatedStatus = settings.store[`${protoStatus.status.value}Status`]; + const { hiddenActivityStatus } = settings.store; + + if (hiddenActivityStatus !== SteamStatus.None && !protoStatus.showCurrentGame.value) { + open(`steam://friends/status/${hiddenActivityStatus}`); + + return; + } + if (associatedStatus === SteamStatus.None) { return; } + + // Open steam protocol URI for status change + open(`steam://friends/status/${associatedStatus}`); + } + } + } +}); diff --git a/src/plugins/steamStatusSync.desktop/steamsyncdemo.webp b/src/plugins/steamStatusSync.desktop/steamsyncdemo.webp new file mode 100644 index 000000000..dcd8bd31d Binary files /dev/null and b/src/plugins/steamStatusSync.desktop/steamsyncdemo.webp differ diff --git a/src/utils/constants.ts b/src/utils/constants.ts index c399baafe..f311fbba8 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -533,6 +533,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({ Antti: { name: "Antti", id: 312974985876471810n + }, + niko: { + name: "niko", + id: 341377368075796483n } } satisfies Record);