Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import discord
- from discord.ext import commands
- from discord.utils import get
- from discord.ext.commands import Bot
- import pymysql
- import asyncio
- #########################################################
- #Config
- bot_token = "NDc0MDMzMDY2OTQwMTcwMjQy.DlQmzw.yeD6G8SwRqI3a628X0r0gS8Kdrc"
- set_prefix = '!'
- channel_id = "484100185300140045"
- embed_logo = "" #Leave blank for no logo, must be a direct link.
- embed_color = 0xffffff #Don't remove 0x. Using Hex Color codes.
- #Database Info.
- db_ip = "43.245.162.42"
- db_user = "distric1_otherus"
- db_pass = "vg_EN9H)9gfi"
- db_name = "distric1_other"
- ##########################################################
- connectionObject = pymysql.connect(host=db_ip, user=db_user, password=db_pass, db=db_name, charset="utf8mb4",
- cursorclass=pymysql.cursors.DictCursor)
- cursorObject = connectionObject.cursor()
- bot = Bot(command_prefix=set_prefix)
- @bot.event
- async def on_ready():
- print("Bot connected!\nCurrently linked to {}\nThis bot was created by https://github.com/Ryanj0nes".format(bot.user.name))
- ########################################################
- latest_id = 0
- async def background_loop():
- global latest_id
- await bot.wait_until_ready()
- while not bot.is_closed:
- sqlQuery = "select * from form ORDER BY id DESC LIMIT 1"
- cursorObject.execute(sqlQuery)
- rows = cursorObject.fetchall()
- for row in rows:
- if row['id'] > latest_id:
- 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']))
- await bot.say(embed=embed)
- latest_id = row['id']
- await asyncio.sleep(60)
- bot.loop.create_task(background_loop())
- bot.run(bot_token)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement