import discord from discord import embeds from discord import member from discord import user from discord import message from discord.errors import DiscordException from discord.ext import commands import asyncio import json import os import random os.chdir('C:\\Users\\Orange\\Desktop\\economy bot my custom') from discord.ext.commands.core import command client = commands.Bot(command_prefix='h!') @client.event async def on_ready(): print('ready.') await client.change_presence( status=discord.Status.online, activity=discord.Game('Playing with hypes')) @client.command() async def bal(ctx, user: discord.Member=None): if not user: user = ctx.author await open_account(user) user = await get_bank_data() users = user wallet_amount = users[str(user.id)]['wallet'] bank_amount = users[str(user.id)]['bank'] embed = discord.Embed(title=f" User\'s hype balance", color="green") embed.add_field(name = "wallet", value = f"{wallet_amount}") embed.add_field(name = "wallet", value = f"{bank_amount}") await ctx.send(embed = embed) async def open_account(user): users = await get_bank_data() if str(user.id) in users: return False else: users[str(user.id)] = {} users[str(user.id)]['wallet'] = {100} users[str(user.id)]['bank'] = {500} with open("economy.json","w") as f: json.dump(users, f, indent=4) return True async def get_bank_data(): with open("economy.json","r") as f: users = json.load(f) return users async def update_bank(users, change=0,mode='wallet'): users = await get_bank_data() users[str(user.id)][mode] += change with open("economy.json","w") as f: json.dump(users, f, indent=4) bal = [users[str(user.id)]['wallet']],users[str(user.id)['bank']] return bal client.run('TOKEN')