mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-04-18 16:28:55 +00:00
Save osu users with last update timestamp
This commit is contained in:
parent
ce09a76dc7
commit
0939543bd3
2 changed files with 17 additions and 4 deletions
|
@ -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"))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ where
|
|||
pub type SoftBans = DB<GuildMap<ServerSoftBans>>;
|
||||
|
||||
/// Save the user IDs.
|
||||
pub type OsuSavedUsers = DB<HashMap<UserId, u64>>;
|
||||
pub type OsuSavedUsers = DB<HashMap<UserId, OsuUser>>;
|
||||
|
||||
/// Save each channel's last requested beatmap.
|
||||
pub type OsuLastBeatmap = DB<HashMap<ChannelId, (Beatmap, Mode)>>;
|
||||
|
@ -118,3 +118,10 @@ pub struct ImplementedSoftBans {
|
|||
/// List of all to-unban people.
|
||||
pub periodical_bans: HashMap<UserId, DateTime<Utc>>,
|
||||
}
|
||||
|
||||
/// An osu! saved user.
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct OsuUser {
|
||||
pub id: u64,
|
||||
pub last_update: DateTime<Utc>,
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue