Advertisement
Guest User

Untitled

a guest
May 1st, 2016
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. @bot.event
  2. async def on_command(command, ctx):
  3. if command_logging == True:
  4. connection = pymysql.connect(host='cccc',
  5. user='ccc',
  6. password='ccc',
  7. db='ccc',
  8. charset='utf8mb4',
  9. cursorclass=pymysql.cursors.DictCursor)
  10. try:
  11. with connection.cursor() as cursor:
  12. sql = "INSERT INTO `command_logs` (`server`, `time`, `channel`, `author`, `command`, `message`) VALUES (%s, %s, %s, %s, %s, %s)"
  13. cursor.execute(sql, (ctx.message.server.name, ctx.message.timestamp, ctx.message.channel.name, "{0} <{1}>".format(ctx.message.author.name, ctx.message.author.id), ctx.invoked_with, ctx.message.content))
  14. connection.commit()
  15. finally:
  16. connection.close()
  17. try:
  18. msg = "NotSoBot Logs\n"
  19. msg += "User: {0} <{1}>\n".format(ctx.message.author, ctx.message.author.id)
  20. msg += "Command: {0}\n".format(ctx.invoked_with)
  21. msg += "Server: {0}\n".format(ctx.message.server.name)
  22. msg += "Channel: {0}\n".format(ctx.message.channel.name)
  23. msg += "Context Message: {0}".format(ctx.message.content)
  24. channel = discord.Object(id='150813303822614528')
  25. await bot.send_message(channel, cool.format(msg))
  26. await bot.process_commands(command)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement