Skip to content

Commit

Permalink
Fix bot crashing on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
l3v11 authored Oct 29, 2022
1 parent 72c14e2 commit ed41877
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions bot/helper/ext_utils/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,30 @@ 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

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()
Expand Down

0 comments on commit ed41877

Please sign in to comment.