fix: local api specs
This commit is contained in:
parent
96fc2d54c5
commit
2213436998
3 changed files with 4 additions and 9 deletions
|
@ -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))
|
.map(|a| name(&ctx.data().caches, &ctx.data().clients.general, a.uuid))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let mc_accounts = futures::future::try_join_all(mc_accounts).await?;
|
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
|
let usable = bots
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|b| {
|
.filter_map(|b| {
|
||||||
|
|
|
@ -3,11 +3,6 @@ use getset::Getters;
|
||||||
use reqwest::Client;
|
use reqwest::Client;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
#[derive(Deserialize, Getters)]
|
|
||||||
pub(crate) struct Response {
|
|
||||||
pub(crate) bots: Vec<Bot>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Deserialize, Getters)]
|
#[derive(Deserialize, Getters)]
|
||||||
#[getset(get = "pub(crate)")]
|
#[getset(get = "pub(crate)")]
|
||||||
pub(crate) struct Bot {
|
pub(crate) struct Bot {
|
||||||
|
@ -36,9 +31,9 @@ pub(crate) enum ListType {
|
||||||
Blacklist,
|
Blacklist,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn fetch_all(client: &Client) -> Result<Response, Error> {
|
pub(crate) async fn fetch_all(client: &Client) -> Result<Vec<Bot>, Error> {
|
||||||
let url = "https://localhost:6969/list";
|
let url = "https://localhost:6969/list";
|
||||||
let response: Response = client
|
let response: Vec<Bot> = client
|
||||||
.get(url)
|
.get(url)
|
||||||
.send()
|
.send()
|
||||||
.await?
|
.await?
|
||||||
|
|
|
@ -24,7 +24,7 @@ impl Display for Error {
|
||||||
fn fmt(&self, f: &mut Formatter) -> FmtResult {
|
fn fmt(&self, f: &mut Formatter) -> FmtResult {
|
||||||
match self {
|
match self {
|
||||||
Error::SqlxError(e) => write!(f, "SQLx Error: {}", e),
|
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::SerenityError(e) => write!(f, "Discord Error:\n {}", e),
|
||||||
Error::OnCooldown(d) => write!(
|
Error::OnCooldown(d) => write!(
|
||||||
f,
|
f,
|
||||||
|
|
Loading…
Add table
Reference in a new issue