payout done, checkrole bug

This commit is contained in:
godot 2024-10-22 12:40:55 +02:00
parent dca2fa387f
commit bc3061ac92
3 changed files with 53 additions and 23 deletions

View File

@ -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

View File

@ -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):
@ -47,6 +42,25 @@ async def balance(ctx):
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
await ctx.send(f"Someone just gave you {earnings} coins")
users[str(user.id)]["wallet"] += earnings
users[str(user.id)]["wallet"] += int(change)
with open("mainbank.json", "w") as f:
json.dump(users,f)
bot.run(token)
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

View File

@ -1 +1 @@
{"412092791733354521": {"wallet": 120}, "232593965910720514": {"wallet": 100}}
{"412092791733354521": {"wallet": 660}, "232593965910720514": {"wallet": 100}}