anonradio: attempt to reduce gradual edit spam

This commit is contained in:
Cynthia Foxwell 2022-12-19 10:33:17 -07:00
parent f77466831b
commit 0f3e029430
1 changed files with 15 additions and 4 deletions

View File

@ -99,10 +99,21 @@ async function updateNowPlaying() {
const content = `${title}\n${subtitle}\n${openmicTime}`.trim();
const thread = hf.bot.guilds.get(GUILD_ID).threads.get(THREAD_ID);
const msg = await thread.getMessage(MESSAGE_ID);
if (msg.content !== content) {
thread.editMessage(MESSAGE_ID, {content});
if (thread) {
const msg = await thread.getMessage(MESSAGE_ID);
if (msg.content !== content) {
await thread.editMessage(MESSAGE_ID, {content});
}
}
}
hf.timer.add("anonradio", updateNowPlaying, 2000);
hf.timer.add(
"anonradio",
async () => {
await new Promise((resolve, reject) => {
setTimeout(() => reject("timeout"), 1900);
updateNowPlaying().then(() => resolve(true));
}).catch(() => {});
},
2000
);