uberbot/src/commands/pkg.rs
2022-08-06 17:49:06 -05:00

33 lines
687 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();
let body = self.client
.get(format!(
"https://archlinux.org/packages/search/json/?name={:?}",
msg.content
))
.send()
.await?.text().await?;
Ok(body)
}
}