-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed event. Started working on /tracking stats
- Loading branch information
Showing
5 changed files
with
23 additions
and
10 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters