mirror of
https://github.com/Noratrieb/discord-court-bot.git
synced 2026-01-16 19:05:01 +01:00
create roles
This commit is contained in:
parent
9c6f958f68
commit
afd5e49eda
5 changed files with 121 additions and 11 deletions
14
src/model.rs
14
src/model.rs
|
|
@ -21,6 +21,7 @@ pub struct State {
|
|||
pub struct CourtRoom {
|
||||
pub channel_id: String,
|
||||
pub ongoing_lawsuit: bool,
|
||||
pub role_id: String,
|
||||
}
|
||||
|
||||
pub struct Mongo {
|
||||
|
|
@ -97,6 +98,19 @@ impl Mongo {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn add_court_room(&self, guild_id: &str, room: CourtRoom) -> Result<()> {
|
||||
let _ = self.find_or_insert_state(guild_id).await?;
|
||||
let coll = self.state_coll();
|
||||
coll.update_one(
|
||||
doc! {"guild_id": &guild_id },
|
||||
doc! {"$push": { "court_rooms": &serde_json::to_string(&room).unwrap() }},
|
||||
None,
|
||||
)
|
||||
.await
|
||||
.wrap_err("push court room")?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn state_coll(&self) -> Collection<State> {
|
||||
self.db.collection("state")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue