Update embedBuilders.js
match request update
This commit is contained in:
@@ -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();
|
||||
const now = new Date();
|
||||
|
||||
// Get the team size number and ensure it's not doubled
|
||||
const teamSize = matchData.team_size;
|
||||
// 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
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user