1919 ForbiddenError , MethodNotAllowedError , RateLimitError , ServerError ,
2020 HTTPError
2121)
22+ from ..utils .conversion import remove_none
2223
2324if TYPE_CHECKING :
2425 from typing import Any , Dict , Optional , Union
@@ -114,28 +115,40 @@ async def __send(
114115 content_type : str = "application/json" ,
115116 data : Optional [Union [Dict , str , Payload ]] = None ,
116117 headers : Optional [Dict [str , Any ]] = None ,
118+ params : Optional [Dict ] = None ,
117119 __ttl : int = None
118120 ) -> Optional [Dict ]:
119121 """
120122 Send an api request to the Discord REST API.
121123
122- method:
124+ Parameters
125+ ----------
126+
127+ method: :class:`aiohttp.ClientSession.request`
123128 The method for the request. (e.g. GET or POST)
124129
125- endpoint:
130+ endpoint: :class:`str`
126131 The endpoint to which the request will be sent.
127132
128- Keyword Arguments:
129-
130- content_type:
133+ content_type: :class:`str`
131134 The request's content type.
132135
133- data:
136+ data: Optional[Union[:class:`Dict`, :class:`str`, :class:`aiohttp.payload.Payload`]]
134137 The data which will be added to the request.
138+ |default| :data:`None`
139+
140+ headers: Optional[:class:`Dict`]
141+ The request headers.
142+ |default| :data:`None`
143+
144+ params: Optional[:class:`Dict`]
145+ The query parameters to add to the request.
146+ |default| :data:`None`
135147
136- __ttl:
148+ __ttl: Optional[:class:`int`]
137149 Private param used for recursively setting the retry amount.
138150 (Eg set to 1 for 1 max retry)
151+ |default| :data:`None`
139152 """
140153 ttl = __ttl or self .max_ttl
141154
@@ -166,8 +179,9 @@ async def __send(
166179 data = data ,
167180 headers = {
168181 "Content-Type" : content_type ,
169- ** (headers or {})
170- }
182+ ** (remove_none (headers ) or {})
183+ },
184+ params = remove_none (params )
171185 ) as res :
172186 return await self .__handle_response (
173187 res , method , endpoint , content_type , data , ttl
@@ -188,22 +202,25 @@ async def __handle_response(
188202 Side effects:
189203 If a 5xx error code is returned it will retry the request.
190204
191- res:
205+ Parameters
206+ ----------
207+
208+ res: :class:`aiohttp.ClientResponse`
192209 The response from the discord API.
193210
194- method:
211+ method: :class:`aiohttp.ClientSession.request`
195212 The method which was used to call the endpoint.
196213
197- endpoint:
214+ endpoint: :class:`str`
198215 The endpoint to which the request was sent.
199216
200- content_type:
217+ content_type: :class:`str`
201218 The request's content type.
202219
203- data:
220+ data: Optional[:class:`str`]
204221 The data which was added to the request.
205222
206- __ttl:
223+ __ttl: :class:`int`
207224 Private param used for recursively setting the retry amount.
208225 (Eg set to 1 for 1 max retry)
209226 """
@@ -292,7 +309,7 @@ async def delete(
292309
293310 Returns
294311 -------
295- Optional[:class:`dict `]
312+ Optional[:class:`Dict `]
296313 The response from discord.
297314 """
298315 return await self .__send (
@@ -301,7 +318,11 @@ async def delete(
301318 headers = headers
302319 )
303320
304- async def get (self , route : str ) -> Optional [Dict ]:
321+ async def get (
322+ self ,
323+ route : str ,
324+ params : Optional [Dict ] = None
325+ ) -> Optional [Dict ]:
305326 """|coro|
306327
307328 Sends a get request to a Discord REST endpoint.
@@ -310,13 +331,20 @@ async def get(self, route: str) -> Optional[Dict]:
310331 ----------
311332 route : :class:`str`
312333 The Discord REST endpoint to send a get request to.
334+ params: Optional[:class:`Dict`]
335+ The query parameters to add to the request.
336+ |default| :data:`None`
313337
314338 Returns
315339 -------
316- Optional[:class:`dict `]
340+ Optional[:class:`Dict `]
317341 The response from discord.
318342 """
319- return await self .__send (self .__session .get , route )
343+ return await self .__send (
344+ self .__session .get ,
345+ route ,
346+ params = params
347+ )
320348
321349 async def head (self , route : str ) -> Optional [Dict ]:
322350 """|coro|
@@ -330,7 +358,7 @@ async def head(self, route: str) -> Optional[Dict]:
330358
331359 Returns
332360 -------
333- Optional[:class:`dict `]
361+ Optional[:class:`Dict `]
334362 The response from discord.
335363 """
336364 return await self .__send (self .__session .head , route )
@@ -347,7 +375,7 @@ async def options(self, route: str) -> Optional[Dict]:
347375
348376 Returns
349377 -------
350- Optional[:class:`dict `]
378+ Optional[:class:`Dict `]
351379 The response from discord.
352380 """
353381 return await self .__send (self .__session .options , route )
@@ -367,7 +395,7 @@ async def patch(
367395 ----------
368396 route : :class:`str`
369397 The Discord REST endpoint to send a patch request to.
370- data : :class:`dict `
398+ data : :class:`Dict `
371399 The update data for the patch request.
372400 content_type: :class:`str`
373401 Body content type.
@@ -377,7 +405,7 @@ async def patch(
377405
378406 Returns
379407 -------
380- Optional[:class:`dict `]
408+ Optional[:class:`Dict `]
381409 JSON response from the discord API.
382410 """
383411 return await self .__send (
@@ -412,7 +440,7 @@ async def post(
412440
413441 Returns
414442 -------
415- Optional[:class:`dict `]
443+ Optional[:class:`Dict `]
416444 JSON response from the discord API.
417445 """
418446 return await self .__send (
@@ -447,7 +475,7 @@ async def put(
447475
448476 Returns
449477 -------
450- Optional[:class:`dict `]
478+ Optional[:class:`Dict `]
451479 JSON response from the discord API.
452480 """
453481 return await self .__send (
0 commit comments