From 3d810cfea32a5a654ae05b2834812788b8b407fc Mon Sep 17 00:00:00 2001 From: minneelyyyy Date: Tue, 11 Feb 2025 17:22:07 -0500 Subject: [PATCH] add an optional user arg to /daily streak --- src/commands/gambling/daily.rs | 10 +++++++--- src/commands/gambling/leaderboard.rs | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/commands/gambling/daily.rs b/src/commands/gambling/daily.rs index c076736..8db6c94 100644 --- a/src/commands/gambling/daily.rs +++ b/src/commands/gambling/daily.rs @@ -1,6 +1,6 @@ use crate::{Context, Error}; -use poise::serenity_prelude::UserId; +use poise::serenity_prelude::{UserId, User}; use sqlx::{types::chrono::{DateTime, Utc, TimeZone}, PgExecutor, Row}; use std::time::Duration; @@ -59,10 +59,14 @@ where /// Tells you what your current daily streak is #[poise::command(slash_command, prefix_command)] -pub async fn streak(ctx: Context<'_>) -> Result<(), Error> { +pub async fn streak(ctx: Context<'_>, user: Option) -> Result<(), Error> { let db = &ctx.data().database; + let (user, name) = match user { + Some(user) => (user.id, user.display_name().to_string()), + None => (ctx.author().id, "You".to_string()), + }; - ctx.reply(format!("You have a daily streak of **{}**", get_streak(db, ctx.author().id).await?.unwrap_or(0))).await?; + ctx.reply(format!("{name} have a daily streak of **{}**", get_streak(db, user).await?.unwrap_or(0))).await?; Ok(()) } diff --git a/src/commands/gambling/leaderboard.rs b/src/commands/gambling/leaderboard.rs index a4f6644..71498bf 100644 --- a/src/commands/gambling/leaderboard.rs +++ b/src/commands/gambling/leaderboard.rs @@ -55,6 +55,7 @@ async fn display_leaderboard(ctx: Context<'_>, t: LeaderboardType) -> Result<(), Ok(()) } +/// DIsplay users with the top highest balances #[poise::command(slash_command, prefix_command)] pub async fn tokens(ctx: Context<'_>, count: Option) -> Result<(), Error> { let count = count.unwrap_or(10); @@ -67,6 +68,7 @@ pub async fn tokens(ctx: Context<'_>, count: Option) -> Result<(), Error> display_leaderboard(ctx, LeaderboardType::Tokens(count)).await } +/// Display users with the top highest daily streaks #[poise::command(slash_command, prefix_command)] pub async fn dailies(ctx: Context<'_>, count: Option) -> Result<(), Error> { let count = count.unwrap_or(10);