diff --git a/index.js b/index.js index 430acbf..95ce4f6 100644 --- a/index.js +++ b/index.js @@ -608,6 +608,18 @@ xmpp.on("status", (status) => { })); } }); + + // If status is 'disconnect', attempt to reconnect after 5 seconds + if (status === 'disconnect') { + console.log(`${colors.yellow("[WARN]")} XMPP disconnected, attempting to reconnect in 5 seconds...`); + setTimeout(() => { + console.log(`${colors.yellow("[WARN]")} Attempting to reconnect to XMPP...`); + xmpp.start().catch((err) => { + console.log(`${colors.red("[ERROR]")} XMPP failed to start: ${err}.`); + setTimeout(start, 5000); + }); + }, 5000); + } }); xmpp.reconnect.on("reconnecting", () => {