diff --git a/README.md b/README.md index fa781c8..05b7349 100644 --- a/README.md +++ b/README.md @@ -10,3 +10,15 @@ ## To learn - [ ] Embeds learning +## Token Security +- [ ] how to import it + +## Funkce +- [ ] tajne si zjistit svuj balance (do DM) + +## ToDO +- [ ] payout() + - [ ] to cut it from who + - [ ] to autoset how much +- [ ] cut() +- [ ] check_role() awiat bug diff --git a/disbot.py b/disbot.py index 004e470..e9a70bc 100644 --- a/disbot.py +++ b/disbot.py @@ -1,6 +1,6 @@ import discord from discord.ext import commands -from private.config import token +#from private.config import token import json import os @@ -17,21 +17,16 @@ bot = commands.Bot(command_prefix='$', intents=intents) @bot.event + # Start succes indicator async def on_ready(): print(f'We have logged in as {bot.user}') -""" -@bot.event() -async def on_message(message): - # test is bot is not responding to itself - if message.author == bot.user: - return +@bot.command() + # Ahoj function +async def ahoj(ctx): + await ctx.send("Zdravím miláčkové!") - # hello reaction - if message.content.startswith('ahoj'): - await message.channel.send('Zdravím miláčkové!') -""" @bot.command() async def balance(ctx): @@ -46,7 +41,26 @@ async def balance(ctx): em = discord.Embed(title = f"{ctx.author.name}'s balance",color = discord.Color.red()) em.add_field(name = "Wallet balance", 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) + + if amount == None: + await ctx.send("Plese enter the amount") + return + + if check_role(ctx, member) == False: + await ctx.send("Good try my man") + if check_role(ctx, member): + await update_bank(member,amount) + + await ctx.send(f"You gave {member} {amount} coins!") + +# TODO! cut async def open_account(user): # opens json file to found if user id is present @@ -73,21 +87,25 @@ async def get_bank_data(): return users - # for testing perpesis only -@bot.command() -async def beg(ctx): - await open_account(ctx.author) +async def update_bank(user,change = 0): users = await get_bank_data() - user = ctx.author - earnings = 10 + users[str(user.id)]["wallet"] += int(change) - await ctx.send(f"Someone just gave you {earnings} coins") - - users[str(user.id)]["wallet"] += earnings - with open("mainbank.json", "w") as f: json.dump(users,f) + + bal = [users[str(user.id)]["wallet"]] + + return bal + +async def check_role(ctx, user:discord.Member): + + role = discord.utils.get(ctx.guild.roles,name = "Učitelé") + + if role in user.roles: + return True + else: + return False -bot.run(token) diff --git a/mainbank.json b/mainbank.json index 87b15a3..82bce6f 100644 --- a/mainbank.json +++ b/mainbank.json @@ -1 +1 @@ -{"412092791733354521": {"wallet": 120}, "232593965910720514": {"wallet": 100}} \ No newline at end of file +{"412092791733354521": {"wallet": 660}, "232593965910720514": {"wallet": 100}} \ No newline at end of file