More logging

This commit is contained in:
Nikolaj Danger
2020-03-24 11:09:31 +01:00
parent da0aea540c
commit de6ee115e7
3 changed files with 22 additions and 8 deletions

View File

@ -1,10 +1,11 @@
import math
import discord
import json
import logging
from funcs import gwendolynFuncs as gf
logging.basicConfig(filename="gwendolyn.log", level=logging.INFO)
def modifier(statistic):
mods = math.floor((statistic-10)/2)
@ -18,15 +19,17 @@ abilities = ["acrobatics","animal_handling","arcana","athletics","deception","hi
def monsterFunc(content):
command = gf.cap(content.lower().replace("!monster ",""))
print("Looking up "+command)
logging.info("Looking up "+command)
if len(content.lower().split()) < 2:
print("Monster doesn't exist in database")
print("")
print("Monster doesn't exist in database\n")
logging.info("Monster doesn't exist in database\n")
return("I don't know that monster...","","","","","")
else:
data = json.load(open('funcs/lookup/monsters.json', encoding = "utf8"))
for monster in data:
print("Found it!")
if str(command) == monster["name"]:
print("Found it!")
logging.info("Found it!")
if monster["subtype"] != "":
typs = (monster["type"]+" ("+monster["subtype"]+")")
else:
@ -104,8 +107,8 @@ def monsterFunc(content):
text3 = (act)
text4 = (react)
text5 = (leg_act)
print("Returning monster information")
print("")
print("Returning monster information\n")
logging.info("Returning monster information\n")
return(str(command),text1,text2,text3,text4,text5)
print("")
return("I don't know that monster...","","","","","")
@ -113,12 +116,16 @@ def monsterFunc(content):
def spellFunc(content):
command = gf.cap(content.lower().replace("!spell ",""))
print("Looking up "+command)
logging.info("Looking up "+command)
data = json.load(open('funcs/lookup/spells.json', encoding = "utf8"))
if str(command) in data:
print("Returning spell information")
logging.info("Returning spell information")
spell_output = ("***"+str(command)+"***\n*"+str(data[str(command)]["level"])+" level "+str(data[str(command)]["school"])+"\nCasting Time: "+str(data[str(command)]["casting_time"])+"\nRange: "+str(data[str(command)]["range"])+"\nComponents: "+str(data[str(command)]["components"])+"\nDuration: "+str(data[str(command)]["duration"])+"*\n \n"+str(data[str(command)]["description"]))
else:
print("I don't know that spell")
logging.info("I don't know that spell")
spell_output = "I don't think that's a spell"
print("Successfully ran !spell")
logging.info("Successfully ran !spell")
return(spell_output)