Skip to content
Draft
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
21 changes: 21 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,27 @@ class Remix {
this.memberMap.set(member.id.server, data);
});

var sessionReconnects = 0;
this.client.on("ready", () => { sessionReconnects = 0; });
this.client.on("error", (err) => {
console.log("Client error:", err);
if (err?.data?.type === "InvalidSession") {
if (sessionReconnects >= 3) {
console.log("Too many InvalidSession errors. Giving up.");
return;
}
sessionReconnects++;
console.log("InvalidSession error. Attempting to reconnect (" + sessionReconnects + "/3)...");
setTimeout(() => {
if (config.token) {
this.client.loginBot(config.token);
} else {
this.client.login(config.login);
}
}, 5000);
}
});

console.log("Loading command files...");
this.handler = new CommandHandler(this.client, config.prefix);
this.handler.setReplyHandler((t, msg) => {
Expand Down