diff --git a/lib/client.js b/lib/client.js index 2ec1b9f..c4dac01 100644 --- a/lib/client.js +++ b/lib/client.js @@ -362,7 +362,9 @@ export default class Client extends EventTarget { } break; case "ERROR": - this.dispatchEvent(new CustomEvent("error", { detail: "Fatal IRC error: " + msg.params[0] })); + this.dispatchEvent(new CustomEvent("error", { + detail: "Fatal IRC error: " + msg.params[0], + })); this.disconnect(); break; case irc.ERR_PASSWDMISMATCH: @@ -372,15 +374,27 @@ export default class Client extends EventTarget { case irc.ERR_UNAVAILRESOURCE: case irc.ERR_NOPERMFORHOST: case irc.ERR_YOUREBANNEDCREEP: - this.dispatchEvent(new CustomEvent("error", { detail: "Error (" + msg.command + "): " + msg.params[msg.params.length - 1] })); + this.dispatchEvent(new CustomEvent("error", { + detail: "Error (" + msg.command + "): " + msg.params[msg.params.length - 1], + })); if (this.status != Client.Status.REGISTERED) { this.disconnect(); } break; case "FAIL": + if (this.status === Client.Status.REGISTERED) { + break; + } + let reason = msg.params[msg.params.length - 1]; if (msg.params[0] === "BOUNCER" && msg.params[2] === "BIND") { this.dispatchEvent(new CustomEvent("error", { - detail: "Failed to bind to bouncer network: " + msg.params[3], + detail: "Failed to bind to bouncer network: " + reason, + })); + this.disconnect(); + } + if (msg.params[1] === "ACCOUNT_REQUIRED") { + this.dispatchEvent(new CustomEvent("error", { + detail: reason, })); this.disconnect(); }