forked from rDrama/rDrama
fix kofi
parent
c943673df5
commit
3b8d025f57
|
@ -12,6 +12,7 @@ if KOFI_TOKEN:
|
||||||
type = Column(String)
|
type = Column(String)
|
||||||
amount = Column(Integer)
|
amount = Column(Integer)
|
||||||
email = Column(String)
|
email = Column(String)
|
||||||
|
claimed = Column(Boolean)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"<Transaction(id={self.id})>"
|
return f"<Transaction(id={self.id})>"
|
|
@ -1422,11 +1422,10 @@ def settings_kofi(v):
|
||||||
if not transaction:
|
if not transaction:
|
||||||
return {"error": "Email not found"}, 404
|
return {"error": "Email not found"}, 404
|
||||||
|
|
||||||
tier = kofi_tiers[transaction.amount]
|
if transaction.claimed:
|
||||||
if v.patron == tier: return {"error": f"{patron} rewards already claimed"}, 400
|
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()
|
tier = kofi_tiers[transaction.amount]
|
||||||
if existing: return {"error": f"{patron} rewards already claimed on another account"}, 400
|
|
||||||
|
|
||||||
v.patron = tier
|
v.patron = tier
|
||||||
if v.discord_id: add_role(v, f"{tier}")
|
if v.discord_id: add_role(v, f"{tier}")
|
||||||
|
@ -1439,6 +1438,9 @@ def settings_kofi(v):
|
||||||
g.db.add(v)
|
g.db.add(v)
|
||||||
|
|
||||||
badge_grant(badge_id=20+tier, user=v)
|
badge_grant(badge_id=20+tier, user=v)
|
||||||
|
|
||||||
|
transaction.claimed = True
|
||||||
|
|
||||||
|
g.db.add(transaction)
|
||||||
|
|
||||||
return {"message": f"{patron} rewards claimed!"}
|
return {"message": f"{patron} rewards claimed!"}
|
Loading…
Reference in New Issue