-
Notifications
You must be signed in to change notification settings - Fork 0
/
cashout.py
executable file
·55 lines (42 loc) · 1.63 KB
/
cashout.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/python3 -u
import discord
import os
from dotenv import load_dotenv
from discord.ext import commands
from datetime import datetime
import mysql.connector
load_dotenv()
intents = discord.Intents.all()
client = commands.Bot(command_prefix='!', intents=intents)
mydb = mysql.connector.connect(
host="localhost",
user="root",
password=os.getenv('db_password'),
database="burnt_bot"
)
mycursor = mydb.cursor()
@client.event
async def on_ready():
print('!cashout started on bot {0.user}'.format(client))
@client.command()
async def cashout(ctx, user: discord.Member):
if ctx.channel.category_id == int(os.getenv('payout_cat')):
mycursor.execute(str("SELECT date, buyer, amount FROM commissions WHERE id=" + str(user.id)))
commissions = mycursor.fetchall()
if not commissions:
await ctx.send("<@!" + str(user.id) + "> has no available commissions.")
else:
total=0
for commission in commissions:
total=total+int(commission[2])
mycursor.execute("DELETE FROM commissions WHERE id=" + str(user.id))
mydb.commit()
await ctx.send("<@!" + str(user.id) + "> has been marked as cashed out for all available commissions (" + total + ")")
else:
await ctx.send("You must use this command in a payout channel")
print(str(str(ctx.author) + " cashed out " + str(user) + " for " + str(total)))
@cashout.error
async def cashout_error(ctx, error):
if isinstance(error, discord.ext.commands.errors.MissingRequiredArgument):
await ctx.send("Must provide @User to cashout")
client.run(os.getenv('TOKEN'))