yo delta check this out

This commit is contained in:
gallant 2022-08-08 10:09:05 -05:00
parent 4c660c7e77
commit 411fb28ae0
1 changed files with 19 additions and 3 deletions

View File

@ -2,6 +2,9 @@ use crate::bot::{Command, Context};
use async_trait::async_trait;
//use std::collections::HashMap;
use reqwest::Client;
use serde_json;
use serde::{Deserialize};
#[derive(Default)]
pub struct Pkg {
@ -16,6 +19,17 @@ impl Pkg {
}
}
#[derive(Deserialize)]
struct pkgd{
results: result,
}
#[derive(Deserialize)]
struct result {
pkgname: String,
repo: String,
pkgdesc: String,
}
#[async_trait]
impl Command for Pkg {
async fn execute(&mut self, msg: Context<'_>) -> anyhow::Result<String> {
@ -23,11 +37,13 @@ impl Command for Pkg {
println!("{:?}",msg.content);
let body = start.client
.get(format!(
"https://archlinux.org/packages/search/json/?name={:?}",
msg.content
"https://archlinux.org/packages/search/json/?name={}",
msg.content.unwrap()
))
.send()
.await?.text().await?;
Ok(body)
let b: pkgd = serde_json::from_str(&body)?;
Ok(format!("{}: {}", b.results.pkgname,b.results.pkgdesc))
}
}