From d65946d8b0455a7cf4a2133c2e7a142a9f51ef92 Mon Sep 17 00:00:00 2001 From: godot Date: Tue, 22 Oct 2024 21:28:02 +0200 Subject: [PATCH] cut()payout()balance() done --- README.md | 13 +------------ disbot.py | 54 ++++++++++++++++++++++++++++++++++++++------------- mainbank.json | 2 +- 3 files changed, 43 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 05b7349..687ba4a 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,3 @@ -## Ahoj functions -- [ ] The whole Ahoj think - - [ ] Case sensitivity -- [ ] Use it on vulgare talk - ## Permisions - [ ] Close bot in specific chanel - [ ] Discord permitions @@ -15,10 +10,4 @@ ## Funkce - [ ] tajne si zjistit svuj balance (do DM) - -## ToDO -- [ ] payout() - - [ ] to cut it from who - - [ ] to autoset how much -- [ ] cut() -- [ ] check_role() awiat bug +- [ ] leaderboard diff --git a/disbot.py b/disbot.py index e9a70bc..d5ea76d 100644 --- a/disbot.py +++ b/disbot.py @@ -29,38 +29,65 @@ async def ahoj(ctx): @bot.command() -async def balance(ctx): +async def balance(ctx, member:discord.Member = "neni"): # test if acount is opend and makes on if not await open_account(ctx.author) - user = ctx.author + if member == "neni": + member = ctx.author + + if member != ctx.author: + + role = await check_role(ctx, ctx.author) + + if role == False: + await ctx.send("Větší snahy ze strany tvé nastati budou než já podlehnu.") + return + users = await get_bank_data() - wallet_amt = users[str(user.id)]["wallet"] + wallet_amt = users[str(member.id)]["wallet"] - em = discord.Embed(title = f"{ctx.author.name}'s balance",color = discord.Color.red()) - em.add_field(name = "Wallet balance", value = wallet_amt) + em = discord.Embed(title = f"{member.name} bodíčky",color = discord.Color.red()) + em.add_field(name = "Bodíčků máš", value = wallet_amt) await ctx.send(embed = em) @bot.command() - # Payout command - # from who???? TODO! async def payout(ctx,member:discord.Member,amount = None): await open_account(member) + role = await check_role(ctx, ctx.author) + if amount == None: - await ctx.send("Plese enter the amount") + await ctx.send("Částku zapoměl napsat jsi.") return - if check_role(ctx, member) == False: - await ctx.send("Good try my man") - if check_role(ctx, member): + if role == False: + await ctx.send("Já nevěřit tvým šprímům, ty více ukázati musíš.") + if role: await update_bank(member,amount) - await ctx.send(f"You gave {member} {amount} coins!") + await ctx.send(f"{member} dostal vyplaceno {amount} bodíčků!") + +@bot.command() +async def cut(ctx,member:discord.Member,amount = None): + + await open_account(member) + + role = await check_role(ctx, ctx.author) + + if amount == None: + await ctx.send("Částku zapoměl napsat jsi.") + return + + if role == False: + await ctx.send("Já nevěřit tvým šprímům, ty více ukázati musíš.") + if role: + await update_bank(member,int(amount)*-1) + + await ctx.send(f"{member} dostal zabaveno {amount} bodíčků!") -# TODO! cut async def open_account(user): # opens json file to found if user id is present @@ -109,3 +136,4 @@ async def check_role(ctx, user:discord.Member): else: return False + diff --git a/mainbank.json b/mainbank.json index 82bce6f..a806b0c 100644 --- a/mainbank.json +++ b/mainbank.json @@ -1 +1 @@ -{"412092791733354521": {"wallet": 660}, "232593965910720514": {"wallet": 100}} \ No newline at end of file +{"412092791733354521": {"wallet": 829}, "232593965910720514": {"wallet": 10136}, "1297253398349090816": {"wallet": 100}} \ No newline at end of file