From 370f6a882a7bf493eb516f1655b8a87fd9c4e026 Mon Sep 17 00:00:00 2001 From: Cynthia Date: Wed, 21 Dec 2022 20:13:34 -0700 Subject: [PATCH] anonradio: reduce edit spam on openmic --- src/modules/anonradio.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/modules/anonradio.js b/src/modules/anonradio.js index cd4a3d3..90fd5d0 100644 --- a/src/modules/anonradio.js +++ b/src/modules/anonradio.js @@ -1,5 +1,3 @@ -const {formatTime} = require("../lib/utils.js"); - const GUILD_ID = "300436792916836352"; const THREAD_ID = "1054106209273253888"; const MESSAGE_ID = "1054109813132509245"; @@ -98,10 +96,14 @@ async function updateNowPlaying() { ); if (streamData && streamData.stream_start_iso8601) { const startTime = new Date(streamData.stream_start_iso8601).getTime(); - title = `${streamData.title} (\`${streamData.server_name ? streamData.server_name + " | " + liveNow.id : liveNow.id}\`)`; - openmicTime = `-\\*- OpenMIC DJ has been streaming for ${formatTime( - Date.now() - startTime - )} -\\*-\n`; + title = `${streamData.title} (\`${ + streamData.server_name + ? streamData.server_name + " | " + liveNow.id + : liveNow.id + }\`)`; + openmicTime = `-\\*- OpenMIC DJ has been streaming since -\\*-\n`; } } catch (err) { // @@ -109,15 +111,17 @@ async function updateNowPlaying() { } const now = Date.now(); - const timestamp = ``; + const timestamp = ``; const content = `${title}\n${subtitle}\n${openmicTime}`.trim(); const thread = hf.bot.guilds.get(GUILD_ID)?.threads.get(THREAD_ID); if (thread) { const msg = await thread.getMessage(MESSAGE_ID); - const oldContent = msg.content.replace(//,"").trim(); + const oldContent = msg.content.replace(/\n/, "").trim(); if (oldContent !== content) { - await thread.editMessage(MESSAGE_ID, {content: timestamp + "\n" + content}); + await thread.editMessage(MESSAGE_ID, { + content: timestamp + "\n" + content, + }); } }