Skip to content

Commit 71b7cd0

Browse files
authored
Fix items in Guild::MessageRepository (#1390)
1 parent fd3aabb commit 71b7cd0

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Discord/Repository/Guild/MessageRepository.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use Discord\Repository\AbstractRepository;
2020
use React\Promise\PromiseInterface;
2121

22-
use function React\Promise\resolve;
22+
use function React\Promise\reject;
2323

2424
/**
2525
* Used only to search messages sent in a guild.
@@ -97,7 +97,7 @@ class MessageRepository extends AbstractRepository
9797
public function freshen(array $queryparams = []): PromiseInterface
9898
{
9999
if (empty($queryparams)) {
100-
return resolve($this);
100+
return reject(new \InvalidArgumentException('Query parameters are required.'));
101101
}
102102

103103
$endpoint = new Endpoint($this->endpoints['all']);
@@ -109,7 +109,9 @@ public function freshen(array $queryparams = []): PromiseInterface
109109

110110
return $this->http->get($endpoint)->then(function ($response) {
111111
$part = $this->factory->create($this->class, (array) $response, true);
112-
return $this->cacheFreshen($part);
112+
$promise = $this->cacheFreshen($part);
113+
$this->discord->emit('GuildSearch', [$part]);
114+
return $promise;
113115
});
114116
}
115117

@@ -120,6 +122,6 @@ public function freshen(array $queryparams = []): PromiseInterface
120122
*/
121123
protected function cacheFreshen($response): PromiseInterface
122124
{
123-
return $this->cache->set($response->{$this->discrim}, (array) $response)->then(fn ($success) => $this);
125+
return $this->cache->set($response->{$this->discrim}, $response)->then(fn ($success) => $this);
124126
}
125127
}

0 commit comments

Comments
 (0)