You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
673 B
23 lines
673 B
use valence::prelude::*;
|
|
|
|
use redis::{Commands, Connection};
|
|
|
|
pub fn run(client: &mut Client, connection: &mut Connection) {
|
|
let wins: redis::RedisResult<Vec<(String, usize)>> = connection.hgetall("wins");
|
|
let Ok(mut wins) = wins else {
|
|
client.send_message("Leaderboards are empty!".color(Color::RED));
|
|
return;
|
|
};
|
|
|
|
wins.sort_by_key(|(_, w)| w.clone());
|
|
wins.reverse();
|
|
|
|
client.send_message("Top 10:".bold());
|
|
|
|
for i in 0..=(wins.len() - 1).clamp(0, 9) {
|
|
let (username, wins) = wins[i].clone();
|
|
|
|
client.send_message(format!("- {} with {} win(s)", username, wins).color(Color::GOLD));
|
|
}
|
|
}
|