This commit is contained in:
Louis Mazin 2026-01-28 12:25:39 +01:00
parent a0db9ad2da
commit 33bcd082db

View File

@ -38,24 +38,10 @@ module.exports = {
const discordName = user ? (user.globalName ? user.globalName : user.username) : link.discord_username; const discordName = user ? (user.globalName ? user.globalName : user.username) : link.discord_username;
const discordMention = `<@${link.discord_id}>`; const discordMention = `<@${link.discord_id}>`;
// Calculer le temps depuis la dernière connexion // date de la dernière connexion formatée pour affichage discord
let lastConnectionText = ''; const lastConnectionText = link.last_palworld_connection
if (link.lastConnection) { ? `<t:${Math.floor(new Date(link.last_palworld_connection).getTime() / 1000)}:f>`
const lastConn = new Date(link.lastConnection); : 'Jamais connecté';
const now = new Date();
const diffMs = now - lastConn;
const diffMinutes = Math.floor(diffMs / 60000);
const diffHours = Math.floor(diffMs / 3600000);
const diffDays = Math.floor(diffMs / 86400000);
if (diffMinutes < 60) {
lastConnectionText = ` - ${diffMinutes}min ago`;
} else if (diffHours < 24) {
lastConnectionText = ` - ${diffHours}h ago`;
} else {
lastConnectionText = ` - ${diffDays}d ago`;
}
}
embed.addFields({ embed.addFields({
name: `👤 ${discordName} - 🎮 ${link.palworld_username} - ${lastConnectionText}`, name: `👤 ${discordName} - 🎮 ${link.palworld_username} - ${lastConnectionText}`,