Skip to content

Commit

Permalink
Fixed event. Started working on /tracking stats
Browse files Browse the repository at this point in the history
  • Loading branch information
xToxette committed Oct 22, 2023
1 parent f5660fc commit 1e9611c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
Binary file modified database.sqlite
Binary file not shown.
Binary file removed database.sqlite-shm
Binary file not shown.
Binary file removed database.sqlite-wal
Binary file not shown.
32 changes: 23 additions & 9 deletions src/commands/tracking/statistics.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,38 @@
use poise::{serenity_prelude as serenity};
use poise::{CreateReply, serenity_prelude as serenity};
use crate::{Context, dal, Error};

/// Display various statistics about your presence in this server
#[poise::command(slash_command, ephemeral)]
pub async fn stats(
ctx: Context<'_>,
#[description = "A user to get statistics for"]
user: Option<serenity::Member>,
user: Option<serenity::User>,
) -> Result<(), Error> {
let target_user = user.clone().unwrap_or(ctx.author().clone());
let voice_state_updates = dal::events::voice_state_update::get_voice_state_updates(
&ctx.data().conn_pool,
target_user.id.0 as i64,
ctx.guild_id()
.map(|i| i.0 as i64))
.await?;

if voice_state_updates.is_empty() {
ctx.send(|m| m.content(format!("Not statistics were found for the requested user"))).await?;
return Ok(())
}



ctx.send(|m| {
match user {
Some(user) =>
m.content(format!("Lets see {}'s statistics", user.display_name())),
m.content(format!("Lets see {}'s statistics", target_user.name)),
None =>
m.content("Lets see your statistics")
}
m.content("Lets see your statistics"),
}.embed(|m| {
m.title("Statistics")
})
}).await?;
println!(
"Requested data: {:#?}",
dal::events::voice_state_update::get_voice_state_updates(&ctx.data().conn_pool, ctx.author().id.0 as i64, ctx.guild_id().map(|i| i.0 as i64)).await.unwrap()
);

Ok(())
}
1 change: 0 additions & 1 deletion src/event_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pub fn main_handler<'a>(
dal::events::voice_state_update::insert(&data.conn_pool, &new).await?;
}
Event::Message { new_message : _} => {
todo!()
}
_ => {}
}
Expand Down

0 comments on commit 1e9611c

Please sign in to comment.