import { userMention } from '@discordjs/builders' ; export function truncate ( text , len , splitChar = ' ' ) { if ( text . length <= len ) return text ; const words = text . split ( splitChar ) ; const res = [ ] ; for ( const word of words ) { const full = res . join ( splitChar ) ; if ( full . length + word . length + 1 <= len - 3 ) { res . push ( word ) ; } } const resText = res . join ( splitChar ) ; return resText . length === text . length ? resText : `${ resText . trim ( ) }...` ; } export function suggestionString ( suggestionType , guaranteed ? , author ? , target ? ) { const messageParts = [ ] ; const [ first , ... rest ] = suggestionType ; if ( author || target ) { messageParts . push ( `*${ first . toUpperCase ( ) }${ rest . join ( '' ) } suggestion` ) ; if ( target ) { messageParts . push ( ` for ${ userMention ( target ) }` ) ; } if ( author ) { messageParts . push ( ` from ${ userMention ( author ) }` ) ; } messageParts . push ( ':*\n' ) ; } if ( guaranteed ) { messageParts . push ( guaranteed ) ; } return messageParts . join ( '' ) ; }