From 327b92bbbf34bc6a0d1cd3545055838dea3fccd7 Mon Sep 17 00:00:00 2001 From: Faelayis <48393914+Faelayis@users.noreply.github.com> Date: Sat, 28 May 2022 21:06:18 +0700 Subject: [PATCH] Fix features show premid not working --- src/changelog.json | 5 +++++ src/index.js | 20 +++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/changelog.json b/src/changelog.json index f967c27..04ce90a 100644 --- a/src/changelog.json +++ b/src/changelog.json @@ -6,6 +6,11 @@ "type": "added", "items": ["Update channel pre release", "Features Optional show premid"] }, + { + "title": "Fixed", + "type": "fixed", + "items": ["Features show premid not working"] + }, { "title": "Improved", "type": "improved", diff --git a/src/index.js b/src/index.js index d87ded9..ef7e1b0 100644 --- a/src/index.js +++ b/src/index.js @@ -30,6 +30,11 @@ const changelog = { type: "added", items: ["Update channel pre release", "Features Optional show premid"], }, + { + title: "Fixed", + type: "fixed", + items: ["Features show premid not working"], + }, { title: "Improved", type: "improved", @@ -54,6 +59,7 @@ export default class Plugin { if (!this.settings.customstatus_hide) { this.settings.customstatus_hide = ["invisible"]; } + !this.settings.show_premid ? (this.settings.show_premid = true) : undefined; this.updateSettings(); } async connected() { @@ -172,12 +178,16 @@ export default class Plugin { if (this.settings.customstatus_hide?.includes(ZLibrary.DiscordModules.UserSettingsStore.status)) return this.client.setActivity(null); if (this.settings.automatically?.hide?.spotify && ZLibrary.DiscordModules.UserActivityStore.getActivity()?.name === "Spotify" ? true : false) return this.client.setActivity(null); - if ((this.settings.show_premid ?? true) && BdApi) { + if ( + this.settings.show_premid && + BdApi && BdApi.findModuleByProps("getActivities") .getActivities() - .find((data) => data === data.assets.large_text.includes("PreMiD")); - return; - } + .find((data) => data.assets?.large_text.match(/(PreMiD)/)) + ? true + : false + ) + return this.client.setActivity(null); const Presence = { details: `CPU ${(await currentLoad().then((data) => data.currentLoad.toFixed(0))) || "0"}%`, state: `RAM ${this.formatRAM(freemem(), totalmem())}`, @@ -468,7 +478,7 @@ export default class Plugin { }) .appendTo(panel) .append( - new ZLibrary.Settings.Switch("Show Premid", undefined, this.settings.show_premid || true, (value) => { + new ZLibrary.Settings.Switch("Show Premid", undefined, this.settings.show_premid, (value) => { this.settings.show_premid = value; }), new ZLibrary.Settings.RadioGroup(