| Total Complexity | 2 |
| Total Lines | 47 |
| 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 | """ |
||
| 5 | Sent when a new user joins a guild. The inner payload is a guild member object |
||
| 6 | with an extra ``guild_id`` key. |
||
| 7 | """ |
||
| 8 | |||
| 9 | from __future__ import annotations |
||
| 10 | |||
| 11 | from typing import TYPE_CHECKING |
||
| 12 | |||
| 13 | from ..objects.events.guild import GuildMemberAddEvent |
||
| 14 | from ..utils import Coro |
||
| 15 | |||
| 16 | if TYPE_CHECKING: |
||
| 17 | from ..client import Client |
||
| 18 | from ..core.gateway import Gateway |
||
| 19 | from ..core.gateway import GatewayDispatch |
||
| 20 | |||
| 21 | |||
| 22 | async def guild_member_add_middleware( |
||
| 23 | self: Client, gateway: Gateway, payload: GatewayDispatch |
||
| 24 | ): |
||
| 25 | """|coro| |
||
| 26 | |||
| 27 | Middleware for the ``on_guild_member_add`` event. |
||
| 28 | |||
| 29 | Parameters |
||
| 30 | ---------- |
||
| 31 | payload : :class:`~pincer.core.gateway.GatewayDispatch` |
||
| 32 | The data received from the guild member add event. |
||
| 33 | gateway : :class:`~pincer.core.gateway.Gateway` |
||
| 34 | The gateway for the current shard. |
||
| 35 | |||
| 36 | Returns |
||
| 37 | ------- |
||
| 38 | Tuple[:class:`str`, :class:`~pincer.objects.events.guild.GuildMemberAddEvent`] |
||
| 39 | ``on_guild_member_add`` and a ``GuildMemberAddEvent`` |
||
| 40 | """ |
||
| 41 | |||
| 42 | return ("on_guild_member_add", GuildMemberAddEvent.from_dict(payload.data)) |
||
| 43 | |||
| 44 | |||
| 45 | def export() -> Coro: |
||
| 46 | return guild_member_add_middleware |
||
| 47 |