clock and timezone cmd
This commit is contained in:
@ -10,7 +10,18 @@ use serenity::{
|
||||
framework::standard::CommandResult,
|
||||
};
|
||||
|
||||
use crate::THEME_COLOR;
|
||||
use chrono_tz::Tz;
|
||||
|
||||
use chrono::{
|
||||
DateTime,
|
||||
offset::Utc,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
THEME_COLOR,
|
||||
SQLPool,
|
||||
models::UserData,
|
||||
};
|
||||
|
||||
|
||||
#[command]
|
||||
@ -52,3 +63,19 @@ async fn donate(ctx: &Context, msg: &Message, _args: String) -> CommandResult {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[command]
|
||||
async fn clock(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
||||
let pool = ctx.data.read().await
|
||||
.get::<SQLPool>().cloned().expect("Could not get SQLPool from data");
|
||||
|
||||
let user_data = UserData::from_id(&msg.author, &ctx, pool).await.unwrap();
|
||||
|
||||
let tz: Tz = user_data.timezone.parse().unwrap();
|
||||
|
||||
let now = Utc::now().with_timezone(&tz);
|
||||
|
||||
let _ = msg.channel_id.say(&ctx, format!("Current time: **{}**", now.format("%H:%M:%S"))).await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Reference in New Issue
Block a user