From 01bd41413dd3bb83e0f392e7e04e9a6174d6ebda Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Fri, 19 Jul 2024 00:57:03 -0300 Subject: [PATCH 01/15] FriendsSince: Fix broken patch --- src/plugins/friendsSince/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/friendsSince/index.tsx b/src/plugins/friendsSince/index.tsx index 717bd754ca7..44be8927f81 100644 --- a/src/plugins/friendsSince/index.tsx +++ b/src/plugins/friendsSince/index.tsx @@ -52,7 +52,7 @@ export default definePlugin({ { find: ".PANEL}),nicknameIcons", replacement: { - match: /USER_PROFILE_MEMBER_SINCE,.{0,100}userId:(\i\.id)}\)}\)/, + match: /BOT_PROFILE_CREATED_ON,.{0,100}userId:(\i\.id)}\)}\)/, replace: "$&,$self.friendsSinceNew({userId:$1,isSidebar:true})" } }, From 11ce0100783cd6a99dc2028e93736338527bb800 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Fri, 19 Jul 2024 13:43:12 -0400 Subject: [PATCH 02/15] StatusWhilePlaying --- src/plugins/statusWhilePlaying/index.ts | 62 +++++++++++++++++++++++++ src/utils/constants.ts | 6 ++- 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 src/plugins/statusWhilePlaying/index.ts diff --git a/src/plugins/statusWhilePlaying/index.ts b/src/plugins/statusWhilePlaying/index.ts new file mode 100644 index 00000000000..d4aa7c31e8f --- /dev/null +++ b/src/plugins/statusWhilePlaying/index.ts @@ -0,0 +1,62 @@ +/* + * 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 { FluxDispatcher, PresenceStore, UserStore } from "@webpack/common"; + +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 status when playing games", + authors: [Devs.thororen], + settings, + runningGamesChange(event) { + let savedStatus = ""; + if (event.games.length > 0) { + const status = PresenceStore.getStatus(UserStore.getCurrentUser().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); + } +}); diff --git a/src/utils/constants.ts b/src/utils/constants.ts index c399baafea9..5601eda314d 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -533,7 +533,11 @@ export const Devs = /* #__PURE__*/ Object.freeze({ Antti: { name: "Antti", id: 312974985876471810n - } + }, + thororen: { + name: "thororen", + id: 848339671629299742n, + }, } satisfies Record); // iife so #__PURE__ works correctly From ccd029eba9a61e00c9a86a19b86b54daa32a9856 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Fri, 19 Jul 2024 13:47:48 -0400 Subject: [PATCH 03/15] Add a Readme.md --- src/plugins/statusWhilePlaying/README.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/plugins/statusWhilePlaying/README.md diff --git a/src/plugins/statusWhilePlaying/README.md b/src/plugins/statusWhilePlaying/README.md new file mode 100644 index 00000000000..6cd2ec94ccc --- /dev/null +++ b/src/plugins/statusWhilePlaying/README.md @@ -0,0 +1,5 @@ +# StatusWhilePlaying + +This pluign automatically updates your status when playing games. + +It can set your status to any of the current statuses. It will revert your status back when the game is closed. From 76663617d86f54fc710c46f08928ba3fd06f1c0d Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Fri, 19 Jul 2024 13:48:37 -0400 Subject: [PATCH 04/15] Fix typo --- src/plugins/statusWhilePlaying/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/statusWhilePlaying/README.md b/src/plugins/statusWhilePlaying/README.md index 6cd2ec94ccc..ee8079890de 100644 --- a/src/plugins/statusWhilePlaying/README.md +++ b/src/plugins/statusWhilePlaying/README.md @@ -1,5 +1,5 @@ # StatusWhilePlaying -This pluign automatically updates your status when playing games. +This plugin automatically updates your status when playing games. It can set your status to any of the current statuses. It will revert your status back when the game is closed. From 39f2305eb21adc54023ffc5857255f1068eaa7c6 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Fri, 19 Jul 2024 15:16:18 -0400 Subject: [PATCH 05/15] Desktop Restricition --- .../{statusWhilePlaying => statusWhilePlaying.desktop}/README.md | 0 .../{statusWhilePlaying => statusWhilePlaying.desktop}/index.ts | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename src/plugins/{statusWhilePlaying => statusWhilePlaying.desktop}/README.md (100%) rename src/plugins/{statusWhilePlaying => statusWhilePlaying.desktop}/index.ts (100%) diff --git a/src/plugins/statusWhilePlaying/README.md b/src/plugins/statusWhilePlaying.desktop/README.md similarity index 100% rename from src/plugins/statusWhilePlaying/README.md rename to src/plugins/statusWhilePlaying.desktop/README.md diff --git a/src/plugins/statusWhilePlaying/index.ts b/src/plugins/statusWhilePlaying.desktop/index.ts similarity index 100% rename from src/plugins/statusWhilePlaying/index.ts rename to src/plugins/statusWhilePlaying.desktop/index.ts From b48f61debc0d0ae9a1bc3ff4ce5a705e9f047b53 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Tue, 23 Jul 2024 23:44:08 -0400 Subject: [PATCH 06/15] Fix FriendsSince Issue --- src/plugins/friendsSince/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/friendsSince/index.tsx b/src/plugins/friendsSince/index.tsx index 44be8927f81..717bd754ca7 100644 --- a/src/plugins/friendsSince/index.tsx +++ b/src/plugins/friendsSince/index.tsx @@ -52,7 +52,7 @@ export default definePlugin({ { find: ".PANEL}),nicknameIcons", replacement: { - match: /BOT_PROFILE_CREATED_ON,.{0,100}userId:(\i\.id)}\)}\)/, + match: /USER_PROFILE_MEMBER_SINCE,.{0,100}userId:(\i\.id)}\)}\)/, replace: "$&,$self.friendsSinceNew({userId:$1,isSidebar:true})" } }, From deaff9ea5c4edeba22b5f90e0ca8bc4a48b676a0 Mon Sep 17 00:00:00 2001 From: thororen <78185467+thororen1234@users.noreply.github.com> Date: Sun, 4 Aug 2024 03:16:10 -0400 Subject: [PATCH 07/15] Apply suggestions from code review Co-authored-by: v --- .../statusWhilePlaying.desktop/index.ts | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/plugins/statusWhilePlaying.desktop/index.ts b/src/plugins/statusWhilePlaying.desktop/index.ts index d4aa7c31e8f..36a048d329f 100644 --- a/src/plugins/statusWhilePlaying.desktop/index.ts +++ b/src/plugins/statusWhilePlaying.desktop/index.ts @@ -40,23 +40,19 @@ const settings = definePluginSettings({ export default definePlugin({ name: "StatusWhilePlaying", - description: "Automatically updates your status when playing games", + description: "Automatically updates your online status (online, idle, dnd) when launching games", authors: [Devs.thororen], settings, - runningGamesChange(event) { - let savedStatus = ""; - if (event.games.length > 0) { - const status = PresenceStore.getStatus(UserStore.getCurrentUser().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); + flux: { + RUNNING_GAMES_CHANGE(event) { + let savedStatus = ""; + if (event.games.length > 0) { + const status = PresenceStore.getStatus(UserStore.getCurrentUser().id); + savedStatus = status; + updateAsync(settings.store.statusToSet); + } else if (event.games.length === 0) { + updateAsync(savedStatus); + } + }, } }); From ed51198f27fde6a204a6f24c98aa9f32c71be639 Mon Sep 17 00:00:00 2001 From: thororen <78185467+thororen1234@users.noreply.github.com> Date: Sun, 4 Aug 2024 03:34:43 -0400 Subject: [PATCH 08/15] Remove savedStatus --- src/plugins/statusWhilePlaying.desktop/index.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/plugins/statusWhilePlaying.desktop/index.ts b/src/plugins/statusWhilePlaying.desktop/index.ts index 36a048d329f..8966599494b 100644 --- a/src/plugins/statusWhilePlaying.desktop/index.ts +++ b/src/plugins/statusWhilePlaying.desktop/index.ts @@ -45,13 +45,11 @@ export default definePlugin({ settings, flux: { RUNNING_GAMES_CHANGE(event) { - let savedStatus = ""; + const status = PresenceStore.getStatus(UserStore.getCurrentUser().id); if (event.games.length > 0) { - const status = PresenceStore.getStatus(UserStore.getCurrentUser().id); - savedStatus = status; updateAsync(settings.store.statusToSet); } else if (event.games.length === 0) { - updateAsync(savedStatus); + updateAsync(status); } }, } From a26d10edfc4070379e619688e9f70fc1fef5994f Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Sun, 4 Aug 2024 04:08:59 -0400 Subject: [PATCH 09/15] Correct Error I Made --- .../statusWhilePlaying.desktop/index.ts | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/plugins/statusWhilePlaying.desktop/index.ts b/src/plugins/statusWhilePlaying.desktop/index.ts index 8966599494b..c8c62bc5147 100644 --- a/src/plugins/statusWhilePlaying.desktop/index.ts +++ b/src/plugins/statusWhilePlaying.desktop/index.ts @@ -8,10 +8,10 @@ import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { findByCodeLazy } from "@webpack"; -import { FluxDispatcher, PresenceStore, UserStore } from "@webpack/common"; +import { PresenceStore, UserStore } from "@webpack/common"; +let savedStatus = ""; const updateAsync = findByCodeLazy("updateAsync", "status"); - const settings = definePluginSettings({ statusToSet: { type: OptionType.SELECT, @@ -29,10 +29,6 @@ const settings = definePluginSettings({ label: "Do Not Disturb", value: "dnd", default: true - }, - { - label: "Invisible", - value: "invisible", } ] } @@ -44,13 +40,18 @@ export default definePlugin({ authors: [Devs.thororen], settings, flux: { - RUNNING_GAMES_CHANGE(event) { - const status = PresenceStore.getStatus(UserStore.getCurrentUser().id); - if (event.games.length > 0) { - updateAsync(settings.store.statusToSet); - } else if (event.games.length === 0) { - updateAsync(status); - } - }, + RUNNING_GAMES_CHANGE(event) { + const status = PresenceStore.getStatus(UserStore.getCurrentUser().id); + if (status === "offline") return; + switch (event.games.length) { + case 0: + updateAsync(savedStatus); + break; + default: + savedStatus = status; + updateAsync(settings.store.statusToSet); + break; + } + }, } }); From 1a0d41a5bbf908e3a5f711abdcc2e157a5ba3086 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Sun, 4 Aug 2024 04:11:30 -0400 Subject: [PATCH 10/15] Readd Invisible --- src/plugins/statusWhilePlaying.desktop/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plugins/statusWhilePlaying.desktop/index.ts b/src/plugins/statusWhilePlaying.desktop/index.ts index c8c62bc5147..15681d2fa50 100644 --- a/src/plugins/statusWhilePlaying.desktop/index.ts +++ b/src/plugins/statusWhilePlaying.desktop/index.ts @@ -29,6 +29,10 @@ const settings = definePluginSettings({ label: "Do Not Disturb", value: "dnd", default: true + }, + { + label: "Invisible", + value: "invisible", } ] } @@ -42,7 +46,6 @@ export default definePlugin({ flux: { RUNNING_GAMES_CHANGE(event) { const status = PresenceStore.getStatus(UserStore.getCurrentUser().id); - if (status === "offline") return; switch (event.games.length) { case 0: updateAsync(savedStatus); From 88eb7832e407725bdd4cd6d4b114820808779144 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Sun, 4 Aug 2024 04:14:23 -0400 Subject: [PATCH 11/15] Added some checks --- src/plugins/statusWhilePlaying.desktop/index.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/plugins/statusWhilePlaying.desktop/index.ts b/src/plugins/statusWhilePlaying.desktop/index.ts index 15681d2fa50..5591376a82a 100644 --- a/src/plugins/statusWhilePlaying.desktop/index.ts +++ b/src/plugins/statusWhilePlaying.desktop/index.ts @@ -48,11 +48,14 @@ export default definePlugin({ const status = PresenceStore.getStatus(UserStore.getCurrentUser().id); switch (event.games.length) { case 0: - updateAsync(savedStatus); + if (savedStatus !== "" && savedStatus !== settings.store.statusToSet) + updateAsync(savedStatus); break; default: - savedStatus = status; - updateAsync(settings.store.statusToSet); + if (status !== settings.store.statusToSet) { + savedStatus = status; + updateAsync(settings.store.statusToSet); + } break; } }, From 29c3b3a60e61b3e51a863fa28288602ae4fa308d Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Sun, 4 Aug 2024 04:17:42 -0400 Subject: [PATCH 12/15] Final Fixes? --- .../statusWhilePlaying.desktop/index.ts | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/plugins/statusWhilePlaying.desktop/index.ts b/src/plugins/statusWhilePlaying.desktop/index.ts index 5591376a82a..038373eb9f1 100644 --- a/src/plugins/statusWhilePlaying.desktop/index.ts +++ b/src/plugins/statusWhilePlaying.desktop/index.ts @@ -46,17 +46,14 @@ export default definePlugin({ flux: { RUNNING_GAMES_CHANGE(event) { const status = PresenceStore.getStatus(UserStore.getCurrentUser().id); - switch (event.games.length) { - case 0: - if (savedStatus !== "" && savedStatus !== settings.store.statusToSet) - updateAsync(savedStatus); - break; - default: - if (status !== settings.store.statusToSet) { - savedStatus = status; - updateAsync(settings.store.statusToSet); - } - break; + if (event.games.length > 0) { + if (savedStatus !== "" && savedStatus !== settings.store.statusToSet) + updateAsync(savedStatus); + } else { + if (status !== settings.store.statusToSet) { + savedStatus = status; + updateAsync(settings.store.statusToSet); + } } }, } From 6b9ee06cf1da456fcacc87c5e6163371b2e334dd Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Sun, 4 Aug 2024 04:28:29 -0400 Subject: [PATCH 13/15] Update Readme --- src/plugins/statusWhilePlaying.desktop/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/statusWhilePlaying.desktop/README.md b/src/plugins/statusWhilePlaying.desktop/README.md index ee8079890de..b260f003172 100644 --- a/src/plugins/statusWhilePlaying.desktop/README.md +++ b/src/plugins/statusWhilePlaying.desktop/README.md @@ -1,5 +1,6 @@ # StatusWhilePlaying -This plugin automatically updates your status when playing games. +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. -It can set your status to any of the current statuses. It will revert your status back when the game is closed. From 51e8912e5a5e025d9f75e902ead4a022521c033f Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Sun, 4 Aug 2024 04:29:00 -0400 Subject: [PATCH 14/15] Remove Extra space --- src/plugins/statusWhilePlaying.desktop/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/statusWhilePlaying.desktop/README.md b/src/plugins/statusWhilePlaying.desktop/README.md index b260f003172..5e3abf28721 100644 --- a/src/plugins/statusWhilePlaying.desktop/README.md +++ b/src/plugins/statusWhilePlaying.desktop/README.md @@ -3,4 +3,3 @@ 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. - From f273f61e5ab5e5e544b0b0f6d83d7ea9c11b2e52 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Wed, 21 Aug 2024 21:40:40 -0400 Subject: [PATCH 15/15] Fix reversed updating --- src/plugins/statusWhilePlaying.desktop/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/statusWhilePlaying.desktop/index.ts b/src/plugins/statusWhilePlaying.desktop/index.ts index 038373eb9f1..0d1590448a9 100644 --- a/src/plugins/statusWhilePlaying.desktop/index.ts +++ b/src/plugins/statusWhilePlaying.desktop/index.ts @@ -47,13 +47,13 @@ export default definePlugin({ RUNNING_GAMES_CHANGE(event) { const status = PresenceStore.getStatus(UserStore.getCurrentUser().id); if (event.games.length > 0) { - if (savedStatus !== "" && savedStatus !== settings.store.statusToSet) - updateAsync(savedStatus); - } else { if (status !== settings.store.statusToSet) { savedStatus = status; updateAsync(settings.store.statusToSet); } + } else { + if (savedStatus !== "" && savedStatus !== settings.store.statusToSet) + updateAsync(savedStatus); } }, }