From 86e46b833872b633f56421ad6dc45aa8e7169b19 Mon Sep 17 00:00:00 2001 From: Leo dev Date: Thu, 5 Sep 2024 15:40:27 +0200 Subject: [PATCH] cooldown --- config.py | 3 ++- main.py | 8 +------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/config.py b/config.py index b81db25..045ed52 100644 --- a/config.py +++ b/config.py @@ -5,4 +5,5 @@ if not INVITE.endswith('/'):INVITE+='/' PUNISH_ROLES=[x.strip() for x in os.environ['PUNISH_ROLES'].split(',')] REDIS_URL=os.environ['REDIS_URL'] REDIS_USER=os.environ['REDIS_USER'] -REDIS_PSW=os.environ['REDIS_PSW'] \ No newline at end of file +REDIS_PSW=os.environ['REDIS_PSW'] +COOLDOWN_PERIOD = 5 \ No newline at end of file diff --git a/main.py b/main.py index 38486be..1167d63 100644 --- a/main.py +++ b/main.py @@ -7,11 +7,8 @@ import time aura = Aura() client = discord.Client(intents=discord.Intents.all()) -# bot = commands.Bot(command_prefix="!", intents=discord.Intents.all()) tree = app_commands.CommandTree(client) -COOLDOWN_PERIOD = 5 - @client.event async def on_ready(): print(client.user) @@ -27,13 +24,10 @@ async def on_message(msg: discord.Message): if msg.author.bot: return user = aura.get(str(msg.author.id)) - time_elapsed = time.time() - user.last_earned - print(time_elapsed) - if time_elapsed >= COOLDOWN_PERIOD: + if int(time.time() - user.last_earned) >= COOLDOWN_PERIOD: user.balance += 3 user.last_earned = time.time() aura.update(user) - await client.process_commands(msg) @client.event async def on_member_join(member: discord.Member):