it works
This commit is contained in:
parent
411fb28ae0
commit
37fe9a8687
|
@ -2,8 +2,9 @@ use crate::bot::{Command, Context};
|
|||
use async_trait::async_trait;
|
||||
//use std::collections::HashMap;
|
||||
use reqwest::Client;
|
||||
use serde_json;
|
||||
use serde_json::{Map,Value};
|
||||
use serde::{Deserialize};
|
||||
use tracing::Level;
|
||||
|
||||
|
||||
#[derive(Default)]
|
||||
|
@ -19,15 +20,17 @@ impl Pkg {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct pkgd{
|
||||
results: result,
|
||||
version: u32,
|
||||
results: Vec<result>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct result {
|
||||
pkgname: String,
|
||||
repo: String,
|
||||
pkgver: String,
|
||||
pkgdesc: String,
|
||||
}
|
||||
#[async_trait]
|
||||
|
@ -43,7 +46,8 @@ impl Command for Pkg {
|
|||
.send()
|
||||
.await?.text().await?;
|
||||
let b: pkgd = serde_json::from_str(&body)?;
|
||||
|
||||
Ok(format!("{}: {}", b.results.pkgname,b.results.pkgdesc))
|
||||
let c = &b.results[0];
|
||||
tracing::debug!("{:?}",b);
|
||||
Ok(format!("{} (v: {}): {}",c.pkgname,c.pkgver,c.pkgdesc))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue