Skip to content

Commit c5d3207

Browse files
committed
Ignore text before code block
Fixes #15
1 parent a19a8ff commit c5d3207

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

bot/src/bot.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,15 @@ struct CodeBlock {
243243
#[async_trait]
244244
impl<'a> poise::PopArgument<'a> for CodeBlock {
245245
async fn pop_from(
246-
args: &'a str,
246+
mut args: &'a str,
247247
attachment_index: usize,
248248
ctx: &serenity::prelude::Context,
249249
message: &poise::serenity_prelude::Message,
250250
) -> Result<(&'a str, usize, Self), (PoiseError, Option<String>)> {
251+
if let Some(code_block_start) = args.find("```") {
252+
args = &args[code_block_start..];
253+
}
254+
251255
let (rest, attachment_index, code_block) =
252256
poise::prefix_argument::CodeBlock::pop_from(args, attachment_index, ctx, message).await?;
253257

0 commit comments

Comments
 (0)