How can I respawn a disconnected client that was not spawned from a ShardingManager?
I've noticed after a long time my web-server will still be running but the bot will be disconnected from discord's gateway. I do not have access to the ShardClientUtil to respawn all shards since the bot was created using the WebSocketManager.
4 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Post the full error stack trace, not just the top part!
- Show your code!
- Explain what exactly your issue is.
- Not a discord.js issue? Check out #useful-servers.
- Issue solved? Press the button!-I am using discord.js v14.11.0
-I need to reconnect my discord bot after it disconnects from the discord gateway.
I did not have a disconnect event file while the issue occured. Now I am creating one so that when it happens again, the bot can reconnect to the discord gateway.
In the ready event I call
await client.destroy();
const { Events, AuditLogEvent } = require('discord.js');
then the shardDisconnect
event fires and I am trying to reconnect the bot to the discord gateway.
i've noticed when I attempt to call await client.login()
after the client is destroyed my ready event is not firing again.
-Before my web-server was still running but my discord bot was disconnected from the gateway randomly.
-Now I am simulating the random disconnect that occurred before I had a handle for the disconnect.
-How can I reconnect my bot given that it was created from a WebSocketManager?
Can you show me how to activate debug mode? The bot disconnected again without anything logging in the shardDisconnect event probably due to an unrecoverable error like you said.Please add the following code to your code base outside of any other event listeners and provide the full log output relevant to your issue.
- Note: if you initialize your Client as
bot
or other identifiers you need to use these instead of client
- If the output is too long to post consider using a bin instead: gist | paste.gg | sourceb.in | hastebinThe issue was that the web-server instance was a webservice not a background worker for the specified site.