Advertisement
Guest User

busted

a guest
Dec 30th, 2018
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. import discord as dsc
  2. import mysql.connector
  3.  
  4. sql = connector.connect(user='API', password='Database1', host='127.0.0.1', database='ddbintegration')
  5.  
  6. #Begin SQL function definitions
  7.  
  8. async def addCharacter(DiscordUser, BeyondID, CharacterName):
  9. beyondOwner = await getBeyondNameFromDiscord(DiscordUser)
  10. addchar = ("insert into characters values""(%s, %s, %s")
  11. data = (BeyondID, beyondOwner, CharacterName)
  12. cursor = sql.cursor()
  13. cursor.execute(addchar,data)
  14. async def getBeyondNameFromDiscord(DiscordName):
  15. query = ("select BeyondName from users""where DiscordName=%s")
  16. data = (DiscordName)
  17. cursor = sql.cursor()
  18. cursor.execute(query, data)
  19. return cursor[0]
  20. async def getCharacters():
  21. query = ("select * from characters")
  22. cursor = sql.cursor()
  23. cursor.execute(query)
  24. return cursor
  25.  
  26. #End SQL function definitions
  27. #Begin Discord function definitions
  28. async def list(message):
  29. reply = ""
  30. cursor = await getCharacters()
  31. for beyondID, BeyondOwner in cursor:
  32. reply += f'{beyondID}|{BeyondOwner} \n '
  33. await client.send_message(message.channel, reply)
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47. client = dsc.Client()
  48.  
  49.  
  50. @client.event
  51. async def on_ready():
  52. print("Logged in")
  53.  
  54. @client.event
  55. async def on_message(message):
  56. if message.content.startswith("!test"):
  57. await client.send_message(message.channel, "Hello, World! I\'m Trying out Discord.py for our bot. This way, Shauna should also be able to read the code, once she's done with her class.")
  58.  
  59. elif message.content.startswith("!uid"):
  60. await client.send_message(message.channel, message.author)
  61. elif message.content.startswith("!list"):
  62. await list(message)
  63. client.run('NTIwNjg4ODMxMTM4MzY1NDQw.Dwqz1A.73cPDca6srC3Ufc3V9c3Gv2loJI')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement