uberbot/src/commands/pkg.rs

34 lines
726 B
Rust

use crate::bot::{Command, Context};
use async_trait::async_trait;
//use std::collections::HashMap;
use reqwest::Client;
#[derive(Default)]
pub struct Pkg {
client: Client,
}
impl Pkg {
pub fn new() -> Self {
Pkg {
client: Client::new(),
}
}
}
#[async_trait]
impl Command for Pkg {
async fn execute(&mut self, msg: Context<'_>) -> anyhow::Result<String> {
let start = Pkg::new();
println!("{:?}",msg.content);
let body = start.client
.get(format!(
"https://archlinux.org/packages/search/json/?name={:?}",
msg.content
))
.send()
.await?.text().await?;
Ok(body)
}
}