pincer.middleware.channel_create.export()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 2
rs 10
c 0
b 0
f 0
cc 1
nop 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 __future__ import annotations
6
7
from typing import TYPE_CHECKING
8
9
from ..objects.guild.channel import Channel
10
11
if TYPE_CHECKING:
12
    from typing import Tuple
13
    from ..core.gateway import GatewayDispatch
14
    from ..client import Client
15
    from ..core.gateway import Gateway
16
17
18
async def channel_create_middleware(
19
    self: Client, gateway: Gateway, payload: GatewayDispatch
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
Unused Code introduced by
The argument gateway seems to be unused.
Loading history...
20
) -> Tuple[str, Channel]:
21
    """|coro|
22
23
    Middleware for the ``on_channel_creation`` event.
24
25
    Parameters
26
    ----------
27
    payload : :class:`~pincer.core.gateway.GatewayDispatch`
28
        The data received from the ready event.
29
    gateway : :class:`~pincer.core.gateway.Gateway`
30
        The gateway for the current shard.
31
32
    Returns
33
    -------
34
    Tuple[:class:`str`, List[:class:`~pincer.objects.guild.channel.Channel`]]
35
        ``on_channel_creation`` and a channel.
36
    """
37
38
    channel: Channel = Channel.from_dict(payload.data)
39
40
    self.guilds[channel.guild_id].channels.append(channel)
41
    self.channels[channel.id] = channel
42
43
    return "on_channel_creation", channel
44
45
46
def export():
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
47
    return channel_create_middleware
48