MissKatyPyro/database/gban_db.py
sourcery-ai[bot] 22b0e3ba35
'Refactored by Sourcery' (#62)
Co-authored-by: Sourcery AI <>
2023-06-16 23:11:49 +07:00

19 lines
No EOL
563 B
Python

from database import dbname
gbansdb = dbname.gban
async def is_gbanned_user(user_id: int) -> bool:
user = await gbansdb.find_one({"user_id": user_id})
return bool(user)
async def add_gban_user(user_id: int):
is_gbanned = await is_gbanned_user(user_id)
if is_gbanned:
return
return await gbansdb.insert_one({"user_id": user_id})
async def remove_gban_user(user_id: int):
is_gbanned = await is_gbanned_user(user_id)
if not is_gbanned:
return
return await gbansdb.delete_one({"user_id": user_id})