-
Notifications
You must be signed in to change notification settings - Fork 186
Closed
Description
Library Version
5.10.0
Describe the Bug
msgspec version - 0.18.4
Sending StringSelectOption
with emoji=CustomEmoji
when msgspec
is installed (used) results with TypeError: Object of type <class 'interactions.models.discord.snowflake.Snowflake'> is not JSON serializable
This bug occurs only with msgspec. Default json and orjson work without any problems.
Steps to Reproduce
- Send message with
StringSelectMenu
, whereStringSelectOption.emoji = CustomEmoji
, whenmsgspec
is installed (used)
Test command to reproduce (msgspec
must be installed):
@slash_command()
async def test(ctx: SlashContext):
await ctx.respond(
components=StringSelectMenu(
StringSelectOption(label="test", value="test_value", emoji=(await ctx.guild.fetch_all_custom_emojis())[0]) # test emoji
)
)
Expected Results
Bot sends Message with StringSelectMenu where StringSelectOption has custom emoji
Minimal Reproducible Code
@slash_command()
async def test(ctx: SlashContext):
await ctx.respond(
components=StringSelectMenu(
StringSelectOption(label="test", value="test_value", emoji=(await ctx.guild.fetch_all_custom_emojis())[0]) # test emoji
)
)
Traceback
File "C:\fox\Lib\site-packages\interactions\client\client.py", line 1900, in __dispatch_interaction
response = await callback
^^^^^^^^^^^^^^
File "C:\fox\Lib\site-packages\interactions\client\client.py", line 1771, in _run_slash_command
return await command(ctx, **ctx.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\fox\Lib\site-packages\interactions\models\internal\command.py", line 132, in __call__
await self.call_callback(self.callback, context)
File "C:\fox\Lib\site-packages\interactions\models\internal\application_commands.py", line 802, in call_callback
return await self.call_with_binding(callback, ctx)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\fox\Lib\site-packages\interactions\models\internal\callback.py", line 43, in call_with_binding
return await callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Lacosst0\PycharmProjects\mister_selectus\bot.py", line 47, in test
await ctx.respond(
File "C:\fox\Lib\site-packages\interactions\models\internal\context.py", line 531, in send
return await super().send(
^^^^^^^^^^^^^^^^^^^
File "C:\fox\Lib\site-packages\interactions\client\mixins\send.py", line 110, in send
message_data = await self._send_http_request(message_payload, files=files or file)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\fox\Lib\site-packages\interactions\models\internal\context.py", line 453, in _send_http_request
message_data = await self.client.http.post_initial_response(payload, self.id, self.token, files=files)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\fox\Lib\site-packages\interactions\api\http\http_requests\interactions.py", line 149, in post_initial_response
return await self.request(
^^^^^^^^^^^^^^^^^^^
File "C:\fox\Lib\site-packages\interactions\api\http\http_client.py", line 397, in request
async with self.__session.request(route.method, route.url, **kwargs) as response:
File "C:\fox\Lib\site-packages\aiohttp\client.py", line 1186, in __aenter__
self._resp = await self._coro
^^^^^^^^^^^^^^^^
File "C:\fox\Lib\site-packages\aiohttp\client.py", line 429, in _request
data = payload.JsonPayload(json, dumps=self._json_serialize)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\fox\Lib\site-packages\aiohttp\payload.py", line 396, in __init__
dumps(value).encode(encoding),
^^^^^^^^^^^^
File "C:\fox\Lib\site-packages\interactions\client\utils\input_utils.py", line 76, in dumps
data = json.dumps(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\fox\Lib\site-packages\interactions\client\utils\input_utils.py", line 32, in enc_hook
raise TypeError(f"Object of type {type(obj)} is not JSON serializable")
TypeError: Object of type <class 'interactions.models.discord.snowflake.Snowflake'> is not JSON serializable
Checklist
- I have searched the open issues for duplicates.
- I have shown the entire traceback, if possible.
- I have removed my token from display, if visible.
- I have attempted to debug this myself, and I believe this issue is with the library
Additional Information
You can find more information about that bug in official interactions.py discord server: https://discord.com/channels/789032594456576001/1163083993474941019
Metadata
Metadata
Assignees
Labels
No labels