Updated autocredits.py

This commit is contained in:
Leander 2023-08-07 14:55:53 +02:00 committed by GitHub
parent 9b8ab4eced
commit dbaec0332b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,11 +2,14 @@ async def get_all_users(client):
users = client['nova-core']['users']
return users
async def update_credits(users, settings=None):
async def update_credits(pymongo_client, settings=None):
users = await get_all_users(pymongo_client)
if not settings:
users.update_many({}, {"$inc": {"credits": 250}})
users.update_many({}, {"$inc": {"credits": 2500}})
else:
for key, value in settings.items():
users.update_many({'role': key}, {"$inc": {"credits": int(value)}})
print(f'Updated {key} to {value}')
users.update_many(
{'level': key}, {"$inc": {"credits": int(value)}})