Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. import discord
  2. from discord.ext import commands
  3. from discord.utils import get
  4. from discord.ext.commands import Bot
  5. import pymysql
  6. import asyncio
  7.  
  8. #########################################################
  9.  
  10. #Config
  11. bot_token = "NDc0MDMzMDY2OTQwMTcwMjQy.DlQmzw.yeD6G8SwRqI3a628X0r0gS8Kdrc"
  12. set_prefix = '!'
  13. channel_id = "484100185300140045"
  14.  
  15. embed_logo = "" #Leave blank for no logo, must be a direct link.
  16. embed_color = 0xffffff #Don't remove 0x. Using Hex Color codes.
  17.  
  18. #Database Info.
  19. db_ip = "43.245.162.42"
  20. db_user = "distric1_otherus"
  21. db_pass = "vg_EN9H)9gfi"
  22. db_name = "distric1_other"
  23.  
  24. ##########################################################
  25.  
  26. connectionObject = pymysql.connect(host=db_ip, user=db_user, password=db_pass, db=db_name, charset="utf8mb4",
  27.  
  28. cursorclass=pymysql.cursors.DictCursor)
  29.  
  30. cursorObject = connectionObject.cursor()
  31.  
  32. bot = Bot(command_prefix=set_prefix)
  33.  
  34. @bot.event
  35. async def on_ready():
  36. print("Bot connected!\nCurrently linked to {}\nThis bot was created by https://github.com/Ryanj0nes".format(bot.user.name))
  37.  
  38. ########################################################
  39.  
  40. latest_id = 0
  41. async def background_loop():
  42. global latest_id
  43. await bot.wait_until_ready()
  44. while not bot.is_closed:
  45. sqlQuery = "select * from form ORDER BY id DESC LIMIT 1"
  46. cursorObject.execute(sqlQuery)
  47. rows = cursorObject.fetchall()
  48.  
  49. for row in rows:
  50. if row['id'] > latest_id:
  51. embed = discord.Embed(title="{} has submitted a request!".format(row['name']), colour=discord.Colour(0xb3e4b5), description="**Name:** {}\n **Email:** {}\n**Community:** {}\n**Price:** {}\n**Message:**\n{}".format(row['name'],row['email'],row['community'],row['price'], row['message']))
  52. await bot.say(embed=embed)
  53. latest_id = row['id']
  54. await asyncio.sleep(60)
  55.  
  56. bot.loop.create_task(background_loop())
  57.  
  58. bot.run(bot_token)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement