Passed
Pull Request — main (#163)
by
unknown
01:38
created

pincer.middleware.thread_list_sync.export()   A

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 the client gains access to a channel"""
5
6
from __future__ import annotations
7
8
from typing import List
9
10
from ..core.dispatch import GatewayDispatch
11
from ..objects import Channel, ThreadMember
12
from ..objects.events.thread import ThreadListSyncEvent
13
from ..utils.conversion import construct_client_dict
14
15
16
async def thread_list_sync(self, payload: GatewayDispatch):
17
    """|coro|
18
19
    Middleware for ``on_thread_list_sync`` event.
20
21
    Parameters
22
    ----------
23
    self : :class:`Client`
24
        The current client/bot.
25
26
    payload : :class:`GatewayDispatch`
27
        The data received from the thread list sync event.
28
29
30
    Returns
31
    -------
32
    Tuple[:class:`str`, List[:class:`~pincer.objects.guild.events.thread.ThreadListSyncEvent`]]
33
        ``on_thread_list_sync`` and an ``ThreadListSyncEvent``
34
    """
35
36
    threads: List[Channel] = [
37
        Channel.from_dict(construct_client_dict(self, thread))
38
        for thread in payload.data.pop("threads")
39
    ]
40
41
    members: List[ThreadMember] = [
42
        ThreadMember.from_dict(construct_client_dict(self, member))
43
        for member in payload.data.pop("members")
44
    ]
45
46
    return "on_thread_list_sync", [
47
        ThreadListSyncEvent.from_dict(
48
            {"threads": threads, "members": members, **payload.data}
49
        )
50
    ]
51
52
53
def export():
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
54
    return thread_list_sync
55