import discord from discord import app_commands import json from cash import user_cash @app_commands.command(name="database", description="database") @app_commands.describe(action="save or load'") async def database(interaction: discord.Interaction, action: str): if action.lower() == "save": with open("database.txt", "w") as f: json.dump(user_cash, f) await interaction.response.send_message("saved to database.txt") elif action.lower() == "load": try: with open("database.txt", "r") as f: loaded_data = json.load(f) user_cash.clear() user_cash.update(loaded_data) await interaction.response.send_message("Database from database.txt") except FileNotFoundError: await interaction.response.send_message("AAAAAAAAAA.") else: await interaction.response.send_message("Use 'save' or 'load'.")