diff --git a/index.ts b/index.ts index 2c69943..85f9368 100644 --- a/index.ts +++ b/index.ts @@ -22,13 +22,13 @@ rcon.on("auth", () => { }); rcon.on("end", () => { - console.log("RCON ended. Reconnecting in 1000ms.") + console.log("RCON ended. Reconnecting in 2000ms.") if(rconReconnectTimeout) { clearTimeout(rconReconnectTimeout); } rconReconnectTimeout = setTimeout(() => { rcon.connect() - }, 1000) + }, 2000) }) client.once(Events.ClientReady, async (readyClient) => { console.log(`Ready! Logged in as ${readyClient.user.tag}`); @@ -42,8 +42,11 @@ client.once(Events.ClientReady, async (readyClient) => { playerUsernames = playerUsernames.concat(f[1].content.split("\n")); if (!f[1].reactions.resolve("✅")) await f[1].react("✅"); let member = f[1].member; - - if (!member) member = await f[1].guild.members.fetch(f[1].author.id); + try { + if (!member) member = await f[1].guild.members.fetch(f[1].author.id); + } catch { + continue; + } if (config.changeNicknames) { if (member.nickname !== f[1].content.split("\n")[0]) { try { diff --git a/rcon.ts b/rcon.ts index 69de561..e30dfb3 100644 --- a/rcon.ts +++ b/rcon.ts @@ -92,19 +92,19 @@ export class Rcon extends (EventEmitter as new () => TypedEmitter) { public connect = (): void => { if (this.tcp) { this._tcpSocket = net.createConnection(this.port, this.host); - this._tcpSocket - .on("data", (data) => { - this._tcpSocketOnData(data); - }) - .on("connect", () => { - this.socketOnConnect(); - }) - .on("error", (err) => { - this.emit("error", err); - }) - .on("end", () => { - this.socketOnEnd(); - }); + this._tcpSocket.on("data", (data) => { + this._tcpSocketOnData(data); + }); + this._tcpSocket.on("connect", () => { + this.socketOnConnect(); + }); + this._tcpSocket.on("error", (err) => { + //this.emit("error", err); + this.socketOnEnd() + }); + this._tcpSocket.on("end", () => { + this.socketOnEnd(); + }); } else { this._udpSocket = dgram.createSocket("udp4"); this._udpSocket