anonradio: reduce edit spam on openmic
This commit is contained in:
parent
5b04ce97a9
commit
370f6a882a
1 changed files with 13 additions and 9 deletions
|
@ -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 <t:${Math.round(
|
||||
startTime / 1000
|
||||
)}:R> -\\*-\n`;
|
||||
}
|
||||
} catch (err) {
|
||||
//
|
||||
|
@ -115,9 +117,11 @@ async function updateNowPlaying() {
|
|||
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(/<t:\d+:T>/,"").trim();
|
||||
const oldContent = msg.content.replace(/<t:\d+:T>\n/, "").trim();
|
||||
if (oldContent !== content) {
|
||||
await thread.editMessage(MESSAGE_ID, {content: timestamp + "\n" + content});
|
||||
await thread.editMessage(MESSAGE_ID, {
|
||||
content: timestamp + "\n" + content,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue