protected function respond(string $type, string $content, array $options = array(), bool $fromEdit = false) {
        if($type === 'reply' && $this->message->channel instanceof \CharlotteDunois\Yasmin\Interfaces\DMChannelInterface) {
            $type = 'plain';
        }
        
        if($type !== 'direct' && $this->message->guild !== null && !$this->message->channel->permissionsFor($this->client->user)->has('SEND_MESSAGES')) {
            $type = 'direct';
        }
        
        if(!empty($options['split']) && !\is_array($options['split'])) {
            $options['split'] = array();
        }
        
        $channelID = $this->getChannelIDOrDM($this->message->channel);
        $shouldEdit = (
            !empty($this->responses) &&
            (
                ($type === 'direct' && !empty($this->responses['dm'])) ||
                ($type !== 'direct' && !empty($this->responses[$channelID]))
            ) &&
            !$fromEdit &&
            empty($options['files'])
        );
        
        switch($type) {
            case 'plain':
                if($shouldEdit) {
                    return $this->editCurrentResponse($channelID, $type, $content, $options);
                } else {
                    return $this->message->channel->send($content, $options);
                }
            break;
            case 'reply':
                if($shouldEdit) {
                    return $this->editCurrentResponse($channelID, $type, $content, $options);
                } else {
                    if(!empty($options['split']) && empty($options['split']['prepend'])) {
                        $options['split']['prepend'] = $this->message->author->__toString().\CharlotteDunois\Yasmin\Models\Message::$replySeparator;
                    }
                    
                    return $this->message->reply($content, $options);
                }
            break;
            case 'direct':
                if($shouldEdit) {
                    return $this->editCurrentResponse($channelID, $type, $content, $options);
                } else {
                    return $this->message->author->createDM()->then(function ($channel) use ($content, $options) {
                        return $channel->send($content, $options);
                    });
                }
            break;
            default:
                throw new \RangeException('Unknown response type "'.$type.'"');
            break;
        }
    }
protected function respond(string $type, string $content, array $options = array(), bool $fromEdit = false) {
        if($type === 'reply' && $this->message->channel instanceof \CharlotteDunois\Yasmin\Interfaces\DMChannelInterface) {
            $type = 'plain';
        }
        
        if($type !== 'direct' && $this->message->guild !== null && !$this->message->channel->permissionsFor($this->client->user)->has('SEND_MESSAGES')) {
            $type = 'direct';
        }
        
        if(!empty($options['split']) && !\is_array($options['split'])) {
            $options['split'] = array();
        }
        
        $channelID = $this->getChannelIDOrDM($this->message->channel);
        $shouldEdit = (
            !empty($this->responses) &&
            (
                ($type === 'direct' && !empty($this->responses['dm'])) ||
                ($type !== 'direct' && !empty($this->responses[$channelID]))
            ) &&
            !$fromEdit &&
            empty($options['files'])
        );
        
        switch($type) {
            case 'plain':
                if($shouldEdit) {
                    return $this->editCurrentResponse($channelID, $type, $content, $options);
                } else {
                    return $this->message->channel->send($content, $options);
                }
            break;
            case 'reply':
                if($shouldEdit) {
                    return $this->editCurrentResponse($channelID, $type, $content, $options);
                } else {
                    if(!empty($options['split']) && empty($options['split']['prepend'])) {
                        $options['split']['prepend'] = $this->message->author->__toString().\CharlotteDunois\Yasmin\Models\Message::$replySeparator;
                    }
                    
                    return $this->message->reply($content, $options);
                }
            break;
            case 'direct':
                if($shouldEdit) {
                    return $this->editCurrentResponse($channelID, $type, $content, $options);
                } else {
                    return $this->message->author->createDM()->then(function ($channel) use ($content, $options) {
                        return $channel->send($content, $options);
                    });
                }
            break;
            default:
                throw new \RangeException('Unknown response type "'.$type.'"');
            break;
        }
    }
protected function respond ( string $ type , string $ content , array $ options = array ( ) , bool $ fromEdit = false ) { if ( $ type === 'reply' && $ this -> message -> channel instanceof \ CharlotteDunois \ Yasmin \ Interfaces \ DMChannelInterface ) { $ type = 'plain' ; } if ( $ type !== 'direct' && $ this -> message -> guild !== null && ! $ this -> message -> channel -> permissionsFor ( $ this -> client -> user ) -> has ( 'SEND_MESSAGES' ) ) { $ type = 'direct' ; } if ( ! empty ( $ options [ 'split' ] ) && ! \ is_array ( $ options [ 'split' ] ) ) { $ options [ 'split' ] = array ( ) ; } $ channelID = $ this -> getChannelIDOrDM ( $ this -> message -> channel ) ; $ shouldEdit = ( ! empty ( $ this -> responses ) && ( ( $ type === 'direct' && ! empty ( $ this -> responses [ 'dm' ] ) ) || ( $ type !== 'direct' && ! empty ( $ this -> responses [ $ channelID ] ) ) ) && ! $ fromEdit && empty ( $ options [ 'files' ] ) ) ; switch ( $ type ) { case 'plain' : if ( $ shouldEdit ) { return $ this -> editCurrentResponse ( $ channelID , $ type , $ content , $ options ) ; } else { return $ this -> message -> channel -> send ( $ content , $ options ) ; } break ; case 'reply' : if ( $ shouldEdit ) { return $ this -> editCurrentResponse ( $ channelID , $ type , $ content , $ options ) ; } else { if ( ! empty ( $ options [ 'split' ] ) && empty ( $ options [ 'split' ] [ 'prepend' ] ) ) { $ options [ 'split' ] [ 'prepend' ] = $ this -> message -> author -> __toString ( ) . \ CharlotteDunois \ Yasmin \ Models \ Message :: $ replySeparator ; } return $ this -> message -> reply ( $ content , $ options ) ; } break ; case 'direct' : if ( $ shouldEdit ) { return $ this -> editCurrentResponse ( $ channelID , $ type , $ content , $ options ) ; } else { return $ this -> message -> author -> createDM ( ) -> then ( function ( $ channel ) use ( $ content , $ options ) { return $ channel -> send ( $ content , $ options ) ; } ) ; } break ; default : throw new \ RangeException ( 'Unknown response type "' . $ type . '"' ) ; break ; } }
Responds to the command message
@param string  $type      One of plain, reply or direct.
@param string  $content
@param array   $options
@param bool    $fromEdit
@return \React\Promise\ExtendedPromiseInterface
@throws \RangeException
@throws \InvalidArgumentException
Responds to the command message