punishment system

This commit is contained in:
2024-09-03 16:48:40 +02:00
parent e8bd402126
commit 100a1cd727
3 changed files with 39 additions and 17 deletions
+1 -1
View File
@@ -39,7 +39,7 @@ class Aura:
return self.data[user_id] return self.data[user_id]
def add(self, user_id) -> User: def add(self, user_id) -> User:
self.data[user_id] = User(10) self.data[user_id] = User(100)
return self.data[user_id] return self.data[user_id]
def save(self): def save(self):
+34 -12
View File
@@ -44,21 +44,43 @@ async def get_aura(interaction: discord.Interaction, member: discord.Member = No
await interaction.response.send_message(embed=embed) await interaction.response.send_message(embed=embed)
@tree.command(name='send', description='Send aura to a member') @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() aura.load()
user = aura.get(str(interaction.user.id)) user = aura.get(str(interaction.user.id))
user_to = aura.get(str(to.id)) user_to = aura.get(str(to.id))
if user.balance >= amount: if amount < 0:
user.balance -= amount amount = -amount
user_to.balance += amount for r in interaction.user.roles:
embed = discord.Embed( if r.id in PUNISH_ROLES:
color=interaction.user.color, if user_to.balance >= amount:
description=f'**From: {interaction.user.name}\nAmount: {amount}**' user_to.balance -= amount
) user.balance += 10
await to.send(embed=embed) await to.send(embed=discord.Embed(
await interaction.response.send_message(f'Sent! You now have {user.balance} aura!', ephemeral=True) color=interaction.user.color,
aura.save() 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: 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) client.run(BOT_TOKEN)
+4 -4
View File
@@ -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'],)) t2 = Thread(target=run, args=(['./.venv/bin/python3', 'main.py'],))
t1.daemon = True t1.daemon = True
t2.daemon = True t2.daemon = True
t1.start() if USE_INVITE_SERVER:t1.start()
if USE_INVITE_SERVER:t2.start() t2.start()
while 1: while 1:
if input() == 'q': if input() == 'q':
t1.join(0) if USE_INVITE_SERVER:t1.join(0)
if USE_INVITE_SERVER:t2.join(0) t2.join(0)