| Total Complexity | 2 |
| Total Lines | 46 |
| 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 an integration is updated""" |
||
| 5 | |||
| 6 | from __future__ import annotations |
||
| 7 | |||
| 8 | from typing import TYPE_CHECKING |
||
| 9 | |||
| 10 | from ..objects.events.integration import IntegrationUpdateEvent |
||
| 11 | from ..utils.types import Coro |
||
| 12 | |||
| 13 | if TYPE_CHECKING: |
||
| 14 | from ..client import Client |
||
| 15 | from ..core.gateway import Gateway |
||
| 16 | from ..core.gateway import GatewayDispatch |
||
| 17 | |||
| 18 | |||
| 19 | async def integration_update_middleware( |
||
| 20 | self: Client, gateway: Gateway, payload: GatewayDispatch |
||
| 21 | ): |
||
| 22 | """|coro| |
||
| 23 | |||
| 24 | Middleware for the ``on_integration_update`` event. |
||
| 25 | |||
| 26 | Parameters |
||
| 27 | ---------- |
||
| 28 | payload : :class:`~pincer.core.gateway.GatewayDispatch` |
||
| 29 | The data received from the integration update event |
||
| 30 | gateway : :class:`~pincer.core.gateway.Gateway` |
||
| 31 | The gateway for the current shard. |
||
| 32 | |||
| 33 | Returns |
||
| 34 | ------- |
||
| 35 | Tuple[:class:`str`, :class:`~pincer.events.integration.IntegrationUpdateEvent`] |
||
| 36 | ``on_integration_update`` and an ``IntegrationUpdateEvent`` |
||
| 37 | """ # noqa: E501 |
||
| 38 | return ( |
||
| 39 | "on_integration_update", |
||
| 40 | IntegrationUpdateEvent.from_dict(payload.data), |
||
| 41 | ) |
||
| 42 | |||
| 43 | |||
| 44 | def export() -> Coro: |
||
| 45 | return integration_update_middleware |
||
| 46 |