Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import discord
- import mysql.connector
- import random
- client = discord.Client()
- mydb = mysql.connector.connect(
- host='localhost',
- user="root",
- passwd="secret",
- database="usercurrency",
- port="2565"
- )
- token = "secret"
- def generateSC():
- random.randint(20, 100)
- @client.event
- async def on_ready():
- print("Bot is logged in.")
- print(mydb)
- @client.event
- async def on_message(message):
- if message.author.bot:
- return
- if message.content.lower() == '?help':
- pass
- elif message.content.lower() == '?addrole':
- pass
- elif message.content.lower() == '?daily':
- sc = generateSC()
- print(message.author.name + "will recieve" + str(sc) + "Sythical Coins")
- cursor = mydb.cursor()
- cursor.execute("SELECT user_sc FROM users WHERE client_id = " + str(message.author.id))
- result = cursor.fetchall()
- print(result)
- if(len(result) == 0):
- print("User is not in db, add them")
- cursor.execute("INSERT INTO users VALUES(" + str(message.author.id) + "," + str(sc) + ")")
- mydb.commit()
- print("Inserted...")
- else:
- pass
- client.run(token)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement