Skip to content

Commit

Permalink
feat(experimental): valfisk intelligence
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanccn committed Jun 20, 2024
1 parent d8a4372 commit 410784c
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/commands/fun/intelligence.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
use std::env;

use color_eyre::eyre::Result;
use serde::Deserialize;
use serde_json::json;

use crate::{reqwest_client::HTTP, Context};

static ASK_API_URL: &str = "https://intelligence.valfisk.ryanccn.dev/ask";

#[derive(Deserialize)]
struct AskResponse {
response: String,
}

/// Ask Valfisk Intelligence™
#[poise::command(slash_command, guild_only)]
#[tracing::instrument(skip(ctx), fields(channel = ctx.channel_id().get(), author = ctx.author().id.get()))]
pub async fn ask(
ctx: Context<'_>,
#[description = "The query to ask about"] query: String,
) -> Result<()> {
ctx.defer().await?;

let secret = env::var("INTELLIGENCE_SECRET")?;
let resp: AskResponse = HTTP
.post(ASK_API_URL)
.bearer_auth(secret)
.json(&json!({ "query": query }))
.send()
.await?
.json()
.await?;

ctx.say(&resp.response).await?;

Ok(())
}
1 change: 1 addition & 0 deletions src/commands/fun/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod autoreply;
pub mod intelligence;
pub mod owo;
pub mod pomelo;
pub mod shiggy;
1 change: 1 addition & 0 deletions src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub fn to_vec() -> Vec<
command!(useful, translate),
command!(useful, suppress_embeds),
command!(fun, autoreply),
command!(fun, intelligence, ask),
command!(fun, owo),
command!(fun, pomelo),
command!(fun, shiggy),
Expand Down

0 comments on commit 410784c

Please sign in to comment.