Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "RustBot"
version = "0.4.6"
version = "0.5.0"
authors = ["Tim Hillier tim.r.hillier@gmail.com"]
edition = "2024"

Expand Down
17 changes: 14 additions & 3 deletions src/commands/score.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,21 @@ Returns the top 10 scoring users.
pub async fn leader(ctx: Context<'_>) -> Result<(), Error> {
let top_scores = get_top_scores(10).await;

let mut reply_string: String = String::new();
let mut reply_string = String::from("🏆 **Leaderboard** 🏆\n\n");
for (i, value) in top_scores.0.iter().enumerate() {
reply_string.push_str((i + 1).to_string().as_str());
reply_string.push_str(value.to_string().as_str());
let place = match i {
0 => "🥇",
1 => "🥈",
2 => "🥉",
_ => "🔹",
};
reply_string.push_str(&format!(
"{} **#{}** — {} — **{}** points\n",
place,
i + 1,
value.user_name,
value.score
));
}

if let Err(why) = ctx.reply(reply_string).await {
Expand Down
Loading