Adding logging, ignoring log file, cleaning up python file lint warnings.

This commit is contained in:
alwayscompiling
2022-06-22 21:30:01 -04:00
parent 1015b0f557
commit 692d43f8ae
2 changed files with 19 additions and 2 deletions
+1
View File
@@ -4,3 +4,4 @@ node_modules/
config.json
.vscode
discord.log
+18 -2
View File
@@ -1,19 +1,35 @@
"""
pvm_highscores discord bot
"""
import json
import logging
import discord
logger = logging.getLogger('discord')
logger.setLevel(logging.DEBUG)
handler = logging.FileHandler(
filename='discord.log', encoding='utf-8', mode='w')
handler.setFormatter(logging.Formatter(
'%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
logger.addHandler(handler)
client = discord.Client()
with open("config.json") as file:
with open("config.json", encoding='utf-8', mode='r') as file:
config_data = json.load(file)
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
""""reports when bot logs in"""
print(f'We have logged in as {client.user}')
@client.event
async def on_message(message):
""""runs when message is sent on server"""
print("message get")
if message.author == client.user:
return