Skip to content

fix: Snowflake encoding issue when msgspec is used fix #1562

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions interactions/client/utils/input_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import re
import typing
from enum import IntFlag
from interactions.models.discord.snowflake import Snowflake
from typing import Any, Dict, Union, Optional

import aiohttp # type: ignore
Expand All @@ -25,8 +26,8 @@
import msgspec.json as json

def enc_hook(obj: Any) -> int:
# msgspec doesnt support IntFlags
if isinstance(obj, IntFlag):
# msgspec doesnt support IntFlags or interactions.Snowflakes
if isinstance(obj, (IntFlag, Snowflake)):
return int(obj)
raise TypeError(f"Object of type {type(obj)} is not JSON serializable")

Expand Down