Когда пишу m.balance ничего не высвечивается.
Когда пишу m.работать, тоесть чтобы получить деньги - 50 монеток, ничего не засчитывается.
Это началось тогда, когда я команды вписал в COGS...
:
class Economy(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_ready(self):
print(f"""{random.choice(["Ког - economy включен.", "Ког - economy включен.", "Ког - economy включен."])}""")
# МИНИ ЯДРО ЭКОНОМИКИ
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"] = 10
with open('mainbank.json', "w") as f:
json.dump(users,f)
return True
async def get_bank_data():
with open('mainbank.json', "r") as f:
users = json.load(f)
return users
async def update_bank(user,change = 0, mode = "wallet"):
users = await get_bank_data()
users[str(users.id)][mode] += change
with open('mainbank.json', "w") as f:
json.dump(users,f)
bal = [users[str(user.id)]["wallet"]]
return bal
# БАЛАНС ИГРОКА
@client.command(aliases = ['бал', 'bal', 'balance', 'кошелёк'])
async def баланс( self, ctx, member: discord.Member = None):
await open_account(ctx.author)
await open_account(member)
user = ctx.author
users = await get_bank_data()
wallet_amt = users[str(member.id)]["wallet"]
if member == None:
embed = discord.Embed(
title = f"Баланс {ctx.author.name}'a:",
color = discord.Color.green()
)
embed.add_field(
name = "Наличные",
value = f"{wallet_amt} "
)
await ctx.send(embed=embed)
else:
embed = discord.Embed(
title=f"Баланс {member.name}'a:",
color=discord.Color.green()
)
embed.add_field(
name="Наличные",
value=f"{wallet_amt} "
)
await ctx.send(embed=embed)
def setup(client):
client.add_cog(Economy(client))