Total Complexity | 2 |
Total Lines | 47 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | # Copyright Pincer 2021-Present |
||
2 | # Full MIT License can be found in `LICENSE` at the project root. |
||
3 | |||
4 | """ |
||
5 | non-subscription event sent when there is an error, |
||
6 | including command responses |
||
7 | """ |
||
8 | from __future__ import annotations |
||
9 | |||
10 | from typing import TYPE_CHECKING |
||
11 | |||
12 | from ..objects.events.error import DiscordError |
||
13 | from ..utils.conversion import construct_client_dict |
||
14 | from ..utils.types import Coro |
||
15 | |||
16 | if TYPE_CHECKING: |
||
17 | from typing import List, Tuple |
||
18 | from ..core.dispatch import GatewayDispatch |
||
19 | |||
20 | |||
21 | def error_middleware( |
||
22 | self, |
||
|
|||
23 | payload: GatewayDispatch |
||
24 | ) -> Tuple[str, List[DiscordError]]: |
||
25 | """|coro| |
||
26 | |||
27 | Middleware for ``on_error`` event. |
||
28 | |||
29 | Parameters |
||
30 | ---------- |
||
31 | payload : :class:`~pincer.core.dispatch.GatewayDispatch` |
||
32 | The data received from the ready event. |
||
33 | |||
34 | Returns |
||
35 | ------- |
||
36 | Tuple[:class:`str`, List[:class:`~pincer.objects.events.error.DiscordError`]] |
||
37 | ``"on_error"`` and a ``DiscordError`` |
||
38 | """ # noqa: E501 |
||
39 | |||
40 | return "on_error", [ |
||
41 | DiscordError.from_dict(construct_client_dict(self, payload.data)) |
||
42 | ] |
||
43 | |||
44 | |||
45 | def export() -> Coro: |
||
46 | return error_middleware |
||
47 |