this is a LOT
This commit is contained in:
parent
b04157e4ae
commit
cb17b18ad3
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1126,7 +1126,7 @@ checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "playerbot"
|
name = "playerbot"
|
||||||
version = "0.5.0"
|
version = "0.6.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"dotenvy",
|
"dotenvy",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "playerbot"
|
name = "playerbot"
|
||||||
version = "0.5.0"
|
version = "0.6.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -4,7 +4,7 @@ mod scpsl;
|
|||||||
mod types;
|
mod types;
|
||||||
use dotenvy::{self, dotenv};
|
use dotenvy::{self, dotenv};
|
||||||
use minecraft::Minecraft;
|
use minecraft::Minecraft;
|
||||||
use scpsl::SCPSL;
|
use scpsl::Scpsl;
|
||||||
use tokio::join;
|
use tokio::join;
|
||||||
use url::{self, Url};
|
use url::{self, Url};
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ async fn main() {
|
|||||||
Url::try_from("https://api.mcstatus.io/v2/status/java/mchprs.shibedrill.site").unwrap(),
|
Url::try_from("https://api.mcstatus.io/v2/status/java/mchprs.shibedrill.site").unwrap(),
|
||||||
std::env::var("TOKEN_BOT_MC_MCHPRS").unwrap(),
|
std::env::var("TOKEN_BOT_MC_MCHPRS").unwrap(),
|
||||||
);
|
);
|
||||||
let scpsl = SCPSL::new(
|
let scpsl = Scpsl::new(
|
||||||
Url::try_from("https://api.scplist.kr/api/servers/81460").unwrap(),
|
Url::try_from("https://api.scplist.kr/api/servers/81460").unwrap(),
|
||||||
std::env::var("TOKEN_BOT_SCPSL").unwrap(),
|
std::env::var("TOKEN_BOT_SCPSL").unwrap(),
|
||||||
);
|
);
|
||||||
|
@ -98,7 +98,7 @@ pub async fn event_handler(
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
info!("Got status: {}", status.to_string());
|
info!("Got status: {}", status.to_string());
|
||||||
|
|
||||||
funcs::set_presence(&ctx, status);
|
funcs::set_presence(ctx, status);
|
||||||
tokio::time::sleep(std::time::Duration::from_secs(30)).await;
|
tokio::time::sleep(std::time::Duration::from_secs(30)).await;
|
||||||
},
|
},
|
||||||
_ => Ok(()),
|
_ => Ok(()),
|
||||||
|
10
src/scpsl.rs
10
src/scpsl.rs
@ -12,16 +12,16 @@ struct ServerSummary {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct Data {
|
pub struct Data {
|
||||||
controller: SCPSL,
|
controller: Scpsl,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct SCPSL {
|
pub struct Scpsl {
|
||||||
url: Url,
|
url: Url,
|
||||||
token: String,
|
token: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SCPSL {
|
impl Scpsl {
|
||||||
pub fn new(url: Url, token: String) -> Self {
|
pub fn new(url: Url, token: String) -> Self {
|
||||||
Self { url, token }
|
Self { url, token }
|
||||||
}
|
}
|
||||||
@ -38,8 +38,8 @@ impl SCPSL {
|
|||||||
|
|
||||||
Ok(ServerResponse::new(
|
Ok(ServerResponse::new(
|
||||||
data.online,
|
data.online,
|
||||||
playercount_unwrapped.get(0).map(|u| u.clone()),
|
playercount_unwrapped.first().copied(),
|
||||||
playercount_unwrapped.get(1).map(|u| u.clone()),
|
playercount_unwrapped.get(1).copied(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user