mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-05-25 01:30:50 +00:00
Split youmubot-core
This commit is contained in:
parent
aec9cd130d
commit
84150cd82e
14 changed files with 56 additions and 38 deletions
38
youmubot-core/src/db.rs
Normal file
38
youmubot-core/src/db.rs
Normal file
|
@ -0,0 +1,38 @@
|
|||
use chrono::{DateTime, Utc};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serenity::{
|
||||
model::id::{RoleId, UserId},
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
use youmubot_db::{GuildMap, DB};
|
||||
|
||||
/// A list of SoftBans for all servers.
|
||||
pub type SoftBans = DB<GuildMap<ServerSoftBans>>;
|
||||
|
||||
/// For the admin commands:
|
||||
/// - Each server might have a `soft ban` role implemented.
|
||||
/// - We allow periodical `soft ban` applications.
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub enum ServerSoftBans {
|
||||
Implemented(ImplementedSoftBans),
|
||||
Unimplemented,
|
||||
}
|
||||
|
||||
impl ServerSoftBans {
|
||||
// Create a new, implemented role.
|
||||
pub fn new_implemented(role: RoleId) -> ServerSoftBans {
|
||||
ServerSoftBans::Implemented(ImplementedSoftBans {
|
||||
role,
|
||||
periodical_bans: HashMap::new(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct ImplementedSoftBans {
|
||||
/// The soft-ban role.
|
||||
pub role: RoleId,
|
||||
/// List of all to-unban people.
|
||||
pub periodical_bans: HashMap<UserId, DateTime<Utc>>,
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue