Total Complexity | 3 |
Total Lines | 40 |
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 guild is deleted""" |
||
5 | |||
6 | from ..core.dispatch import GatewayDispatch |
||
7 | from ..objects.guild import UnavailableGuild |
||
8 | from ..utils.conversion import construct_client_dict |
||
9 | |||
10 | |||
11 | async def guild_delete_middleware(self, payload: GatewayDispatch): |
||
12 | """|coro| |
||
13 | |||
14 | Middleware for ``on_guild_delete`` event. |
||
15 | |||
16 | Parameters |
||
17 | ---------- |
||
18 | self : :class:`Client` |
||
19 | The current client/bot. |
||
20 | |||
21 | payload : :class:`GatewayDispatch` |
||
22 | The data received from the guild delete event. |
||
23 | |||
24 | |||
25 | Returns |
||
26 | ------- |
||
27 | Tuple[:class:`str`, List[:class:`~pincer.objects.guild.guild.UnavailableGuild`]] |
||
28 | ``on_guild_delete`` and an ``UnavailableGuild`` |
||
29 | """ |
||
30 | guild = UnavailableGuild.from_dict(construct_client_dict(self, payload.data)) |
||
31 | |||
32 | if guild.id in self.guilds.key(): |
||
33 | self.guilds.pop(guild.id) |
||
34 | |||
35 | return "on_guild_delete", [guild] |
||
36 | |||
37 | |||
38 | def export(): |
||
|
|||
39 | return guild_delete_middleware |
||
40 |