New server

This commit is contained in:
August 2026-05-03 14:33:59 -04:00
parent a496f70cda
commit c2491f4542
Signed by: shibedrill
SSH Key Fingerprint: SHA256:M0m3JW1s38BgO2t0fG146Yxd9OJ2IOqkvCAsuRHQ6Pw
4 changed files with 22 additions and 8 deletions

View File

@ -24,5 +24,10 @@ async fn main() {
std::env::var("TOKEN_BOT_MC_MCHPRS").unwrap(),
"Project MCRV".into(),
);
let dawn = Minecraft::new(
Url::try_from("https://api.mcstatus.io/v2/status/java/mchprs.shibedrill.site").unwrap(),
std::env::var("TOKEN_BOT_MC_DAWN").unwrap(),
"Dawn Group".into(),
);
join!(mchprs.run(), gamerzone.run());
}

View File

@ -3,7 +3,10 @@ use reqwest::{Client, Request};
use serenity::*;
use url::Url;
use crate::{funcs, types::{self, ServerResponse}};
use crate::{
funcs,
types::{self, ServerResponse},
};
#[derive(serde::Deserialize, Debug)]
struct ServerSummary {
@ -58,7 +61,7 @@ impl Minecraft {
data.online,
Some(players.online as u32),
Some(players.max as u32),
Some(data.version.name_raw)
Some(data.version.name_raw),
))
} else {
Ok(ServerResponse::new(data.online, None, None, None))

View File

@ -46,7 +46,7 @@ impl Scpsl {
data.online,
playercount_unwrapped.first().copied(),
playercount_unwrapped.get(1).copied(),
None
None,
))
}

View File

@ -4,16 +4,21 @@ pub struct ServerResponse {
online: bool,
players: Option<u32>,
max: Option<u32>,
version: Option<String>
version: Option<String>,
}
impl ServerResponse {
pub fn new(online: bool, players: Option<u32>, max: Option<u32>, version: Option<String>) -> Self {
pub fn new(
online: bool,
players: Option<u32>,
max: Option<u32>,
version: Option<String>,
) -> Self {
ServerResponse {
online,
players,
max,
version
version,
}
}
@ -38,7 +43,8 @@ impl ServerResponse {
}
pub fn to_string(&self) -> String {
format!("{} {} {}",
format!(
"{} {} {}",
if let Some(players) = self.players {
if let Some(max) = self.max {
format!("{}/{}", players, max)