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 async_trait::async_trait;
|
||||||
//use std::collections::HashMap;
|
//use std::collections::HashMap;
|
||||||
use reqwest::Client;
|
use reqwest::Client;
|
||||||
use serde_json;
|
use serde_json::{Map,Value};
|
||||||
use serde::{Deserialize};
|
use serde::{Deserialize};
|
||||||
|
use tracing::Level;
|
||||||
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
@ -19,15 +20,17 @@ impl Pkg {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
struct pkgd{
|
struct pkgd{
|
||||||
results: result,
|
version: u32,
|
||||||
|
results: Vec<result>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
struct result {
|
struct result {
|
||||||
pkgname: String,
|
pkgname: String,
|
||||||
repo: String,
|
repo: String,
|
||||||
|
pkgver: String,
|
||||||
pkgdesc: String,
|
pkgdesc: String,
|
||||||
}
|
}
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
|
@ -43,7 +46,8 @@ impl Command for Pkg {
|
||||||
.send()
|
.send()
|
||||||
.await?.text().await?;
|
.await?.text().await?;
|
||||||
let b: pkgd = serde_json::from_str(&body)?;
|
let b: pkgd = serde_json::from_str(&body)?;
|
||||||
|
let c = &b.results[0];
|
||||||
Ok(format!("{}: {}", b.results.pkgname,b.results.pkgdesc))
|
tracing::debug!("{:?}",b);
|
||||||
|
Ok(format!("{} (v: {}): {}",c.pkgname,c.pkgver,c.pkgdesc))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue