Skip to content

Commit

Permalink
Merge pull request #3 from WISVCH/leaderboard-today-rank
Browse files Browse the repository at this point in the history
Add rank to leaderboard_today
  • Loading branch information
julian9499 authored Dec 20, 2024
2 parents c18a014 + d244fc3 commit fa2744f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::cmp;
use demoji_rs::remove_emoji;
use poise::serenity_prelude as serenity;
use serde::Deserialize;
use std::cmp;

struct Data {} // User data, which is stored and accessible in all command invocations
type Error = Box<dyn std::error::Error + Send + Sync>;
Expand Down Expand Up @@ -121,13 +121,13 @@ async fn leaderboard_today(ctx: Context<'_>) -> Result<(), Error> {
})
.max()
.unwrap();
let row_size: usize = start_width + 16;
let row_size: usize = start_width + 24;
let row_count = 1900 / row_size;

let mut table_rows = vec![];
table_rows.push(format!(
"{1:0$} | {2:5} | {3:5}",
start_width, "Name", "Stars", "Score"
"{4:5} | {1:0$} | {2:5} | {3:5}",
start_width, "Name", "Stars", "Score", "Rank"
));
table_rows.push(format!("{:-^row_size$}", ""));

Expand All @@ -146,7 +146,10 @@ async fn leaderboard_today(ctx: Context<'_>) -> Result<(), Error> {
stars += "*";
}

format!("{name:0$} | {stars:^5} | {1:<5}", start_width, x.score)
format!(
"{2:>4}) | {name:0$} | {stars:<5} | {1:>5}",
start_width, x.score, x.rank
)
})
.collect::<Vec<String>>()
.as_mut(),
Expand Down

0 comments on commit fa2744f

Please sign in to comment.