import Constants from '../../common/constants' ; import { Plugin } from '../../common/plugin' ; import { IContainer , IMessage , ChannelType } from '../../common/types' ; export default class DmReportPlugin extends Plugin { public commandName : string = 'anonreport' ; public name : string = 'anonreport' ; public description : string = 'anonymously report a concern to moderation team' ; public usage : string = 'anonreport <message> <...screenshot>' ; public override pluginAlias = [ ] ; public permission : ChannelType = ChannelType . Staff ; public override pluginChannelName : string = Constants . Channels . Staff . ModCommands ; public override usableInDM = true ; public override usableInGuild = true ; constructor ( public container ) { super ( ) ; } public override validate ( _message , args ) { return ! ! args . length ; } public async execute ( message , args ) { const maybe_ticket_id = args [ 0 ] ; const isTicketId = this . container . modService . isTicketId ( maybe_ticket_id ) ; if ( ! isTicketId && ! message . guild ) { await this . container . modService . fileAnonReport ( message ) . then ( ( ticket_id ) => message . reply ( 'Thank you, your report has been recorded.\n' + `Staff may update you through Ticket \`${ ticket_id }\`.\n` + `Also, you can add to this report with \`!${ this . name } ${ ticket_id } ...\` in this DM.` ) ) . catch ( ( e ) => this . container . loggerService . error ( e ) ) ; return ; } if ( ! isTicketId ) { await message . reply ( `Please provide a ticket id to respond within a guild. Ex. \`!${ this . name } ${ this . container . modService . generateTicketId ( message ) } ...\`` ) ; return ; } const handleTicket = async ( ) => { return await ( message . guild ? this . container . modService . respondToAnonReport ( maybe_ticket_id , message ) : this . container . modService . fileAnonReportWithTicketId ( maybe_ticket_id , message ) ) ; } ; await handleTicket ( ) . then ( ( ticket_id ) => message . reply ( `Thank you. The update for Ticket ${ ticket_id } was processed.` ) ) ; } }