Compare commits

..

2 Commits

Author SHA1 Message Date
614b40ca08
rm dockerfile 2026-05-07 00:23:52 -04:00
d5f9c0ead6
Logging better 2026-05-07 00:22:32 -04:00
3 changed files with 6 additions and 4 deletions

View File

@ -63,20 +63,24 @@ pub async fn event_handler(
let http_response = request(data.server.api_address())
.await
.expect("Error executing request");
trace!("Got HTTP response");
let results = data.server.parse(
http_response
.text()
.await
.expect("Response had no body text"),
);
trace!("Parsed response");
match &results {
ServerResponse::Offline => {
info!("Got status: Offline");
ctx.set_presence(
Some(ActivityData::custom("Server offline!")),
serenity::OnlineStatus::DoNotDisturb,
);
}
ServerResponse::Online(online_info) => {
info!("Got status: Online");
ctx.set_presence(
Some(ActivityData::custom(format!(
"{}/{} online, v{}",

View File

@ -13,6 +13,7 @@ use std::path::Path;
#[tokio::main]
async fn main() {
env_logger::init();
info!("Starting up!");
let config = config_parser::parse_configs(Path::new("config.json"))
.expect("Could not parse config.json");
info!("Got config file");

View File

@ -6,9 +6,6 @@ const USER_AGENT: &str = "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36
pub async fn request(url: Url) -> Result<Response, reqwest::Error> {
let client = reqwest::Client::new();
let mut request = reqwest::Request::new(reqwest::Method::GET, url);
request.headers_mut().append(
"User-Agent",
HeaderValue::from_str(USER_AGENT).expect("Could not build header"),
);
request.headers_mut().append("User-Agent", HeaderValue::from_str(USER_AGENT).expect("Could not build header"));
client.execute(request).await
}