diff --git a/src/commands/mod.rs b/src/commands/mod.rs index e043fb6..d4f7046 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -68,6 +68,49 @@ pub async fn boop(ctx: Context<'_>) -> Result<(), Error> { 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> {