-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiscord bot master.py
136 lines (116 loc) · 4.08 KB
/
discord bot master.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import discord
from discord.ext import commands
import sqlite3
currencyname = 'dobloons'
currencyname = str(currencyname)
currencyname = ' ' + currencyname
client = commands.Bot(command_prefix = '!')
@client.command(pass_context=True)
@client.event
async def on_ready():
print('bot is ready')
@client.command()
async def ping():
await client.say('Pong!')
@client.command()
async def echo(*args):
output = ''
for word in args:
output += word
output += ' '
await client.say(output)
@client.command(pass_context=True)
async def balance(ctx, *arg):
currencyamount = arg[-1]
arg = arg[:-1]
membername = ''
currentbalance= ''
for argument in arg:
membername += str(argument) + ' '
print(membername)
membername = "'" + membername
membername = membername + "'"
print(membername)
conn = sqlite3.connect('currency_store.db')
c = conn.cursor()
c.execute("CREATE TABLE IF NOT EXISTS currency(user STR, balance INT)")
c.execute("SELECT balance FROM currency WHERE user = ?", (membername,))
currentbalance = c.fetchall()
currentbalance = str(currentbalance)
currentbalance = currentbalance[2:-3]
if currentbalance == '':
await client.say('that person isnt in the database')
else:
currentbalance = str(currentbalance)
currentbalance = currentbalance + currencyname
await client.say('that persons balance is')
await client.say(currentbalance)
@client.command(pass_context=True)
@commands.has_role('currency')
async def insert(ctx, *arg):
arg = arg[:-1]
membername = ''
currentbalance= ''
for argument in arg:
membername += str(argument) + ' '
membername = "'" + membername
membername = membername + "'"
print(membername)
conn = sqlite3.connect('currency_store.db')
c = conn.cursor()
c.execute("CREATE TABLE IF NOT EXISTS currency(user STR, balance INT)")
if membername == "''":
await client.say("incorrect formatting, you have to @ the person twice")
await client.say()
if currentbalance == '':
await client.say('checking databse')
c.execute("SELECT balance FROM currency WHERE user = ?", (membername,))
currentbalance = c.fetchall()
currentbalance = str(currentbalance)
currentbalance = currentbalance[2:-3]
if currentbalance == '':
await client.say("adding user to database")
c.execute("INSERT INTO currency VALUES(?,0)",(membername,))
conn.commit()
await client.say("added user to database")
else:
await client.say("user is already in the database")
else:
await client.say("oopsy, that person is in the database")
@client.command(pass_context=True)
@commands.has_role('currency')
async def give(ctx, *arg):
currencyamount = arg[-1]
arg = arg[:-1]
membername = ''
currentbalance= ''
for argument in arg:
membername += str(argument) + ' '
print(membername)
membername = "'" + membername
membername = membername + "'"
print(membername)
conn = sqlite3.connect('currency_store.db')
c = conn.cursor()
c.execute("CREATE TABLE IF NOT EXISTS currency(user STR, balance INT)")
c.execute("SELECT balance FROM currency WHERE user = ?", (membername,))
currentbalance = c.fetchall()
currentbalance = str(currentbalance)
currentbalance = currentbalance[2:-3]
if currentbalance == '':
await client.say('uhhh, that person isnt in the database')
currentbalance = int(currentbalance)
currencyamount = int(currencyamount)
currentbalance = currentbalance + currencyamount
currentbalance = str(currentbalance)
currentbalance = currentbalance + currencyname
await client.say('new balance')
await client.say(currentbalance)
c.execute("UPDATE currency SET balance = ? WHERE user =?",(currentbalance,membername,))
conn.commit()
await client.say("balance successfully updated")
@client.command()
async def broken():
await client.say('im sorry, im trying my best')
await client.say(person)
client.run('TOKEN')