K
K
Kenity2021-09-26 19:58:05
Python
Kenity, 2021-09-26 19:58:05

How to make the bot give out the balance?

There is a code that randomly gives the balance. I want to make the bot take or give out money at the command and mention of a person. How to do it?

The code:

@client.command()
async def give(ctx, member: discord.Member):
    await open_account(ctx.author)
    user = ctx.author

    users = await get_bank_data()

    earnings = random.randrange(1000000)

    await ctx.send(f'{ctx.author.mention} Got {earnings} coins!!')

    users[str(user.id)]["wallet"] += earnings

    with open("mainbank.json",'w') as f:
        json.dump(users,f)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2021-09-26
@Kenity

everything is well described in the documentation .
if you can't google "python json", I think writing bots should be delayed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question