diff --git a/naff/api/http/http_client.py b/naff/api/http/http_client.py index ec77274d1..ba5c4a1ad 100644 --- a/naff/api/http/http_client.py +++ b/naff/api/http/http_client.py @@ -5,6 +5,7 @@ from weakref import WeakValueDictionary import aiohttp +import discord_typings from aiohttp import BaseConnector, ClientSession, ClientWebSocketResponse, FormData from multidict import CIMultiDictProxy @@ -32,12 +33,12 @@ __api_version__, ) from naff.client.errors import DiscordError, Forbidden, GatewayNotFound, HTTPException, NotFound, LoginError +from naff.client.mixins.serialization import DictSerializationMixin from naff.client.utils.input_utils import response_decode, OverriddenJson from naff.client.utils.serializer import dict_filter from naff.models import CooldownSystem from naff.models.discord.file import UPLOADABLE_TYPE from .route import Route -import discord_typings __all__ = ("HTTPClient",) @@ -213,6 +214,13 @@ def _process_payload( if isinstance(payload, dict): payload = dict_filter(payload) + + for k, v in payload.items(): + if isinstance(v, DictSerializationMixin): + payload[k] = v.to_dict() + if isinstance(v, (list, tuple, set)): + payload[k] = [i.to_dict() if isinstance(i, DictSerializationMixin) else i for i in v] + else: payload = [dict_filter(x) if isinstance(x, dict) else x for x in payload]