fix taking away points when no note with note rdm

This commit is contained in:
Lili (Tlapka) 2022-10-25 18:31:36 +02:00
parent 15dfd3ccae
commit a667f746f3
1 changed files with 14 additions and 12 deletions

View File

@ -18,19 +18,21 @@ def handle_redeem(message, user_id):
redeem_type = current_app.config['REDEEMS'][redeem]["type"] redeem_type = current_app.config['REDEEMS'][redeem]["type"]
points = read_users_points(db, user_id) points = read_users_points(db, user_id)
if points is not None and points >= price: if points is not None and points >= price:
if use_points(db, user_id, price): if redeem_type == "counter":
if redeem_type == "counter": add_to_counter(db, redeem)
add_to_counter(db, redeem) use_points(db, user_id, price)
send_chat(f"{redeem} redeemed for {price} points.")
elif redeem_type == "list":
add_to_redeem_queue(db, user_id, redeem)
use_points(db, user_id, price)
send_chat(f"{redeem} redeemed for {price} points.")
elif redeem_type == "note":
if note is not None:
add_to_redeem_queue(db, user_id, redeem, note)
use_points(db, user_id, price)
send_chat(f"{redeem} redeemed for {price} points.") send_chat(f"{redeem} redeemed for {price} points.")
elif redeem_type == "list": else:
add_to_redeem_queue(db, user_id, redeem) send_chat(f"Cannot redeem {redeem}, no note included.")
send_chat(f"{redeem} redeemed for {price} points.")
elif redeem_type == "note":
if note is not None:
add_to_redeem_queue(db, user_id, redeem, note)
send_chat(f"{redeem} redeemed for {price} points.")
else:
send_chat(f"Cannot redeem {redeem}, no note included.")
else: else:
send_chat(f"{redeem} not redeemed because of an error.") send_chat(f"{redeem} not redeemed because of an error.")
else: else: