From c53b9d8bc2745921b6f071ff756d2316d223e7af Mon Sep 17 00:00:00 2001 From: Dany Sluijk Date: Fri, 6 Dec 2024 09:33:40 +0100 Subject: [PATCH] fix: correctly specify the results when less than the maximum are available --- src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index ef6756e..3a66a12 100644 --- a/src/main.rs +++ b/src/main.rs @@ -97,7 +97,7 @@ async fn leaderboard_total(ctx: Context<'_>) -> Result<(), Error> { .as_mut(), ); - let mut stylized_answer = table_rows[0..row_count].join("\n"); + let mut stylized_answer = table_rows[0..cmp::min(row_count, table_rows.len())].join("\n"); stylized_answer = format!("```\n{}```", truncate(&*stylized_answer, 1990)); ctx.say(stylized_answer).await?; @@ -151,7 +151,7 @@ async fn leaderboard_today(ctx: Context<'_>) -> Result<(), Error> { .as_mut(), ); - let mut stylized_answer = table_rows[0..row_count].join("\n"); + let mut stylized_answer = table_rows[0..cmp::min(row_count, table_rows.len())].join("\n"); stylized_answer = format!("```\n{}```", truncate(&*stylized_answer, 1990)); println!("{}", stylized_answer); ctx.say(stylized_answer).await?;