Fix this proj

This commit is contained in:
Soph :3 2024-08-27 22:28:10 +03:00
parent 562df25d0a
commit c7c3c06170
Signed by: sophie
GPG key ID: EDA5D222A0C270F2
2 changed files with 20 additions and 17 deletions

View file

@ -22,13 +22,13 @@ rcon.on("auth", () => {
}); });
rcon.on("end", () => { rcon.on("end", () => {
console.log("RCON ended. Reconnecting in 1000ms.") console.log("RCON ended. Reconnecting in 2000ms.")
if(rconReconnectTimeout) { if(rconReconnectTimeout) {
clearTimeout(rconReconnectTimeout); clearTimeout(rconReconnectTimeout);
} }
rconReconnectTimeout = setTimeout(() => { rconReconnectTimeout = setTimeout(() => {
rcon.connect() rcon.connect()
}, 1000) }, 2000)
}) })
client.once(Events.ClientReady, async (readyClient) => { client.once(Events.ClientReady, async (readyClient) => {
console.log(`Ready! Logged in as ${readyClient.user.tag}`); 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")); playerUsernames = playerUsernames.concat(f[1].content.split("\n"));
if (!f[1].reactions.resolve("✅")) await f[1].react("✅"); if (!f[1].reactions.resolve("✅")) await f[1].react("✅");
let member = f[1].member; let member = f[1].member;
try {
if (!member) member = await f[1].guild.members.fetch(f[1].author.id); if (!member) member = await f[1].guild.members.fetch(f[1].author.id);
} catch {
continue;
}
if (config.changeNicknames) { if (config.changeNicknames) {
if (member.nickname !== f[1].content.split("\n")[0]) { if (member.nickname !== f[1].content.split("\n")[0]) {
try { try {

18
rcon.ts
View file

@ -92,17 +92,17 @@ export class Rcon extends (EventEmitter as new () => TypedEmitter<Events>) {
public connect = (): void => { public connect = (): void => {
if (this.tcp) { if (this.tcp) {
this._tcpSocket = net.createConnection(this.port, this.host); this._tcpSocket = net.createConnection(this.port, this.host);
this._tcpSocket this._tcpSocket.on("data", (data) => {
.on("data", (data) => {
this._tcpSocketOnData(data); this._tcpSocketOnData(data);
}) });
.on("connect", () => { this._tcpSocket.on("connect", () => {
this.socketOnConnect(); this.socketOnConnect();
}) });
.on("error", (err) => { this._tcpSocket.on("error", (err) => {
this.emit("error", err); //this.emit("error", err);
}) this.socketOnEnd()
.on("end", () => { });
this._tcpSocket.on("end", () => {
this.socketOnEnd(); this.socketOnEnd();
}); });
} else { } else {