use crate::{Context, Error}; use poise::serenity_prelude as serenity; pub mod invites; pub mod links; pub mod planning; pub mod schedule; pub mod utils; /// Boop the bot! #[poise::command(prefix_command, track_edits, slash_command)] pub async fn boop(ctx: Context<'_>) -> Result<(), Error> { let uuid_boop = ctx.id(); ctx.send(|m| { m.content("I want some boops! 🐇").components(|c| { c.create_action_row(|ar| { ar.create_button(|b| { b.style(serenity::ButtonStyle::Primary) .label("Boop me!") .custom_id(uuid_boop) }) }) }) }) .await?; let mut boop_count: i32 = 0; while let Some(mci) = serenity::CollectComponentInteraction::new(ctx.discord()) .channel_id(ctx.channel_id()) // .timeout(std::time::Duration::from_secs(1200)) .filter(move |mci| mci.data.custom_id == uuid_boop.to_string()) .await { boop_count += 1; let mut msg = mci.message.clone(); msg.edit(ctx.discord(), |m| { m.content(match boop_count { 2 => "Boop count: <:HamSmile:738765923401596991>".to_string(), 3 => "Boop 3".to_string(), 4 => "Boop four".to_string(), 5 => "Boop five".to_string(), 42 => "Boop count: 42, but what is the question?".to_string(), 43 => "Boop count: 43 A wild <@230001507481681920> appeared".to_string(), 69 => "Boop count: 69 Nice!".to_string(), 77 => "Boop count: 77 <@547041420733841409> Approved".to_string(), 308 => "Redirect 308: Boop count is in another castle".to_string(), 400 => "ERROR 400: Bad booping".to_string(), 401 => "ERROR 401: Unauthorized booping".to_string(), 402 => "ERROR 402: Payment required, no free boops".to_string(), 403 => "ERROR 403: Forbidden boop".to_string(), 404 => "ERROR 404: Boop count not found".to_string(), 420 => "Boop count: 420 Blaze it".to_string(), 666 => "Boop count: 666 😈".to_string(), 777 => "Boop count: 777 A wild <@117992484310745097> appeared".to_string(), _ => format!("Boop count: {}", boop_count), }) }) .await?; mci.create_interaction_response(ctx.discord(), |ir| { ir.kind(serenity::InteractionResponseType::DeferredUpdateMessage) }) .await?; } Ok(()) } #[poise::command(track_edits, slash_command)] pub async fn fix(ctx: Context<'_>) -> Result<(), Error> { let uuid_fix = ctx.id(); ctx.send(|m| { m.content("You want to fix things? Just press the magic fix button.").components(|c| { c.create_action_row(|ar| { ar.create_button(|b| { b.style(serenity::ButtonStyle::Success) .label("Fix") .custom_id(uuid_fix) }) }) }) }) .await?; let mut fix_count: i32 = 0; while let Some(mci) = serenity::CollectComponentInteraction::new(ctx.discord()) .channel_id(ctx.channel_id()) // .timeout(std::time::Duration::from_secs(1200)) .filter(move |mci| mci.data.custom_id == uuid_fix.to_string()) .await { fix_count += 1; let mut msg = mci.message.clone(); msg.edit(ctx.discord(), |m| { m.content(format!("Fixing failed try again. Attempt {}", fix_count)) }) .await?; mci.create_interaction_response(ctx.discord(), |ir| { ir.kind(serenity::InteractionResponseType::DeferredUpdateMessage) }) .await?; } Ok(()) } pub fn get_links( ) -> poise::Command> { // poise::Command { // subcommands: vec![ // links::eurosport::eurosport(), // links::eurosport::olympics(), // links::links(), // // Let's make sure poise isn't confused by the duplicate names! // ], // ..links::links() // }; links::links() }