New server
This commit is contained in:
parent
a496f70cda
commit
c2491f4542
@ -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());
|
||||
}
|
||||
|
||||
@ -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))
|
||||
|
||||
@ -46,7 +46,7 @@ impl Scpsl {
|
||||
data.online,
|
||||
playercount_unwrapped.first().copied(),
|
||||
playercount_unwrapped.get(1).copied(),
|
||||
None
|
||||
None,
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
16
src/types.rs
16
src/types.rs
@ -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)
|
||||
@ -50,7 +56,7 @@ impl ServerResponse {
|
||||
},
|
||||
self.online,
|
||||
if let Some(version) = &self.version {
|
||||
version.to_string()
|
||||
version.to_string()
|
||||
} else {
|
||||
"N/A".into()
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user