import type { EmbedField , Member , Message , TextChannel } from "eris" ; import { Command } from "../../classes/Command" ; import { generateSnowflake } from "../../utils/snowflake" ; export class AddpointCommand extends Command { description = "Gives a member a reputation point." ; requiredperms = [ "manageMessages" ] ; args = "<member:member&strict> [reason:string]" ; aliases = [ "addmerit" , "addrep" , "addreputation" , "merit" ] ; staff = true ; async run ( msg , pargs , args ) { const id = generateSnowflake ( ) ; const member = pargs [ 0 ] . value as Member ; let reason = args . slice ( 1 ) . join ( " " ) ; if ( reason . length > 512 ) reason = reason . slice ( 0 , 512 ) ; await this . bot . db . insertUserPoint ( { id : id , receiver : member . id , giver : msg . author . id , guild : msg . channel . guild . id , reason : reason || null , } ) ; this . bot . emit ( "reputationPointAdd" , msg . channel . guild , member . user , msg . author , reason , id ) ; const points = await this . bot . db . getAllUserGuildPoints ( member . id , msg . channel . guild . id ) ; const fields = [ ] ; fields . push ( { name : msg . string ( "global.ID" ) , value : `${ id }` , inline : true , } ) ; if ( points . length > 1 ) { fields . push ( { name : msg . string ( "moderation.POINT_TOTAL" ) , value : `${ points . length }` , inline : true , } ) ; } if ( reason ) { fields . push ( { name : msg . string ( "global.REASON" ) , value : `${ reason }` , } ) ; } msg . channel . createMessage ( { embed : { title : msg . string ( "global.SUCCESS" ) , description : msg . string ( "moderation.POINT_ADDED" , { member : member . user . username } ) , color : msg . convertHex ( "success" ) , fields : fields , footer : { text : msg . string ( "global.RAN_BY" , { author : msg . tagUser ( msg . author ) } ) , icon_url : msg . author . dynamicAvatarURL ( ) , } , } , } ) ; } }