import { Command , CommandClient , Structures } from 'detritus-client' ; import { Markup } from 'detritus-client/lib/utils' ; import { editGuildSettings } from '../../../api' ; import { CommandTypes } from '../../../constants' ; import { DefaultParameters , Parameters , editOrReply } from '../../../utils' ; import { BaseCommand } from '../basecommand' ; export interface CommandArgsBefore { guild : Structures . Guild | null ; } export interface CommandArgs { guild : Structures . Guild ; } export const COMMAND_NAME = 'owner unblock guild' ; export default class OwnerBlockGuildCommand extends BaseCommand { constructor ( client ) { super ( client , { name : COMMAND_NAME , default : DefaultParameters . guild , label : 'guild' , metadata : { description : 'Unblock a guild from the bot' , examples : [ `${ COMMAND_NAME } 178313653177548800` , ] , type : CommandTypes . OWNER , usage : '<guild:id>' , } , type : Parameters . guild , } ) ; } onBefore ( context ) { return context . user . isClientOwner ; } onBeforeRun ( context , args ) { return ! ! args . guild ; } onCancelRun ( context , args ) { if ( ! args . guild ) { return editOrReply ( context , '⚠ Unable to find that guild.' ) ; } return super . onCancelRun ( context , args ) ; } async run ( context , args ) { const { guild } = args ; const settings = await editGuildSettings ( context , guild . id , { blocked : false } ) ; return editOrReply ( context , `Alright, unblocked guild ${ Markup . escape . all ( guild . name ) } (${ guild . id })}.` ) ; } }