diff --git a/youmubot/src/commands/osu/mod.rs b/youmubot/src/commands/osu/mod.rs index 8c44e37..4217d7d 100644 --- a/youmubot/src/commands/osu/mod.rs +++ b/youmubot/src/commands/osu/mod.rs @@ -1,4 +1,4 @@ -use crate::db::{DBWriteGuard, OsuSavedUsers}; +use crate::db::{DBWriteGuard, OsuSavedUsers, OsuUser}; use crate::http; use serenity::{ framework::standard::{ @@ -103,7 +103,13 @@ pub fn save(ctx: &mut Context, msg: &Message, mut args: Args) -> CommandResult { .into(); let mut db = db.borrow_mut()?; - db.insert(msg.author.id, u.id); + db.insert( + msg.author.id, + OsuUser { + id: u.id, + last_update: chrono::Utc::now(), + }, + ); msg.reply( &ctx, MessageBuilder::new() @@ -157,7 +163,7 @@ impl UsernameArg { let db = db.borrow()?; db.get(&id) .cloned() - .map(UserID::ID) + .map(|u| UserID::ID(u.id)) .ok_or(Error::from("No saved account found")) } } diff --git a/youmubot/src/db/mod.rs b/youmubot/src/db/mod.rs index 2205df2..e115383 100644 --- a/youmubot/src/db/mod.rs +++ b/youmubot/src/db/mod.rs @@ -37,7 +37,7 @@ where pub type SoftBans = DB>; /// Save the user IDs. -pub type OsuSavedUsers = DB>; +pub type OsuSavedUsers = DB>; /// Save each channel's last requested beatmap. pub type OsuLastBeatmap = DB>; @@ -118,3 +118,10 @@ pub struct ImplementedSoftBans { /// List of all to-unban people. pub periodical_bans: HashMap>, } + +/// An osu! saved user. +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct OsuUser { + pub id: u64, + pub last_update: DateTime, +}