yo delta check this out
This commit is contained in:
parent
4c660c7e77
commit
411fb28ae0
|
@ -2,6 +2,9 @@ use crate::bot::{Command, Context};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
//use std::collections::HashMap;
|
//use std::collections::HashMap;
|
||||||
use reqwest::Client;
|
use reqwest::Client;
|
||||||
|
use serde_json;
|
||||||
|
use serde::{Deserialize};
|
||||||
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Pkg {
|
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]
|
#[async_trait]
|
||||||
impl Command for Pkg {
|
impl Command for Pkg {
|
||||||
async fn execute(&mut self, msg: Context<'_>) -> anyhow::Result<String> {
|
async fn execute(&mut self, msg: Context<'_>) -> anyhow::Result<String> {
|
||||||
|
@ -23,11 +37,13 @@ impl Command for Pkg {
|
||||||
println!("{:?}",msg.content);
|
println!("{:?}",msg.content);
|
||||||
let body = start.client
|
let body = start.client
|
||||||
.get(format!(
|
.get(format!(
|
||||||
"https://archlinux.org/packages/search/json/?name={:?}",
|
"https://archlinux.org/packages/search/json/?name={}",
|
||||||
msg.content
|
msg.content.unwrap()
|
||||||
))
|
))
|
||||||
.send()
|
.send()
|
||||||
.await?.text().await?;
|
.await?.text().await?;
|
||||||
Ok(body)
|
let b: pkgd = serde_json::from_str(&body)?;
|
||||||
|
|
||||||
|
Ok(format!("{}: {}", b.results.pkgname,b.results.pkgdesc))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue