From 4fe3512b2b6cdfda371a690bb22ee365fbdea34b Mon Sep 17 00:00:00 2001 From: Cynthia Date: Wed, 21 Dec 2022 08:58:57 -0700 Subject: [PATCH] anonradio: use timeout instead of interval --- src/modules/anonradio.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/modules/anonradio.js b/src/modules/anonradio.js index fc0673a..4980ea1 100644 --- a/src/modules/anonradio.js +++ b/src/modules/anonradio.js @@ -4,6 +4,10 @@ const GUILD_ID = "300436792916836352"; const THREAD_ID = "1054106209273253888"; const MESSAGE_ID = "1054109813132509245"; +if (hf.__anonradio_timeout) { + clearTimeout(hf.__anonradio_timeout); +} + async function updateNowPlaying() { let playing; try { @@ -105,9 +109,12 @@ async function updateNowPlaying() { await thread.editMessage(MESSAGE_ID, {content}); } } -} -hf.timer.add( + hf.__anonradio_timeout = setTimeout(updateNowPlaying, 2000); +} +updateNowPlaying(); + +/*hf.timer.add( "anonradio", async () => { await new Promise((resolve, reject) => { @@ -116,4 +123,4 @@ hf.timer.add( }).catch(() => {}); }, 2000 -); +);*/