5180 fichiers 38.5 Mo 0 téléchargements 296 vues mis à jour il y a 6 heures ui
export interface BanInfo {
    type: 'account' | 'ip' | 'machine' | 'super' | string;
    reason: string;
    permanent: boolean;
    expiresAt?: number;
}

export const parseBan = (payload: Record<string, unknown>): BanInfo | null => {
    const raw = payload?.ban;
    if (!raw || typeof raw !== 'object') return null;
    const ban = raw as Record<string, unknown>;
    const type = typeof ban.type === 'string' ? ban.type : 'account';
    const reason = typeof ban.reason === 'string' ? ban.reason : '';
    const permanent = ban.permanent === true || ban.permanent === 'true';
    const expiresAt = typeof ban.expiresAt === 'number' ? ban.expiresAt : undefined;
    return { type, reason, permanent, expiresAt };
};

export const formatRemaining = (epochSeconds: number): string => {
    const totalSeconds = Math.max(0, epochSeconds - Math.floor(Date.now() / 1000));
    const days = Math.floor(totalSeconds / 86400);
    const hours = Math.floor((totalSeconds % 86400) / 3600);
    const minutes = Math.floor((totalSeconds % 3600) / 60);
    const seconds = totalSeconds % 60;
    if (days > 0) return `${days}d ${hours}h ${minutes}m`;
    if (hours > 0) return `${hours}h ${minutes}m`;
    if (minutes > 0) return `${minutes}m ${seconds}s`;
    return `${seconds}s`;
};
15Sujets
1Dépôts
20Membres
2En ligne
Profile
Inscrit
Dernière visite
Messages
0
Votes positifs
0
Votes négatifs
0

Nous utilisons des cookies pour assurer le bon fonctionnement du site et améliorer votre expérience. en savoir plus

Autoriser