Skip to content
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

[pull] master from Rapptz:master #19

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions discord/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import copy
import time
import secrets
import asyncio
from datetime import datetime
from typing import (
Expand Down Expand Up @@ -1614,6 +1615,9 @@ async def send(
else:
flags = MISSING

if nonce is None:
nonce = secrets.randbits(64)

with handle_message_parameters(
content=content,
tts=tts,
Expand Down
5 changes: 4 additions & 1 deletion discord/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,10 @@ def latency(self) -> float:

def _can_handle_close(self) -> bool:
code = self._close_code or self.socket.close_code
return code not in (1000, 4004, 4010, 4011, 4012, 4013, 4014)
# If the socket is closed remotely with 1000 and it's not our own explicit close
# then it's an improper close that should be handled and reconnected
is_improper_close = self._close_code is None and self.socket.close_code == 1000
return is_improper_close or code not in (1000, 4004, 4010, 4011, 4012, 4013, 4014)

async def poll_event(self) -> None:
"""Polls for a DISPATCH event and handles the general gateway loop.
Expand Down
1 change: 1 addition & 0 deletions discord/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ def handle_message_parameters(

if nonce is not None:
payload['nonce'] = str(nonce)
payload['enforce_nonce'] = True

if message_reference is not MISSING:
payload['message_reference'] = message_reference
Expand Down
Loading