Skip to content

Commit

Permalink
fix instances where avatar is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
JABirchall committed May 19, 2019
1 parent c8f3db2 commit ad7eab2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Nimda/Core/Timers/SetPresence.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
namespace Nimda\Core\Timers;

use CharlotteDunois\Yasmin\Client;
use CharlotteDunois\Yasmin\Models\ClientUser;
use Doctrine\Instantiator\Exception\InvalidArgumentException;
use Nimda\Core\Timer;
use React\Promise\PromiseInterface;
use function React\Promise\reject;

class SetPresence extends Timer
{
Expand All @@ -13,8 +16,11 @@ class SetPresence extends Timer
*/
public function trigger(Client $client): PromiseInterface
{
return $client->user->setAvatar($this->config['avatar'])->then(function () use ($client) {
return $client->user->setPresence($this->config['presence']);
return $client->user->setPresence($this->config['presence'])->then(function (ClientUser $clientUser) {
if($this->config['avatar'] === '') {
return reject(new InvalidArgumentException('Avatar not set'));
}
return $clientUser->client->user->setAvatar($this->config['avatar']);
});
}
}

0 comments on commit ad7eab2

Please sign in to comment.