Passed
Pull Request — main (#163)
by
unknown
01:28
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
    """
18
    Middleware for ``on_thread_list_sync`` event.
19
20
    :param self:
21
        The current client
22
23
    :param payload:
24
        The data received from the thread list sync event.
25
    """
26
    threads: List[Channel] = [
27
        Channel.from_dict(construct_client_dict(self, thread))
28
        for thread in payload.data.pop("threads")
29
    ]
30
31
    members: List[ThreadMember] = [
32
        ThreadMember.from_dict(construct_client_dict(self, member))
33
        for member in payload.data.pop("members")
34
    ]
35
36
    return "on_thread_list_sync", [
37
        ThreadListSyncEvent.from_dict(
38
            {"threads": threads, "members": members, **payload.data}
39
        )
40
    ]
41
42
43
def export():
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
44
    return thread_list_sync
45