Logging
This commit is contained in:
@ -1,11 +1,8 @@
|
||||
import math
|
||||
import discord
|
||||
import json
|
||||
import logging
|
||||
|
||||
from funcs import gwendolynFuncs as gf
|
||||
|
||||
logging.basicConfig(filename="gwendolyn.log", level=logging.INFO)
|
||||
from funcs import cap, logThis
|
||||
|
||||
# Calculates D&D stat modifier
|
||||
def modifier(statistic):
|
||||
@ -19,22 +16,19 @@ abilities = ["acrobatics","animal_handling","arcana","athletics","deception","hi
|
||||
|
||||
# Looks up a monster
|
||||
def monsterFunc(content):
|
||||
command = gf.cap(content.lower().replace("!monster ",""))
|
||||
print("Looking up "+command)
|
||||
logging.info("Looking up "+command)
|
||||
command = cap(content.lower().replace("!monster ",""))
|
||||
logThis("Looking up "+command)
|
||||
|
||||
# 1-letter monsters don't exist
|
||||
if len(content.lower().split()) < 2:
|
||||
print("Monster doesn't exist in database\n")
|
||||
logging.info("Monster doesn't exist in database\n")
|
||||
logThis("Monster doesn't exist in database")
|
||||
return("I don't know that monster...","","","","","")
|
||||
else:
|
||||
# Opens "mensters.json"
|
||||
data = json.load(open('resources/monsters.json', encoding = "utf8"))
|
||||
for monster in data:
|
||||
if str(command) == monster["name"]:
|
||||
print("Found it!")
|
||||
logging.info("Found it!")
|
||||
logThis("Found it!")
|
||||
|
||||
# Looks at the information about the monster and returns that information
|
||||
# in seperate variables, allowing Gwendolyn to know where to seperate
|
||||
@ -52,9 +46,9 @@ def monsterFunc(content):
|
||||
for save in saves:
|
||||
if save in monster:
|
||||
if monster[save] >= 0:
|
||||
saving_throws += " "+gf.cap(save[:3])+" +"+str(monster[save])+","
|
||||
saving_throws += " "+cap(save[:3])+" +"+str(monster[save])+","
|
||||
else:
|
||||
saving_throws += " "+gf.cap(save[:3])+" "+str(monster[save])+","
|
||||
saving_throws += " "+cap(save[:3])+" "+str(monster[save])+","
|
||||
if saving_throws != "":
|
||||
saving_throws = "\n**Saving Throws**"+saving_throws[:-1]
|
||||
|
||||
@ -62,9 +56,9 @@ def monsterFunc(content):
|
||||
for skill in abilities:
|
||||
if skill in monster:
|
||||
if monster[skill] >= 0:
|
||||
skills += " "+gf.cap(skill.replace("_"," "))+" +"+str(monster[skill])+","
|
||||
skills += " "+cap(skill.replace("_"," "))+" +"+str(monster[skill])+","
|
||||
else:
|
||||
skills += " "+gf.cap(skill.replace("_"," "))+" "+str(monster[skill])+","
|
||||
skills += " "+cap(skill.replace("_"," "))+" "+str(monster[skill])+","
|
||||
if skills != "":
|
||||
skills = "\n**Skills**"+skills[:-1]
|
||||
|
||||
@ -122,29 +116,23 @@ def monsterFunc(content):
|
||||
text4 = (react)
|
||||
text5 = (leg_act)
|
||||
|
||||
print("Returning monster information")
|
||||
logging.info("Returning monster information")
|
||||
logThis("Returning monster information")
|
||||
return(str(command),text1,text2,text3,text4,text5)
|
||||
print("Couldn't find monster")
|
||||
logging.info("Couldn't find monster")
|
||||
logThis("Couldn't find monster")
|
||||
return("I don't know that monster...","","","","","")
|
||||
|
||||
# Looks up a spell
|
||||
def spellFunc(content):
|
||||
command = gf.cap(content.lower().replace("!spell ",""))
|
||||
print("Looking up "+command)
|
||||
logging.info("Looking up "+command)
|
||||
command = cap(content.lower().replace("!spell ",""))
|
||||
logThis("Looking up "+command)
|
||||
|
||||
# Opens "spells.json"
|
||||
data = json.load(open('resources/spells.json', encoding = "utf8"))
|
||||
if str(command) in data:
|
||||
print("Returning spell information")
|
||||
logging.info("Returning spell information")
|
||||
logThis("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")
|
||||
logThis("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")
|
||||
logThis("Successfully ran !spell")
|
||||
return(spell_output)
|
||||
|
Reference in New Issue
Block a user