forked from rDrama/rDrama
1
0
Fork 0
master
Aevann1 2022-09-18 02:28:09 +02:00
parent c943673df5
commit 3b8d025f57
2 changed files with 8 additions and 5 deletions

View File

@ -12,6 +12,7 @@ if KOFI_TOKEN:
type = Column(String)
amount = Column(Integer)
email = Column(String)
claimed = Column(Boolean)
def __repr__(self):
return f"<Transaction(id={self.id})>"

View File

@ -1422,11 +1422,10 @@ def settings_kofi(v):
if not transaction:
return {"error": "Email not found"}, 404
tier = kofi_tiers[transaction.amount]
if v.patron == tier: return {"error": f"{patron} rewards already claimed"}, 400
if transaction.claimed:
return {"error": f"{patron} rewards already claimed"}, 400
existing = g.db.query(User.id).filter(User.email == v.email, User.is_activated == True, User.patron >= tier).first()
if existing: return {"error": f"{patron} rewards already claimed on another account"}, 400
tier = kofi_tiers[transaction.amount]
v.patron = tier
if v.discord_id: add_role(v, f"{tier}")
@ -1439,6 +1438,9 @@ def settings_kofi(v):
g.db.add(v)
badge_grant(badge_id=20+tier, user=v)
transaction.claimed = True
g.db.add(transaction)
return {"message": f"{patron} rewards claimed!"}