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", () => {
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;
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 {

18
rcon.ts
View file

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