From 5ba67c5da546a7e14d02ca3154f9d02d4dced58c Mon Sep 17 00:00:00 2001 From: Matt Fellenz Date: Mon, 27 May 2024 12:25:02 -0700 Subject: [PATCH] Ignore text before code block --- bot/src/bot.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bot/src/bot.rs b/bot/src/bot.rs index 1eea2ac..60308bc 100644 --- a/bot/src/bot.rs +++ b/bot/src/bot.rs @@ -243,11 +243,15 @@ struct CodeBlock { #[async_trait] impl<'a> poise::PopArgument<'a> for CodeBlock { async fn pop_from( - args: &'a str, + mut args: &'a str, attachment_index: usize, ctx: &serenity::prelude::Context, message: &poise::serenity_prelude::Message, ) -> Result<(&'a str, usize, Self), (PoiseError, Option)> { + if let Some(code_block_start) = args.find("```") { + args = &args[code_block_start..]; + } + let (rest, attachment_index, code_block) = poise::prefix_argument::CodeBlock::pop_from(args, attachment_index, ctx, message).await?;