import { Guild } from 'discord.js' ; import { Duration } from 'luxon' ; import { LangCode , Language } from '../models/enums' ; export class FormatUtils { public static roleMention ( guild , discordId ) { if ( discordId === '@here' ) { return discordId ; } if ( discordId === guild . id ) { return '@everyone' ; } return `<@&${ discordId }>` ; } public static channelMention ( discordId ) { return `<#${ discordId }>` ; } public static userMention ( discordId ) { return `<@!${ discordId }>` ; } public static duration ( milliseconds , langCode ) { return Duration . fromObject ( Object . fromEntries ( Object . entries ( Duration . fromMillis ( milliseconds , { locale : Language . locale ( langCode ) } ) . shiftTo ( 'year' , 'quarter' , 'month' , 'week' , 'day' , 'hour' , 'minute' , 'second' ) . toObject ( ) ) . filter ( ( [ _ , value ] ) => ! ! value ) ) ) . toHuman ( { maximumFractionDigits : 0 } ) ; } }