19
19
use Discord \Repository \AbstractRepository ;
20
20
use React \Promise \PromiseInterface ;
21
21
22
- use function React \Promise \resolve ;
22
+ use function React \Promise \reject ;
23
23
24
24
/**
25
25
* Used only to search messages sent in a guild.
@@ -97,7 +97,7 @@ class MessageRepository extends AbstractRepository
97
97
public function freshen (array $ queryparams = []): PromiseInterface
98
98
{
99
99
if (empty ($ queryparams )) {
100
- return resolve ( $ this );
100
+ return reject ( new \ InvalidArgumentException ( ' Query parameters are required. ' ) );
101
101
}
102
102
103
103
$ endpoint = new Endpoint ($ this ->endpoints ['all ' ]);
@@ -109,7 +109,9 @@ public function freshen(array $queryparams = []): PromiseInterface
109
109
110
110
return $ this ->http ->get ($ endpoint )->then (function ($ response ) {
111
111
$ 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 ;
113
115
});
114
116
}
115
117
@@ -120,6 +122,6 @@ public function freshen(array $queryparams = []): PromiseInterface
120
122
*/
121
123
protected function cacheFreshen ($ response ): PromiseInterface
122
124
{
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 );
124
126
}
125
127
}
0 commit comments