feat(status): add emoji support for RYZEN and XEON hosts in status monitoring

This commit is contained in:
2025-10-31 08:06:48 +01:00
parent 4bb33bea89
commit 17c00211da
2 changed files with 89 additions and 71 deletions

View File

@@ -6,6 +6,9 @@ CLIENT_ID=your_discord_client_id_here
EMOJI_STATUS_ONLINE=<a:online:1432684754276323431>
EMOJI_STATUS_OFFLINE=<a:offline:1432684900175183882>
EMOJI_RYZEN=<:ryzen:1433711892009848833>
EMOJI_XEON=<:xeon:1433711864168054855>
# Database Configuration
DB_HOST=localhost
DB_PORT=5432

View File

@@ -2,9 +2,16 @@ import ping from "ping";
import * as cron from 'cron';
import { ActivityType, Client } from "discord.js";
import { Host } from "../type";
import { loadEnvFile } from "process";
import { configDotenv } from "dotenv";
configDotenv();
export class StatusService {
private EMOJI_RYZEN : string = process.env.EMOJI_RYZEN as string;
private EMOJI_XEON : string = process.env.EMOJI_XEON as string;
public hosts: Host[] = [
{
'host': 'https://protojx.com',
@@ -20,31 +27,37 @@ export class StatusService {
},
{
host: '5.178.99.4',
name: 'RYZEN 01 🖥️',
name: 'RYZEN 01 ' + this.EMOJI_RYZEN,
alive: false,
type: 'ping'
},
{
host: '5.178.99.6',
name: 'RYZEN 02 🖥️',
name: 'RYZEN 02 ' + this.EMOJI_RYZEN,
alive: false,
type: 'ping'
},
{
host: '5.178.99.5',
name: 'RYZEN 03 🖥️',
name: 'RYZEN 03 ' + this.EMOJI_RYZEN,
alive: false,
type: 'ping'
},
{
host: '154.16.254.10',
name: 'RYZEN7 04 ' + this.EMOJI_RYZEN,
alive: false,
type: 'ping'
},
{
host: '5.178.99.177',
name: 'XEON 01 (2697A V4) 🖥️',
name: 'XEON 01 (2697A V4) ' + this.EMOJI_XEON,
alive: false,
type: 'ping'
},
{
host: '5.178.99.248',
name: 'XEON 02 (2687W V4) 🖥️',
name: 'XEON 02 (2687W V4) ' + this.EMOJI_XEON,
alive: false,
type: 'ping'
},
@@ -60,7 +73,7 @@ export class StatusService {
alive: false,
type: 'ping'
}
]
];
private client: Client | null = null;
@@ -93,9 +106,11 @@ export class StatusService {
const hosts = this.hosts.length;
const hostsAlive = this.hosts.filter((h) => h.alive).length;
this.client.user?.setActivity({name: (
this.client.user?.setActivity({
name: (
hosts == hostsAlive ? '✅ All services are online.' : `📛 ${hosts - hostsAlive} service${hosts - hostsAlive > 1 ? 's' : ''} offline.`
), type: ActivityType.Watching});
), type: ActivityType.Watching
});
}
}