coollsd commited on
Commit
b2a3792
1 Parent(s): 6b71189

Update cash.py

Browse files
Files changed (1) hide show
  1. cash.py +9 -3
cash.py CHANGED
@@ -1,9 +1,14 @@
1
  import discord
2
  from discord import app_commands
 
3
 
4
  user_cash = {}
5
 
6
- @app_commands.command(name="cash", description="check the current cash u got")
 
 
 
 
7
  async def cash(interaction: discord.Interaction):
8
  user_id = interaction.user.id
9
  balance = user_cash.get(user_id, 0)
@@ -16,6 +21,7 @@ async def cash(interaction: discord.Interaction):
16
  message = f"Your current balance is ${balance:.2f}"
17
 
18
  embed = discord.Embed(title="Cash Balance", description=message, color=0x787878)
19
- embed.set_footer(text="Use /dice to bet your cash or use pet roll to get more cash!")
20
 
21
- await interaction.response.send_message(embed=embed)
 
 
1
  import discord
2
  from discord import app_commands
3
+ import json
4
 
5
  user_cash = {}
6
 
7
+ def save_database():
8
+ with open("database.txt", "w") as f:
9
+ json.dump(user_cash, f)
10
+
11
+ @app_commands.command(name="cash", description="check cash")
12
  async def cash(interaction: discord.Interaction):
13
  user_id = interaction.user.id
14
  balance = user_cash.get(user_id, 0)
 
21
  message = f"Your current balance is ${balance:.2f}"
22
 
23
  embed = discord.Embed(title="Cash Balance", description=message, color=0x787878)
24
+ embed.set_footer(text="Use /dice to bet your cash!")
25
 
26
+ await interaction.response.send_message(embed=embed)
27
+ save_database() # Save the database after each cash operation