Update embedBuilders.js

match request update
This commit is contained in:
VinceC
2025-01-01 09:58:50 -06:00
parent 35e58972a8
commit 1ad3a11bd3

View File

@@ -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
},
{