fix some things

This commit is contained in:
nora 2022-06-15 21:45:36 +02:00
parent afd5e49eda
commit 835665e77f
3 changed files with 162 additions and 51 deletions

View file

@ -1,5 +1,6 @@
use color_eyre::Result;
use mongodb::{
bson,
bson::doc,
options::{ClientOptions, Credential},
Client, Collection, Database,
@ -98,12 +99,12 @@ impl Mongo {
Ok(())
}
pub async fn add_court_room(&self, guild_id: &str, room: CourtRoom) -> Result<()> {
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() }},
doc! {"$push": { "court_rooms": bson::to_bson(room).wrap_err("invalid bson for room")? }},
None,
)
.await