From ed41877a72aadca3be3b1aeb5dcee4096e2daeed Mon Sep 17 00:00:00 2001 From: Levi <57452819+l3v11@users.noreply.github.com> Date: Sat, 29 Oct 2022 10:25:42 +0600 Subject: [PATCH] Fix bot crashing on startup --- bot/helper/ext_utils/database.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bot/helper/ext_utils/database.py b/bot/helper/ext_utils/database.py index 013bec4c..4eccf76a 100644 --- a/bot/helper/ext_utils/database.py +++ b/bot/helper/ext_utils/database.py @@ -15,8 +15,8 @@ def __init__(self): def __connect(self): try: self.__client = MongoClient(DATABASE_URL) - self.__db = self.client['SearchX'] - self.__collection = self.db['users'] + self.__db = self.__client['SearchX'] + self.__collection = self.__db['users'] except PyMongoError as err: LOGGER.error(err) self.__err = True @@ -24,21 +24,21 @@ def __connect(self): def auth_user(self, user_id: int): if self.__err: return - self.col.insert_one({"user_id": user_id}) + self.__collection.insert_one({"user_id": user_id}) return 'Authorization granted' self.__client.close() def unauth_user(self, user_id: int): if self.__err: return - self.col.delete_many({"user_id": user_id}) + self.__collection.delete_many({"user_id": user_id}) return 'Authorization revoked' self.__client.close() def load_users(self): if self.__err: return - users = self.col.find().sort("user_id") + users = self.__collection.find().sort("user_id") for user in users: AUTHORIZED_USERS.add(user["user_id"]) self.__client.close()