add more info to mc-status
This commit is contained in:
parent
fe7f1f8b43
commit
490fdf26b3
1 changed files with 22 additions and 1 deletions
|
@ -56,6 +56,8 @@ class GatewayClient {
|
|||
this.ws = null;
|
||||
this.token = null;
|
||||
this.user = null;
|
||||
this.wasEverReady = false;
|
||||
this.isReady = false;
|
||||
this.onEvent = (e) => {};
|
||||
}
|
||||
|
||||
|
@ -111,6 +113,8 @@ class GatewayClient {
|
|||
case messageTypes.READY: {
|
||||
console.log("gateway: READY");
|
||||
this.user = message.d.user;
|
||||
this.wasEverReady = true;
|
||||
this.isReady = true;
|
||||
break;
|
||||
}
|
||||
case messageTypes.EVENT: {
|
||||
|
@ -128,6 +132,7 @@ class GatewayClient {
|
|||
});
|
||||
this.ws.on("close", () => {
|
||||
console.log("gateway: closed, reconnecting in 4000ms");
|
||||
this.isReady = false;
|
||||
setTimeout(() => {
|
||||
console.log("gateway: reconnecting");
|
||||
this.connect(token);
|
||||
|
@ -136,6 +141,7 @@ class GatewayClient {
|
|||
this.ws.on("error", (e) => {
|
||||
console.error("gateway: error", e);
|
||||
console.log("gateway: reconnecting in 4000ms due to previous error");
|
||||
this.isReady = false;
|
||||
setTimeout(() => {
|
||||
console.log("gateway: reconnecting");
|
||||
this.connect(token);
|
||||
|
@ -174,9 +180,22 @@ class Bridge {
|
|||
this.userRequestedServerJob();
|
||||
return;
|
||||
} else if (e.message.content === "!:mc-status") {
|
||||
const message = `:scroll: **Server information**
|
||||
Player Count: **${this.playerCount}**
|
||||
${this.serverStartedAt ? `Started: <t:${Math.floor(this.serverStartedAt/1000)}:R>` : "Started: [server is closed]"}
|
||||
|
||||
:gear: **Runtime Information**:
|
||||
rconConnection exists: \`${!!this.rconConnection}\`
|
||||
process exists: \`${!!this.process}\`
|
||||
gatewayConnection.user exists: \`${!!this.gatewayConnection.user}\`
|
||||
rconConnection.hasAuthed: \`${this.rconConnection.hasAuthed}\`
|
||||
gatewayConnection.isReady: \`${this.gatewayConnection.isReady}\`
|
||||
gatewayConnection.wasEverReady: \`${this.gatewayConnection.wasEverReady}\`
|
||||
`;
|
||||
|
||||
this.sendBridgeMessageAs(TARGET_GUILD_ID,
|
||||
TARGET_CHANNEL_ID,
|
||||
`:scroll: **Server information**\n**Player Count**: ${this.playerCount}\n**Started**: <t:${Math.floor(this.serverStartedAt/1000)}:R>`,
|
||||
message,
|
||||
null,
|
||||
null
|
||||
);
|
||||
|
@ -280,12 +299,14 @@ class Bridge {
|
|||
console.log(`server process: exited with code ${code}`);
|
||||
this.sendBridgeMessageAs(TARGET_GUILD_ID, TARGET_CHANNEL_ID, ":zap: Server is now closed.", null, null);
|
||||
this.process = null;
|
||||
this.serverStartedAt = null;
|
||||
});
|
||||
|
||||
this.process.on("error", (e) => {
|
||||
console.error("server process: error", e);
|
||||
this.sendBridgeMessageAs(TARGET_GUILD_ID, TARGET_CHANNEL_ID, ":flushed: Server process error.", null, null);
|
||||
this.process = null;
|
||||
this.serverStartedAt = null;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue