Conditions | 4 |
Total Lines | 29 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | # Copyright Pincer 2021-Present |
||
17 | async def ready_middleware(self, payload: GatewayDispatch): |
||
18 | """|coro| |
||
19 | |||
20 | Middleware for ``on_ready`` event. |
||
21 | |||
22 | Parameters |
||
23 | ---------- |
||
24 | payload : :class:`GatewayDispatch` |
||
25 | The data recieved from the stage instance create event |
||
26 | |||
27 | Returns |
||
28 | ------- |
||
29 | Tuple[:class:`str`] |
||
30 | ``on_ready`` |
||
31 | """ |
||
32 | user = payload.data.get("user") |
||
33 | guilds = payload.data.get("guilds") |
||
34 | |||
35 | if not user or guilds is None: |
||
36 | raise InvalidPayload( |
||
37 | "A `user` and `guilds` key/value pair is expected on the " |
||
38 | "`ready` payload event." |
||
39 | ) |
||
40 | |||
41 | self.bot = User.from_dict(construct_client_dict(self, user)) |
||
42 | self.guilds = dict(map(lambda i: (i["id"], None), guilds)) |
||
43 | |||
44 | await ChatCommandHandler(self).initialize() |
||
45 | return ("on_ready",) |
||
46 | |||
50 |