diff --git a/bot.ts b/bot.ts index 38f4bfa..8438c69 100644 --- a/bot.ts +++ b/bot.ts @@ -14,6 +14,7 @@ import * as schedule from 'node-schedule'; dotenv.config(); +export var nextPlayBackTime: string = ''; const minTime = parseInt(process.env.INTERVALMIN_MINUTES!, 10); // Minimum interval in minutes const maxTime = convertHoursToMinutes(parseInt(process.env.INTERVALMAX_HOURS!, 10)); // Maximum interval in minutes const voiceChannelRetries = parseInt(process.env.VOICECHANNELRETRIES!, 10); // Number of retries to find a voice channel with members in it @@ -113,6 +114,8 @@ function scheduleNextJoin(){ log(randomInterval); + nextPlayBackTime = new Date(new Date().getTime() + randomInterval * 60000).toLocaleTimeString(); + const minutes = randomInterval % 60; const hours = Math.floor(randomInterval / 60); @@ -130,6 +133,7 @@ function log(waitTime: number){ const nextJoinTime = new Date(currentTime.getTime() + waitTime * 60000); const minutes = waitTime % 60; const hours = Math.floor(waitTime / 60); + console.log( LoggerColors.Cyan, ` Wait time: ${waitTime} minutes, diff --git a/client/web/client.js b/client/web/client.js index 9347f11..dccb80f 100644 --- a/client/web/client.js +++ b/client/web/client.js @@ -1,3 +1,14 @@ +function loadNextPlaybackTime() { + fetch('/nextplaybacktime') + .then(response => response.text()) + .then(data => { + const nextPlaybackTime = document.getElementById('nextPlaybackTime'); + nextPlaybackTime.textContent = `Playing next time: ${data}`; + } + ) + .catch(error => console.error('Error:', error)); +} + function loadFiles() { // Fetch the JSON data from the /sounds endpoint fetch('/sounds') @@ -51,6 +62,7 @@ function loadFiles() { // Call loadFiles when the script is loaded loadFiles(); +loadNextPlaybackTime(); document.getElementById('uploadForm').addEventListener('submit', function(event) { event.preventDefault(); diff --git a/client/web/index.html b/client/web/index.html index 60a8383..d36c920 100644 --- a/client/web/index.html +++ b/client/web/index.html @@ -11,22 +11,32 @@