From 100a1cd727d9dee4fd9bc843b3f94b2d953fa26a Mon Sep 17 00:00:00 2001 From: Leo dev Date: Tue, 3 Sep 2024 16:48:40 +0200 Subject: [PATCH] punishment system --- aura.py | 2 +- main.py | 46 ++++++++++++++++++++++++++++++++++------------ run.py | 8 ++++---- 3 files changed, 39 insertions(+), 17 deletions(-) diff --git a/aura.py b/aura.py index 4e47195..6ae567f 100644 --- a/aura.py +++ b/aura.py @@ -39,7 +39,7 @@ class Aura: return self.data[user_id] def add(self, user_id) -> User: - self.data[user_id] = User(10) + self.data[user_id] = User(100) return self.data[user_id] def save(self): diff --git a/main.py b/main.py index 3afd283..502379c 100644 --- a/main.py +++ b/main.py @@ -44,21 +44,43 @@ async def get_aura(interaction: discord.Interaction, member: discord.Member = No await interaction.response.send_message(embed=embed) @tree.command(name='send', description='Send aura to a member') -async def send(interaction: discord.Interaction, to: discord.Member, amount: int): +async def send(interaction: discord.Interaction, to: discord.Member, amount: int, reason: str = ""): aura.load() user = aura.get(str(interaction.user.id)) user_to = aura.get(str(to.id)) - if user.balance >= amount: - user.balance -= amount - user_to.balance += amount - embed = discord.Embed( - color=interaction.user.color, - description=f'**From: {interaction.user.name}\nAmount: {amount}**' - ) - await to.send(embed=embed) - await interaction.response.send_message(f'Sent! You now have {user.balance} aura!', ephemeral=True) - aura.save() + if amount < 0: + amount = -amount + for r in interaction.user.roles: + if r.id in PUNISH_ROLES: + if user_to.balance >= amount: + user_to.balance -= amount + user.balance += 10 + await to.send(embed=discord.Embed( + color=interaction.user.color, + title="Punished!", + description=f'**By: {interaction.user.name}\nAmount: {amount}\nReason: {reason}**' + )) + await interaction.response.send_message(f'Punished! You gained 10+ aura!', ephemeral=True) + aura.save() + else: + await interaction.response.send_message(f'Cannot punish. {to.name} only has {user_to.balance} aura!', ephemeral=True) + return + if user.balance >= 10: + user.balance -= 10 + await interaction.response.send_message(f'Cannot punish. You are not a developer.{" -10 aura!" if user.balance>=10 else""}', ephemeral=True) + return else: - await interaction.response.send_message(f'Cannot send. You only have {user.balance} aura!', ephemeral=True) + if user.balance >= amount: + user.balance -= amount + user_to.balance += amount + await to.send(embed=discord.Embed( + color=interaction.user.color, + title="Aura received!", + description=f'**From: {interaction.user.name}\nAmount: {amount}**' + )) + await interaction.response.send_message(f'Sent! You now have {user.balance} aura!', ephemeral=True) + aura.save() + else: + await interaction.response.send_message(f'Cannot send. You only have {user.balance} aura!', ephemeral=True) client.run(BOT_TOKEN) \ No newline at end of file diff --git a/run.py b/run.py index 186d323..617482a 100644 --- a/run.py +++ b/run.py @@ -6,9 +6,9 @@ t1 = Thread(target=run, args=(['./.venv/bin/python3', 'invite_sys.py'],)) t2 = Thread(target=run, args=(['./.venv/bin/python3', 'main.py'],)) t1.daemon = True t2.daemon = True -t1.start() -if USE_INVITE_SERVER:t2.start() +if USE_INVITE_SERVER:t1.start() +t2.start() while 1: if input() == 'q': - t1.join(0) - if USE_INVITE_SERVER:t2.join(0) \ No newline at end of file + if USE_INVITE_SERVER:t1.join(0) + t2.join(0) \ No newline at end of file