import type { Message , TextChannel } from "eris" ; import { Command } from "../../classes/Command" ; export class SnipeCommand extends Command { description = "Sends the latest deleted message in a channel." ; async run ( msg ) { const guildconfig = await this . bot . db . getGuildConfig ( msg . channel . guild . id ) ; if ( guildconfig ?. snipingEnable === false ) { return msg . createEmbed ( msg . string ( "global.ERROR" ) , msg . string ( "moderation.SNIPE_NOTENABLED" ) , "error" ) ; } const isNotStaff = ! msg . member ?. permissions ?. has ( "manageMessages" ) || ( guildconfig ?. staffRole && ! msg . member ?. roles ?. includes ( guildconfig . staffRole ) ) ; if ( guildconfig ?. snipingPermission === false && isNotStaff ) { return msg . createEmbed ( msg . string ( "global.ERROR" ) , msg . string ( "moderation.SNIPE_NOPERMS" ) , "error" ) ; } const snipeMessage = this . bot . snipeData [ msg . channel . id ] ; if ( ! snipeMessage ) return msg . createEmbed ( msg . string ( "global.ERROR" ) , msg . string ( "moderation.SNIPE_NODATA" ) , "error" ) ; msg . channel . createMessage ( { embed : { description : `${ snipeMessage . content }` || "" , color : msg . convertHex ( "general" ) , timestamp : new Date ( snipeMessage . timestamp || Date . now ( ) ) , author : { name : snipeMessage . author ? ` ${ msg . string ( "global.MEMBER_SAID" , { member : snipeMessage . author } ) }` : "" , icon_url : snipeMessage . authorpfp || "" , } , image : { url : snipeMessage . attachment || "" , } , } , } ) ; } }