payout done, checkrole bug
This commit is contained in:
parent
dca2fa387f
commit
bc3061ac92
12
README.md
12
README.md
@ -10,3 +10,15 @@
|
|||||||
## To learn
|
## To learn
|
||||||
- [ ] Embeds learning
|
- [ ] 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
|
||||||
|
|||||||
62
disbot.py
62
disbot.py
@ -1,6 +1,6 @@
|
|||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from private.config import token
|
#from private.config import token
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
@ -17,21 +17,16 @@ bot = commands.Bot(command_prefix='$', intents=intents)
|
|||||||
|
|
||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
|
# Start succes indicator
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
print(f'We have logged in as {bot.user}')
|
print(f'We have logged in as {bot.user}')
|
||||||
|
|
||||||
"""
|
|
||||||
@bot.event()
|
|
||||||
async def on_message(message):
|
|
||||||
|
|
||||||
# test is bot is not responding to itself
|
@bot.command()
|
||||||
if message.author == bot.user:
|
# Ahoj function
|
||||||
return
|
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()
|
@bot.command()
|
||||||
async def balance(ctx):
|
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 = discord.Embed(title = f"{ctx.author.name}'s balance",color = discord.Color.red())
|
||||||
em.add_field(name = "Wallet balance", value = wallet_amt)
|
em.add_field(name = "Wallet balance", value = wallet_amt)
|
||||||
await ctx.send(embed = em)
|
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):
|
async def open_account(user):
|
||||||
# opens json file to found if user id is present
|
# opens json file to found if user id is present
|
||||||
@ -73,21 +87,25 @@ async def get_bank_data():
|
|||||||
|
|
||||||
return users
|
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()
|
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:
|
with open("mainbank.json", "w") as f:
|
||||||
json.dump(users,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)
|
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
{"412092791733354521": {"wallet": 120}, "232593965910720514": {"wallet": 100}}
|
{"412092791733354521": {"wallet": 660}, "232593965910720514": {"wallet": 100}}
|
||||||
Loading…
x
Reference in New Issue
Block a user