public function sendFile($filepath, $filename = null, $content = null, $tts = false)
    {
        $deferred = new Deferred();

        if ($this->getChannelType() != self::TYPE_TEXT) {
            $deferred->reject(new \Exception('You cannot send a file to a voice channel.'));

            return $deferred->promise();
        }

        if (! file_exists($filepath)) {
            $deferred->reject(new FileNotFoundException("File does not exist at path {$filepath}."));

            return $deferred->promise();
        }

        if (is_null($filename)) {
            $filename = basename($filepath);
        }

        $this->http->sendFile($this, $filepath, $filename, $content, $tts)->then(
            function ($response) use ($deferred) {
                $message = $this->factory->create(Message::class, $response, true);
                $this->messages->push($message);

                $deferred->resolve($message);
            },
            \React\Partial\bind_right($this->reject, $deferred)
        );

        return $deferred->promise();
    }
public function sendFile($filepath, $filename = null, $content = null, $tts = false)
    {
        $deferred = new Deferred();

        if ($this->getChannelType() != self::TYPE_TEXT) {
            $deferred->reject(new \Exception('You cannot send a file to a voice channel.'));

            return $deferred->promise();
        }

        if (! file_exists($filepath)) {
            $deferred->reject(new FileNotFoundException("File does not exist at path {$filepath}."));

            return $deferred->promise();
        }

        if (is_null($filename)) {
            $filename = basename($filepath);
        }

        $this->http->sendFile($this, $filepath, $filename, $content, $tts)->then(
            function ($response) use ($deferred) {
                $message = $this->factory->create(Message::class, $response, true);
                $this->messages->push($message);

                $deferred->resolve($message);
            },
            \React\Partial\bind_right($this->reject, $deferred)
        );

        return $deferred->promise();
    }
public function sendFile ( $ filepath , $ filename = null , $ content = null , $ tts = false ) { $ deferred = new Deferred ( ) ; if ( $ this -> getChannelType ( ) != self :: TYPE_TEXT ) { $ deferred -> reject ( new \ Exception ( 'You cannot send a file to a voice channel.' ) ) ; return $ deferred -> promise ( ) ; } if ( ! file_exists ( $ filepath ) ) { $ deferred -> reject ( new FileNotFoundException ( "File does not exist at path {$filepath}." ) ) ; return $ deferred -> promise ( ) ; } if ( is_null ( $ filename ) ) { $ filename = basename ( $ filepath ) ; } $ this -> http -> sendFile ( $ this , $ filepath , $ filename , $ content , $ tts ) -> then ( function ( $ response ) use ( $ deferred ) { $ message = $ this -> factory -> create ( Message :: class , $ response , true ) ; $ this -> messages -> push ( $ message ) ; $ deferred -> resolve ( $ message ) ; } , \ React \ Partial \ bind_right ( $ this -> reject , $ deferred ) ) ; return $ deferred -> promise ( ) ; }
Sends a file to the channel if it is a text channel.

@param string $filepath The path to the file to be sent.
@param string $filename The name to send the file as.
@param string $content  Message content to send with the file.
@param bool   $tts      Whether to send the message with TTS.

@return \React\Promise\Promise
Sends a file to the channel if it is a text channel .