From dcdafd305b19bf3b8da4a1c9c2d945a2972469c0 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Mon, 17 Jan 2022 14:07:50 +0200 Subject: [PATCH] fgfg\ --- files/routes/admin.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/files/routes/admin.py b/files/routes/admin.py index a35f71f97..19f12588c 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -58,6 +58,9 @@ def remove_admin(v, username): @limiter.limit("1/second;30/minute;200/hour;1000/day") @admin_level_required(3) def distribute(v, comment): + autobetter = g.db.query(User).filter_by(id=AUTOBETTER_ID).one_or_none() + if autobetter.coins == 0: return {"error": "@AutoBetter has 0 coins"} + try: comment = int(comment) except: abort(400) post = g.db.query(Comment.parent_submission).filter_by(id=comment).one_or_none()[0] @@ -67,7 +70,6 @@ def distribute(v, comment): for option in post.bet_options: pool += option.upvotes pool *= 200 - autobetter = g.db.query(User).filter_by(id=AUTOBETTER_ID).one_or_none() autobetter.coins -= pool if autobetter.coins < 0: autobetter.coins = 0 g.db.add(autobetter)