create roles

This commit is contained in:
nora 2022-06-14 22:32:56 +02:00
parent 9c6f958f68
commit afd5e49eda
5 changed files with 121 additions and 11 deletions

View file

@ -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")
}