Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,41 @@ pub async fn eminem(ctx: Context<'_>) -> Result<(), anyhow::Error> {
Ok(())
}

/// alfred fox
///
/// This command fetches a random fluffy foxy with a 1/1000 chance of foxy jumpscare.
#[poise::command(
slash_command,
prefix_command,
track_edits,
broadcast_typing,
aliases("floof")
)]
pub async fn fox(ctx: Context<'_>) -> Result<(), anyhow::Error> {
const FOX_API_ENDPOINT: &str = "https://randomfox.ca/floof/";

if rand::random_range(1..=1000) == 67 {
// scary foxy (ᗒᗣᗕ)՞
ctx.say("https://tenor.com/fZEGeo3lNTk.gif").await?;
return Ok(());
}

// fluffy foxy (˶>⩊<˶)
let response = reqwest::get(FOX_API_ENDPOINT)
.await
.with_context(|| format!("Failed to fetch response from {FOX_API_ENDPOINT}"))?;
let payload = &response.text().await?;
let parsed = json::parse(payload)
.with_context(|| format!("Failed to parse response payload:\n{payload}"))?;
ctx.say(
parsed["image"]
.as_str()
.unwrap_or("response has unexpected structure"),
)
.await?;
Ok(())
}

/// alfred kleanthis
#[poise::command(slash_command, prefix_command, track_edits)]
pub async fn kleanthis(ctx: Context<'_>) -> Result<(), anyhow::Error> {
Expand Down
5 changes: 4 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ use poise::{
use tokio::sync::Mutex;

use crate::{
commands::{admin, cat, command_check, define, delfin, dog, eminem, kleanthis, tuff, typst},
commands::{
admin, cat, command_check, define, delfin, dog, eminem, fox, kleanthis, tuff, typst,
},
config::{CONFIG, Config},
state::State,
};
Expand Down Expand Up @@ -40,6 +42,7 @@ async fn main() -> Result<(), anyhow::Error> {
kleanthis(),
typst(),
tuff(),
fox(),
admin::toggle_command(),
],
// set up prefix
Expand Down