uberbot/src/commands/pkg.rs

34 lines
726 B
Rust
Raw Normal View History

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