Skip to content

Commit a2345ca

Browse files
TimHillierTIm Hillier
andauthored
Updated lb (#15)
* Updated score leaderboard. * Update version to 5.0 --------- Co-authored-by: TIm Hillier <thillier@acrocommerce.com>
1 parent 54d68a5 commit a2345ca

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "RustBot"
3-
version = "0.4.6"
3+
version = "0.5.0"
44
authors = ["Tim Hillier tim.r.hillier@gmail.com"]
55
edition = "2024"
66

src/commands/score.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,21 @@ Returns the top 10 scoring users.
5757
pub async fn leader(ctx: Context<'_>) -> Result<(), Error> {
5858
let top_scores = get_top_scores(10).await;
5959

60-
let mut reply_string: String = String::new();
60+
let mut reply_string = String::from("🏆 **Leaderboard** 🏆\n\n");
6161
for (i, value) in top_scores.0.iter().enumerate() {
62-
reply_string.push_str((i + 1).to_string().as_str());
63-
reply_string.push_str(value.to_string().as_str());
62+
let place = match i {
63+
0 => "🥇",
64+
1 => "🥈",
65+
2 => "🥉",
66+
_ => "🔹",
67+
};
68+
reply_string.push_str(&format!(
69+
"{} **#{}** — {} — **{}** points\n",
70+
place,
71+
i + 1,
72+
value.user_name,
73+
value.score
74+
));
6475
}
6576

6677
if let Err(why) = ctx.reply(reply_string).await {

0 commit comments

Comments
 (0)