...
This commit is contained in:
@ -6,6 +6,7 @@ pub mod user_data;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use chrono_tz::Tz;
|
||||
use serenity::{
|
||||
async_trait,
|
||||
model::id::{ChannelId, GuildId, UserId},
|
||||
@ -33,6 +34,8 @@ pub trait CtxData {
|
||||
user_id: U,
|
||||
) -> Result<UserData, Box<dyn std::error::Error + Sync + Send>>;
|
||||
|
||||
async fn timezone<U: Into<UserId> + Send + Sync>(&self, user_id: U) -> Tz;
|
||||
|
||||
async fn channel_data<C: Into<ChannelId> + Send + Sync>(
|
||||
&self,
|
||||
channel_id: C,
|
||||
@ -92,6 +95,13 @@ impl CtxData for Context {
|
||||
UserData::from_user(&user, &self, &pool).await
|
||||
}
|
||||
|
||||
async fn timezone<U: Into<UserId> + Send + Sync>(&self, user_id: U) -> Tz {
|
||||
let user_id = user_id.into();
|
||||
let pool = self.data.read().await.get::<SQLPool>().cloned().unwrap();
|
||||
|
||||
UserData::timezone_of(user_id, &pool).await
|
||||
}
|
||||
|
||||
async fn channel_data<C: Into<ChannelId> + Send + Sync>(
|
||||
&self,
|
||||
channel_id: C,
|
||||
|
Reference in New Issue
Block a user