Skip to content

Commit

Permalink
[Refactor] Remove some nested code
Browse files Browse the repository at this point in the history
  • Loading branch information
Satellaa committed Oct 12, 2024
1 parent 10f479f commit 9dd7e5a
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions src/commands/prices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,17 @@ async fn respond(
card_result: Result<Option<Card>>,
identifier: &str,
) -> Result<()> {
match card_result? {
Some(mut card) => {
card.card_prices.retain(|_, arr| !arr.is_empty());
if card.card_prices.is_empty() {
ctx.say(format!("Oops! `{}` is not in stock.", card.name.en)).await?;
}
else {
let embeds_map = create_embeds_map(&card);
let mut pagination = Pagination::new(ctx, &embeds_map);
pagination.start().await?;
}
}
None => {
ctx.say(format!("Could not find a card matching `{}`!", identifier)).await?;
}
let Some(mut card) = card_result? else {
ctx.say(format!("Could not find a card matching `{}`!", identifier)).await?;
return Ok(());
};

card.card_prices.retain(|_, arr| !arr.is_empty());

if card.card_prices.is_empty() {
ctx.say(format!("Oops! `{}` is not in stock.", card.name.en)).await?;
return Ok(());
}
Ok(())

Pagination::new(ctx, &create_embeds_map(&card)).start().await
}

0 comments on commit 9dd7e5a

Please sign in to comment.