From 4d43e984a877f289fdbc1acb3f0746d552ce389c Mon Sep 17 00:00:00 2001 From: Yasir Aris M Date: Sat, 21 Oct 2023 22:59:57 +0700 Subject: [PATCH] Tes add ban user to db Signed-off-by: Yasir Aris M --- database/users_chats_db.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/database/users_chats_db.py b/database/users_chats_db.py index 8ac6b4f7..c80e87ae 100644 --- a/database/users_chats_db.py +++ b/database/users_chats_db.py @@ -44,15 +44,16 @@ class UsersData: return await self.col.count_documents({}) async def remove_ban(self, id): - await self.col.delete_one({"id": id}) + await self.col.delete_one({"_id": id}) async def ban_user(self, user_id, ban_reason="No Reason"): - await self.col.insert_one({"id": user_id, "reason": ban_reason}) + await self.col.insert_one({"_id": user_id, "reason": ban_reason}) async def get_ban_status(self, id): - default = dict(is_banned=False, ban_reason="") - user = await self.col.find_one({"id": int(id)}) - return user.get("ban_status", default) if user else default + user = await self.col.find_one({"_id": int(id)}) + if user: + return True + return False async def get_all_users(self): return self.col.find({})