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(),
|
std::env::var("TOKEN_BOT_MC_MCHPRS").unwrap(),
|
||||||
"Project MCRV".into(),
|
"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());
|
join!(mchprs.run(), gamerzone.run());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,10 @@ use reqwest::{Client, Request};
|
|||||||
use serenity::*;
|
use serenity::*;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
use crate::{funcs, types::{self, ServerResponse}};
|
use crate::{
|
||||||
|
funcs,
|
||||||
|
types::{self, ServerResponse},
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(serde::Deserialize, Debug)]
|
#[derive(serde::Deserialize, Debug)]
|
||||||
struct ServerSummary {
|
struct ServerSummary {
|
||||||
@ -58,7 +61,7 @@ impl Minecraft {
|
|||||||
data.online,
|
data.online,
|
||||||
Some(players.online as u32),
|
Some(players.online as u32),
|
||||||
Some(players.max as u32),
|
Some(players.max as u32),
|
||||||
Some(data.version.name_raw)
|
Some(data.version.name_raw),
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
Ok(ServerResponse::new(data.online, None, None, None))
|
Ok(ServerResponse::new(data.online, None, None, None))
|
||||||
|
|||||||
@ -46,7 +46,7 @@ impl Scpsl {
|
|||||||
data.online,
|
data.online,
|
||||||
playercount_unwrapped.first().copied(),
|
playercount_unwrapped.first().copied(),
|
||||||
playercount_unwrapped.get(1).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,
|
online: bool,
|
||||||
players: Option<u32>,
|
players: Option<u32>,
|
||||||
max: Option<u32>,
|
max: Option<u32>,
|
||||||
version: Option<String>
|
version: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ServerResponse {
|
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 {
|
ServerResponse {
|
||||||
online,
|
online,
|
||||||
players,
|
players,
|
||||||
max,
|
max,
|
||||||
version
|
version,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,7 +43,8 @@ impl ServerResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_string(&self) -> String {
|
pub fn to_string(&self) -> String {
|
||||||
format!("{} {} {}",
|
format!(
|
||||||
|
"{} {} {}",
|
||||||
if let Some(players) = self.players {
|
if let Some(players) = self.players {
|
||||||
if let Some(max) = self.max {
|
if let Some(max) = self.max {
|
||||||
format!("{}/{}", players, max)
|
format!("{}/{}", players, max)
|
||||||
@ -50,7 +56,7 @@ impl ServerResponse {
|
|||||||
},
|
},
|
||||||
self.online,
|
self.online,
|
||||||
if let Some(version) = &self.version {
|
if let Some(version) = &self.version {
|
||||||
version.to_string()
|
version.to_string()
|
||||||
} else {
|
} else {
|
||||||
"N/A".into()
|
"N/A".into()
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user