(
self,
route: Route,
*,
files: Optional[Sequence[File]] = None,
form: Optional[Iterable[Dict[str, Any]]] = None,
**kwargs: Any,
)
| 587 | return value |
| 588 | |
| 589 | async def request( |
| 590 | self, |
| 591 | route: Route, |
| 592 | *, |
| 593 | files: Optional[Sequence[File]] = None, |
| 594 | form: Optional[Iterable[Dict[str, Any]]] = None, |
| 595 | **kwargs: Any, |
| 596 | ) -> Any: |
| 597 | method = route.method |
| 598 | url = route.url |
| 599 | route_key = route.key |
| 600 | |
| 601 | bucket_hash = None |
| 602 | try: |
| 603 | bucket_hash = self._bucket_hashes[route_key] |
| 604 | except KeyError: |
| 605 | key = f'{route_key}:{route.major_parameters}' |
| 606 | else: |
| 607 | key = f'{bucket_hash}:{route.major_parameters}' |
| 608 | |
| 609 | ratelimit = self.get_ratelimit(key) |
| 610 | |
| 611 | # header creation |
| 612 | headers: Dict[str, str] = { |
| 613 | 'User-Agent': self.user_agent, |
| 614 | } |
| 615 | |
| 616 | if self.token is not None: |
| 617 | headers['Authorization'] = 'Bot ' + self.token |
| 618 | # some checking if it's a JSON request |
| 619 | if 'json' in kwargs: |
| 620 | headers['Content-Type'] = 'application/json' |
| 621 | kwargs['data'] = utils._to_json(kwargs.pop('json')) |
| 622 | |
| 623 | try: |
| 624 | reason = kwargs.pop('reason') |
| 625 | except KeyError: |
| 626 | pass |
| 627 | else: |
| 628 | if reason: |
| 629 | headers['X-Audit-Log-Reason'] = _uriquote(reason, safe='/ ') |
| 630 | |
| 631 | kwargs['headers'] = headers |
| 632 | |
| 633 | # Proxy support |
| 634 | if self.proxy is not None: |
| 635 | kwargs['proxy'] = self.proxy |
| 636 | if self.proxy_auth is not None: |
| 637 | kwargs['proxy_auth'] = self.proxy_auth |
| 638 | |
| 639 | if not self._global_over.is_set(): |
| 640 | # wait until the global lock is complete |
| 641 | await self._global_over.wait() |
| 642 | |
| 643 | response: Optional[aiohttp.ClientResponse] = None |
| 644 | data: Optional[Union[Dict[str, Any], str]] = None |
| 645 | async with ratelimit: |
| 646 | for tries in range(5): |
no test coverage detected