| Total Complexity | 2 |
| Total Lines | 45 |
| 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 | """Sent when a channel is created/joined on the client.""" |
||
| 5 | from ..core.dispatch import GatewayDispatch |
||
| 6 | from ..objects import Channel |
||
| 7 | from ..utils.conversion import construct_client_dict |
||
| 8 | from ..utils.types import Coro |
||
| 9 | |||
| 10 | from typing import TYPE_CHECKING |
||
|
|
|||
| 11 | |||
| 12 | from ..utils.conversion import construct_client_dict |
||
| 13 | from ..objects.guild.channel import Channel |
||
| 14 | |||
| 15 | if TYPE_CHECKING: |
||
| 16 | from typing import List, Tuple |
||
| 17 | |||
| 18 | from ..core.dispatch import GatewayDispatch |
||
| 19 | |||
| 20 | def channel_create_middleware( |
||
| 21 | self, |
||
| 22 | payload: GatewayDispatch |
||
| 23 | ) -> Tuple[str, List[Channel]]: |
||
| 24 | """|coro| |
||
| 25 | |||
| 26 | Middleware for ``on_channel_creation`` event. |
||
| 27 | |||
| 28 | Parameters |
||
| 29 | ---------- |
||
| 30 | payload : :class:`~pincer.core.dispatch.GatewayDispatch` |
||
| 31 | The data received from the ready event. |
||
| 32 | |||
| 33 | Returns |
||
| 34 | ------- |
||
| 35 | Tuple[:class:`str`, List[:class:`~pincer.objects.guild.channel.Channel`]] |
||
| 36 | ``"on_channel_creation"`` and a channel. |
||
| 37 | """ |
||
| 38 | return "on_channel_creation", [ |
||
| 39 | Channel.from_dict(construct_client_dict(self, payload.data)) |
||
| 40 | ] |
||
| 41 | |||
| 42 | |||
| 43 | def export() -> Coro: |
||
| 44 | return channel_create_middleware |
||
| 45 |