From 2213436998c1c8b26f7e3afa035f2cb1f1a4281b Mon Sep 17 00:00:00 2001 From: Stachelbeere1248 Date: Tue, 18 Feb 2025 20:20:44 +0100 Subject: [PATCH] fix: local api specs --- src/commands/helpstart.rs | 2 +- src/data/helpstart_api.rs | 9 ++------- src/error.rs | 2 +- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/commands/helpstart.rs b/src/commands/helpstart.rs index 3076187..983ff3b 100644 --- a/src/commands/helpstart.rs +++ b/src/commands/helpstart.rs @@ -20,7 +20,7 @@ pub(crate) async fn helpstart(ctx: Context<'_>) -> Result<(), Error> { .map(|a| name(&ctx.data().caches, &ctx.data().clients.general, a.uuid)) .collect::>(); let mc_accounts = futures::future::try_join_all(mc_accounts).await?; - let bots = fetch_all(&ctx.data().clients.local_api_client).await?.bots; + let bots = fetch_all(&ctx.data().clients.local_api_client).await?; let usable = bots .iter() .filter_map(|b| { diff --git a/src/data/helpstart_api.rs b/src/data/helpstart_api.rs index 5ada940..0ddd5d4 100644 --- a/src/data/helpstart_api.rs +++ b/src/data/helpstart_api.rs @@ -3,11 +3,6 @@ use getset::Getters; use reqwest::Client; use serde::Deserialize; -#[derive(Deserialize, Getters)] -pub(crate) struct Response { - pub(crate) bots: Vec, -} - #[derive(Deserialize, Getters)] #[getset(get = "pub(crate)")] pub(crate) struct Bot { @@ -36,9 +31,9 @@ pub(crate) enum ListType { Blacklist, } -pub(crate) async fn fetch_all(client: &Client) -> Result { +pub(crate) async fn fetch_all(client: &Client) -> Result, Error> { let url = "https://localhost:6969/list"; - let response: Response = client + let response: Vec = client .get(url) .send() .await? diff --git a/src/error.rs b/src/error.rs index 40898c3..96bf5c0 100644 --- a/src/error.rs +++ b/src/error.rs @@ -24,7 +24,7 @@ impl Display for Error { fn fmt(&self, f: &mut Formatter) -> FmtResult { match self { Error::SqlxError(e) => write!(f, "SQLx Error: {}", e), - Error::ApiError(e) => write!(f, "HTTPS Error (Hypixel / Mojang API):\n{}", e), + Error::ApiError(e) => write!(f, "HTTPS Error:\n{}", e), Error::SerenityError(e) => write!(f, "Discord Error:\n {}", e), Error::OnCooldown(d) => write!( f,