Skip to content

Commit

Permalink
handle cases where leaderboard is empty (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
circuitsacul authored Jan 20, 2023
1 parent 680fb74 commit d31ebda
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions src/interactions/commands/chat/leaderboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,29 @@ impl Leaderboard {
})
.collect::<String>()
});
let pages: Vec<_> = pages
.map(|p| {
(
None,
Some(vec![embed::build()
.title(if include_gone {
"Leaderboard (Including Gone)"
} else {
"Leaderboard"
})
.description(p)
.build()]),
)
})
.collect();

if pages.is_empty() {
ctx.respond_str("Nothing to show.", true).await?;
return Ok(());
}

let author_id = ctx.interaction.author_id().unwrap();
paginator::simple(
&mut ctx,
pages
.map(|p| {
(
None,
Some(vec![embed::build()
.title(if include_gone {
"Leaderboard (Including Gone)"
} else {
"Leaderboard"
})
.description(p)
.build()]),
)
})
.collect(),
author_id,
false,
)
.await?;
paginator::simple(&mut ctx, pages, author_id, false).await?;

Ok(())
}
Expand Down

0 comments on commit d31ebda

Please sign in to comment.