Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @bot.event
- async def on_command(command, ctx):
- if command_logging == True:
- connection = pymysql.connect(host='cccc',
- user='ccc',
- password='ccc',
- db='ccc',
- charset='utf8mb4',
- cursorclass=pymysql.cursors.DictCursor)
- try:
- with connection.cursor() as cursor:
- sql = "INSERT INTO `command_logs` (`server`, `time`, `channel`, `author`, `command`, `message`) VALUES (%s, %s, %s, %s, %s, %s)"
- 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))
- connection.commit()
- finally:
- connection.close()
- try:
- msg = "NotSoBot Logs\n"
- msg += "User: {0} <{1}>\n".format(ctx.message.author, ctx.message.author.id)
- msg += "Command: {0}\n".format(ctx.invoked_with)
- msg += "Server: {0}\n".format(ctx.message.server.name)
- msg += "Channel: {0}\n".format(ctx.message.channel.name)
- msg += "Context Message: {0}".format(ctx.message.content)
- channel = discord.Object(id='150813303822614528')
- await bot.send_message(channel, cool.format(msg))
- await bot.process_commands(command)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement