cooldown
This commit is contained in:
@@ -31,8 +31,11 @@ class Aura:
|
|||||||
self.r = redis.Redis(host=redis_host[0], port=int(redis_host[1]), username=REDIS_USER, password=REDIS_PSW, decode_responses=True)
|
self.r = redis.Redis(host=redis_host[0], port=int(redis_host[1]), username=REDIS_USER, password=REDIS_PSW, decode_responses=True)
|
||||||
|
|
||||||
def get(self, user_id) -> User | None:
|
def get(self, user_id) -> User | None:
|
||||||
|
user_id = str(user_id)
|
||||||
try:
|
try:
|
||||||
return User(user_id, int(self.r.get(str(user_id))), self.last_earns[user_id] if user_id in self.last_earns else 0.0)
|
if not user_id in self.last_earns:
|
||||||
|
self.last_earns[user_id] = 0.0
|
||||||
|
return User(user_id, int(self.r.get(user_id)), self.last_earns[user_id])
|
||||||
except:
|
except:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ async def on_message(msg: discord.Message):
|
|||||||
if msg.author.bot:
|
if msg.author.bot:
|
||||||
return
|
return
|
||||||
user = aura.get(str(msg.author.id))
|
user = aura.get(str(msg.author.id))
|
||||||
|
if user==None:
|
||||||
|
return
|
||||||
if int(time.time() - user.last_earned) >= COOLDOWN_PERIOD:
|
if int(time.time() - user.last_earned) >= COOLDOWN_PERIOD:
|
||||||
user.balance += 3
|
user.balance += 3
|
||||||
user.last_earned = time.time()
|
user.last_earned = time.time()
|
||||||
|
|||||||
Reference in New Issue
Block a user