anonradio: use timeout instead of interval

This commit is contained in:
Cynthia Foxwell 2022-12-21 08:58:57 -07:00
parent a430d0d1ed
commit 4fe3512b2b

View file

@ -4,6 +4,10 @@ const GUILD_ID = "300436792916836352";
const THREAD_ID = "1054106209273253888"; const THREAD_ID = "1054106209273253888";
const MESSAGE_ID = "1054109813132509245"; const MESSAGE_ID = "1054109813132509245";
if (hf.__anonradio_timeout) {
clearTimeout(hf.__anonradio_timeout);
}
async function updateNowPlaying() { async function updateNowPlaying() {
let playing; let playing;
try { try {
@ -105,9 +109,12 @@ async function updateNowPlaying() {
await thread.editMessage(MESSAGE_ID, {content}); await thread.editMessage(MESSAGE_ID, {content});
} }
} }
}
hf.timer.add( hf.__anonradio_timeout = setTimeout(updateNowPlaying, 2000);
}
updateNowPlaying();
/*hf.timer.add(
"anonradio", "anonradio",
async () => { async () => {
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
@ -116,4 +123,4 @@ hf.timer.add(
}).catch(() => {}); }).catch(() => {});
}, },
2000 2000
); );*/