From a9d756f0a211b19995d5cba52c32cbc55d742693 Mon Sep 17 00:00:00 2001 From: kmmiio99o <164557248+kmmiio99o@users.noreply.github.com> Date: Sat, 31 Jan 2026 17:15:40 +0100 Subject: [PATCH] fix(plugins/multi-scrobbler/src/utils/activity.ts): fix activity sometimes disappearing without word, or not showing at all --- plugins/multi-scrobbler/src/utils/activity.ts | 47 ++++--------------- 1 file changed, 8 insertions(+), 39 deletions(-) diff --git a/plugins/multi-scrobbler/src/utils/activity.ts b/plugins/multi-scrobbler/src/utils/activity.ts index 518ff18..24cb2cb 100644 --- a/plugins/multi-scrobbler/src/utils/activity.ts +++ b/plugins/multi-scrobbler/src/utils/activity.ts @@ -6,70 +6,39 @@ import Constants from "../constants"; import { stop } from "../manager"; import { AssetManager } from "../modules"; -const log = (...args: any[]) => console.log("[Activity]", ...args); -const logError = (...args: any[]) => - console.error("[Activity] Error:", ...args); -const logVerbose = (...args: any[]) => { - // just log everything for now since checking the setting is tricky here - try { - console.log("[Activity] Verbose:", ...args); - } catch { - console.log("[Activity] Verbose:", ...args); - } -}; - -// Remove Discord activity +/** Clears the user's activity */ export function clearActivity() { - log("Clearing Discord activity"); return sendRequest(null); } -// Send activity to Discord or clear it +/** Sends the activity details to Discord */ export function sendRequest(activity: Activity | null) { if (pluginState.pluginStopped) { - logVerbose("Plugin is stopped, clearing activity"); stop(); activity = null; } pluginState.lastActivity = activity; - logVerbose( - "Dispatching activity update:", - activity ? "Setting activity" : "Clearing activity", - ); - FluxDispatcher.dispatch({ type: "LOCAL_ACTIVITY_UPDATE", activity: activity, pid: 2312, - socketId: "Multi-Service-Scrobbler@Vendetta", + socketId: "Multi-Scrobbler@Vendetta", }); - - if (activity) { - log(`Activity set: ${activity.details} - ${activity.state}`); - } else { - log("Activity cleared"); - } } -// Get Discord asset for album art +/** Fetches Discord application assets */ export async function fetchAsset( asset: string[], appId: string = Constants.APPLICATION_ID, ): Promise { - if (!asset?.length) { - logVerbose("No assets to fetch"); - return []; - } + if (!asset?.length) return []; try { - logVerbose(`Fetching ${asset.length} asset(s):`, asset); - const result = await AssetManager.fetchAssetIds(appId, asset); - logVerbose(`Successfully fetched ${result.length} asset(s)`); - return result; + return await AssetManager.fetchAssetIds(appId, asset); } catch (error) { - logError("Failed to fetch assets:", error); + console.error("[Multi-Scrobbler] Failed to fetch assets:", error); return []; } -} +} \ No newline at end of file