noahkaiser
noahkaiser
DIAdiscord.js - Imagine an app
Created by noahkaiser on 7/23/2023 in #djs-questions
How can I respawn a disconnected client that was not spawned from a ShardingManager?
The issue was that the web-server instance was a webservice not a background worker for the specified site.
8 replies
DIAdiscord.js - Imagine an app
Created by noahkaiser on 7/23/2023 in #djs-questions
How can I respawn a disconnected client that was not spawned from a ShardingManager?
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.
8 replies
DIAdiscord.js - Imagine an app
Created by noahkaiser on 7/23/2023 in #djs-questions
How can I respawn a disconnected client that was not spawned from a ShardingManager?
-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?
8 replies
DIAdiscord.js - Imagine an app
Created by noahkaiser on 7/23/2023 in #djs-questions
How can I respawn a disconnected client that was not spawned from a ShardingManager?
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');
const { Events } = require('discord.js');

module.exports = {
name: Events.ClientReady,
once: false,
async execute(client) {
console.log(`Ready! Logged in as ${client.user.tag}`); //only fired once when the application starts/logs in
await client.destroy(); // destroy the socket and attempt to reconnect...
},
};
const { Events } = require('discord.js');

module.exports = {
name: Events.ClientReady,
once: false,
async execute(client) {
console.log(`Ready! Logged in as ${client.user.tag}`); //only fired once when the application starts/logs in
await client.destroy(); // destroy the socket and attempt to reconnect...
},
};
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.
const {
Events
} = require('discord.js');

module.exports = {
name: Events.ShardDisconnect,
once: false,
async execute(client, event, id) {
console.log(`Shard ${id} disconnected from Discord with code ${event.code}.`);
try {
await client.login(process.env.TOKEN) //does not trigger the ready event?
} catch (error) {
console.error('Error respawning the shard:', error);
}
},
};
const {
Events
} = require('discord.js');

module.exports = {
name: Events.ShardDisconnect,
once: false,
async execute(client, event, id) {
console.log(`Shard ${id} disconnected from Discord with code ${event.code}.`);
try {
await client.login(process.env.TOKEN) //does not trigger the ready event?
} catch (error) {
console.error('Error respawning the shard:', error);
}
},
};
8 replies
DIAdiscord.js - Imagine an app
Created by noahkaiser on 7/23/2023 in #djs-questions
How can I respawn a disconnected client that was not spawned from a ShardingManager?
-I am using discord.js v14.11.0 -I need to reconnect my discord bot after it disconnects from the discord gateway.
8 replies