Adding logging, ignoring log file, cleaning up python file lint warnings.
This commit is contained in:
@@ -4,3 +4,4 @@ node_modules/
|
|||||||
|
|
||||||
config.json
|
config.json
|
||||||
.vscode
|
.vscode
|
||||||
|
discord.log
|
||||||
|
|||||||
+18
-2
@@ -1,19 +1,35 @@
|
|||||||
|
"""
|
||||||
|
pvm_highscores discord bot
|
||||||
|
"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
import discord
|
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()
|
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)
|
config_data = json.load(file)
|
||||||
|
|
||||||
|
|
||||||
@client.event
|
@client.event
|
||||||
async def on_ready():
|
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
|
@client.event
|
||||||
async def on_message(message):
|
async def on_message(message):
|
||||||
|
""""runs when message is sent on server"""
|
||||||
print("message get")
|
print("message get")
|
||||||
if message.author == client.user:
|
if message.author == client.user:
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user