file description module import type { Message } from "eris" ; import config from "../../config.json" ; export async function createEmbed ( this , title , desc ? , colortype ? ) { if ( this && ! this . channel ) return ; let embedTitle ; let embedDescription ; let embedFieldColor ; const embedFooter = { text : "" , icon_url : "" , } ; if ( title ) embedTitle = title . length > 250 ? `${ title . substring ( 0 , 250 ) }...` : title ; if ( desc ) embedDescription = desc . length > 2000 ? `${ desc . substring ( 0 , 2000 ) }...` : desc ; if ( typeof this === "object" && this . author ) { embedFooter . text = `${ this . string ( "global.RAN_BY" , { author : this . tagUser ( this . author ) } ) }` ; embedFooter . icon_url = this . author . dynamicAvatarURL ( ) ; } if ( colortype ) embedFieldColor = convertHex ( colortype ) ; else embedFieldColor = convertHex ( "general" ) ; const embedConstruct = { embed : { title : embedTitle , description : embedDescription , color : embedFieldColor , footer : embedFooter , } , } ; return this . channel . createMessage ( embedConstruct ) ; } export async function editEmbed ( this , title , desc ? , colortype ? ) { if ( ! this ) throw new Error ( "No message object was provided" ) ; if ( this && ! this . channel ) return ; let embedTitle ; let embedDescription ; let embedFooter ; let embedFieldColor ; if ( title ) embedTitle = title . length > 250 ? `${ title . substring ( 0 , 250 ) }...` : title ; if ( desc ) embedDescription = desc . length > 2000 ? `${ desc . substring ( 0 , 2000 ) }...` : desc ; if ( colortype ) embedFieldColor = convertHex ( colortype ) ; else embedFieldColor = convertHex ( "general" ) ; if ( this && this . embeds [ 0 ] . footer ) { embedFooter = this . embeds [ 0 ] . footer ; } const embedConstruct = { embed : { title : embedTitle , description : embedDescription , color : embedFieldColor , footer : embedFooter , } , } ; return this . edit ( embedConstruct ) ; } export function convertHex ( colortype ) { return parseInt ( config . colors [ colortype ] . replace ( /#/g , "0x" ) ) ; }