Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
15 changes: 5 additions & 10 deletions nonebot/adapters/discord/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import contextlib
from functools import lru_cache
import inspect
import json
import sys
from types import UnionType
from typing import Any, cast
Expand Down Expand Up @@ -36,7 +35,8 @@
Reconnect,
Resume,
)
from .utils import decompress_data, log, model_dump
from .serialization import encode_model_json_text
from .utils import decompress_data, log

RECONNECT_INTERVAL = 3.0

Expand Down Expand Up @@ -297,7 +297,7 @@ async def _heartbeat(ws: WebSocket, bot: Bot) -> None:
{"data": bot.sequence if bot.has_sequence else None},
)
with contextlib.suppress(Exception):
await ws.send(json.dumps(model_dump(payload, by_alias=True)))
await ws.send(encode_model_json_text(payload, by_alias=True))

async def _heartbeat_task(
self, ws: WebSocket, bot: Bot, heartbeat_interval: int
Expand Down Expand Up @@ -342,13 +342,8 @@ async def _authenticate(

try:
await ws.send(
json.dumps(
model_dump(
payload,
by_alias=True,
exclude_none=True,
omit_unset_values=True,
)
encode_model_json_text(
payload, by_alias=True, exclude_none=True, omit_unset_values=True
)
)
except Exception as e:
Expand Down
4 changes: 2 additions & 2 deletions nonebot/adapters/discord/api/client.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# This file is auto-generated by scripts/generate_client_pyi.py.
# Do not edit this file directly.
# Generated at: 2026-02-26T19:42:13Z
# Generated at: 2026-03-16T08:58:21Z
# Source file: nonebot/adapters/discord/api/handle.py
# Source SHA256: b377b5d9309e2fe7268299cffc7777caec3d0f9a0cc7f25b6b1ebbb2ae846e0c
# Source SHA256: 8d5b74fe9c3de234287ba1e845638d1b814dbe1ef47d9b64f2875db0d29826f4
# Script SHA256: bca3059c41f047e5cfb7f59a630cbcd9f80c226dc2138e28b19cd6b811cd03dc

from datetime import datetime
Expand Down
Loading
Loading