From 1ad3a11bd3743fa40e03814afeb0a571bdc47014 Mon Sep 17 00:00:00 2001 From: VinceC <33974776+VinceC3@users.noreply.github.com> Date: Wed, 1 Jan 2025 09:58:50 -0600 Subject: [PATCH] Update embedBuilders.js match request update --- src/utils/embedBuilders.js | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/src/utils/embedBuilders.js b/src/utils/embedBuilders.js index aec8efd..3eb0b3e 100644 --- a/src/utils/embedBuilders.js +++ b/src/utils/embedBuilders.js @@ -149,19 +149,36 @@ class EmbedBuilders { static createMatchRequestEmbed(matchData) { // Parse the match date from the provided format const matchDateTime = new Date(matchData.match_date); - const formattedDateTime = matchDateTime.toLocaleString(); - - // Get the team size number and ensure it's not doubled - const teamSize = matchData.team_size; + const now = new Date(); + + // Calculate time difference in minutes + const timeDiffMinutes = Math.floor((matchDateTime - now) / (1000 * 60)); + + // Format the time until match + let timeUntilMatch; + if (timeDiffMinutes < 0) { + timeUntilMatch = 'Match has already started'; + } else if (timeDiffMinutes < 60) { + timeUntilMatch = `${timeDiffMinutes} minutes`; + } else { + const hours = Math.floor(timeDiffMinutes / 60); + const minutes = timeDiffMinutes % 60; + timeUntilMatch = `${hours} hour${hours !== 1 ? 's' : ''} ${minutes} minute${minutes !== 1 ? 's' : ''}`; + } return new EmbedBuilder() - .setColor('#00ff00') // Green for new match requests + .setColor('#00ff00') .setTitle(`🎮 New ${matchData.game_name} Match`) - .setDescription(`${teamSize} Match in ${matchData.region} Region`) + .setDescription(`${matchData.team_size} Match in ${matchData.region} Region`) .addFields( { - name: '⏰ Starting', - value: formattedDateTime, + name: '⏰ Match Time (UTC)', + value: matchDateTime.toUTCString(), + inline: true + }, + { + name: '⏳ Time Until Match', + value: timeUntilMatch, inline: true }, {