Skip to content
This repository has been archived by the owner on Mar 13, 2023. It is now read-only.

[BUG] bot.is_ready not reset during reconnect #591

Closed
3 tasks done
Wolfhound905 opened this issue Aug 10, 2022 · 0 comments · Fixed by #595
Closed
3 tasks done

[BUG] bot.is_ready not reset during reconnect #591

Wolfhound905 opened this issue Aug 10, 2022 · 0 comments · Fixed by #595
Assignees
Labels
Bug::Library A bug in the library

Comments

@Wolfhound905
Copy link
Collaborator

NAFF Version

latest

Describe the Bug

When a session is, "Gateway has invalidated session! Reconnecting..."
bot.is_ready is not set to false and will spam you with all the join things

Expected Results

What should happen during a reconnect is is_ready is set back to false and then true once it is connected

Minimal Reproducible Code

import naff

bot = naff.Client(sync_interactions=True, debug_scope=701347683591389185)

@naff.slash_command(name="trip_reconnect")
async def trip_reconnect(ctx):
    await ctx.send("Session invalidated")
    await bot.ws.dispatch_opcode(None, naff.WebSocketOPCodes.INVALIDATE_SESSION)

@naff.listen(naff.events.GuildJoin)
async def join(event: naff.events.GuildJoin):
    if bot.is_ready:
        print("This should not happen within the testing period")

bot.start("token")

Traceback

No response

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.

Additional Information

I think that this is where is ready should be set back to false

async def reconnect(self, *, resume: bool = False, code: int = 1012) -> None:
async with self._race_lock:
self._closed.clear()
if self.ws is not None:
await self.ws.close(code=code)
self.ws = None
self._zlib = zlib.decompressobj()
self.ws = await self.state.client.http.websocket_connect(self.ws_url)
hello = await self.receive(force=True)
self.heartbeat_interval = hello["d"]["heartbeat_interval"] / 1000
if not resume:
await self._identify()
else:
await self._resume_connection()
self._closed.set()
self._acknowledged.set()

@Wolfhound905 Wolfhound905 added the Bug::Library A bug in the library label Aug 10, 2022
@LordOfPolls LordOfPolls linked a pull request Aug 10, 2022 that will close this issue
7 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug::Library A bug in the library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants