From 695922e3b6b87a3fa53c15b7590e42551246fb2a Mon Sep 17 00:00:00 2001 From: August Date: Mon, 26 Jan 2026 22:54:53 +0000 Subject: [PATCH] Add deer game --- Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 2 +- src/command/devel.rs | 15 +++++++++------ src/command/fun.rs | 31 ++++++++++++++++++++++++++++++- src/main.rs | 3 ++- 6 files changed, 44 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 42051d4..c4d6dd8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2378,7 +2378,7 @@ dependencies = [ [[package]] name = "shibe-bot" -version = "1.1.0" +version = "1.2.0" dependencies = [ "anyhow", "dotenvy", diff --git a/Cargo.toml b/Cargo.toml index 1f3b5f7..a6bb190 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "shibe-bot" description = "A Discord bot written in Rust, using Poise." license = "MIT" readme = "README.md" -version = "1.1.0" +version = "1.2.0" edition = "2021" build = "build.rs" diff --git a/README.md b/README.md index b74e19f..02c4fec 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Shibe Bot 1.1.0 +# Shibe Bot 1.2.0 [![Rust](https://github.com/shibedrill/shibe-bot/actions/workflows/rust.yml/badge.svg)](https://github.com/shibedrill/shibe-bot/actions/workflows/rust.yml) [![GitHub License](https://img.shields.io/github/license/shibedrill/shibe-bot)](LICENSE.txt) diff --git a/src/command/devel.rs b/src/command/devel.rs index 71031c9..2468769 100644 --- a/src/command/devel.rs +++ b/src/command/devel.rs @@ -1,5 +1,8 @@ -#[cfg(feature="self-update")] -use {std::convert::Infallible, std::os::unix::process::CommandExt, octocrab, std::io::Write, self_replace, zip, minreq}; +#[cfg(feature = "self-update")] +use { + minreq, octocrab, self_replace, std::convert::Infallible, std::io::Write, + std::os::unix::process::CommandExt, zip, +}; use crate::Context; use crate::Error; @@ -34,7 +37,7 @@ pub async fn version(ctx: Context<'_>) -> Result<(), Error> { Ok(()) } -#[cfg(feature="self-update")] +#[cfg(feature = "self-update")] /// Update the bot remotely (requires Github CI) #[poise::command(slash_command, owners_only, hide_in_help)] pub async fn update( @@ -114,7 +117,7 @@ pub async fn say( Ok(()) } -#[cfg(feature="self-update")] +#[cfg(feature = "self-update")] fn self_update() -> Result { let artifact_url = "https://nightly.link/shibedrill/shibe-bot/workflows/rust/main/artifact.zip"; let tempdir = tempfile::Builder::new().prefix("shibe-bot").tempdir()?; @@ -167,11 +170,11 @@ fn self_update() -> Result { mod test { #[cfg(test)] - #[cfg(feature="self-update")] + #[cfg(feature = "self-update")] use {crate::Error, std::convert::Infallible}; #[test] - #[cfg(feature="self-update")] + #[cfg(feature = "self-update")] fn test_self_update() -> Result { use crate::command::devel::self_update; use pretty_env_logger; diff --git a/src/command/fun.rs b/src/command/fun.rs index 7410212..53d6e57 100644 --- a/src/command/fun.rs +++ b/src/command/fun.rs @@ -1,7 +1,13 @@ +use std::time::Duration; + use crate::Context; use crate::Error; +use poise::serenity_prelude::CacheHttp; +use poise::serenity_prelude::ShardMessenger; +use poise::serenity_prelude::client; use poise::serenity_prelude as serenity; +use poise::serenity_prelude::futures::TryFutureExt; use rand::seq::IndexedRandom; use rand::Rng; @@ -91,7 +97,7 @@ pub async fn curbstomp( &format!("{} made {} eat pavement.", ctx.author(), target) }; ctx.say(response).await?; - info!("Executed command `whack` successfully"); + info!("Executed command `curbstomp` successfully"); Ok(()) } @@ -180,3 +186,26 @@ pub async fn deer(ctx: Context<'_>) -> Result<(), Error> { info!("Executed command `deer` successfully"); Ok(()) } + +/// Deer game! First to react wins. +#[poise::command(slash_command, global_cooldown = 20)] +pub async fn game(ctx: Context<'_>) -> Result<(), Error> { + ctx.say("Deer game! React to the :deer: first to win.") + .await?; + + std::thread::sleep(Duration::from_secs(3)); + + let reply = ctx.say(":deer:").await?; + let deer_msg = reply.message().await?; + let collector = deer_msg.await_reactions(ctx); + let collector = collector.timeout(Duration::from_secs(5)); + + if let Some(react) = collector.await { + let reacting_user = react.user(ctx.http()).await?; + ctx.say(format!("{} was first to react! yay!", reacting_user)).await?; + } else { + ctx.say("Nobody reacted. Game over