🥅 Error codes

This commit is contained in:
NikolajDanger
2020-07-29 12:14:30 +02:00
parent ef434ecee8
commit b991ac0385
10 changed files with 489 additions and 280 deletions

View File

@ -22,11 +22,16 @@ meanWords = ["stupid", "bitch", "fuck", "dumb", "idiot"]
async def parseCommands(message,content): async def parseCommands(message,content):
# Sends the contents of a help file, as specified by the message. # Sends the contents of a help file, as specified by the message.
if content.startswith("help"): if content.startswith("help"):
try:
if content == "help" or content == "help ": if content == "help" or content == "help ":
try:
with codecs.open("resources/help/help.txt",encoding="utf-8") as f: with codecs.open("resources/help/help.txt",encoding="utf-8") as f:
text = f.read() text = f.read()
em = discord.Embed(title = "Help", description = text,colour = 0x59f442) em = discord.Embed(title = "Help", description = text,colour = 0x59f442)
await message.channel.send(embed = em) await message.channel.send(embed = em)
except:
logThis("Couldn't find help.txt (error code 101)")
await message.channel.send("Couldn't find help.txt (error code 101)")
else: else:
command = content.replace(" ","-") command = content.replace(" ","-")
logThis("Looking for "+command+".txt") logThis("Looking for "+command+".txt")
@ -36,7 +41,11 @@ async def parseCommands(message,content):
em = discord.Embed(title = command.replace("help-","").capitalize(), description = text,colour = 0x59f442) em = discord.Embed(title = command.replace("help-","").capitalize(), description = text,colour = 0x59f442)
await message.channel.send(embed = em) await message.channel.send(embed = em)
except: except:
await message.channel.send("Couldn't find help for that command") logThis("Couldn't find help for that command (error code 102)")
await message.channel.send("Couldn't find help for that command (error code 102)")
except:
logThis("Something fucked up (error code 100)")
await message.channel.send("Something fucked up (error code 100)")
# Logs whatever you write in the message # Logs whatever you write in the message
if content.startswith("log "): if content.startswith("log "):
@ -44,6 +53,7 @@ async def parseCommands(message,content):
# Stops the bot # Stops the bot
elif content.startswith("stop"): elif content.startswith("stop"):
try:
if message.author.display_name == "Nikolaj": if message.author.display_name == "Nikolaj":
await message.channel.send("Logging out...") await message.channel.send("Logging out...")
@ -59,27 +69,42 @@ async def parseCommands(message,content):
await client.logout() await client.logout()
else: else:
logThis(message.author.display_name+" tried to run stop me!") logThis(message.author.display_name+" tried to run stop me! (error code 201)")
await message.channel.send("I don't think I will, "+message.author.display_name) await message.channel.send("I don't think I will, "+message.author.display_name+" (error code 201)")
except:
logThis("Something fucked up (error code 200)")
await message.channel.send("Something fucked up (error code 200)")
# Does a hello with the helloFunc function from funcs/gwendolynpy # Does a hello with the helloFunc function from funcs/gwendolynpy
elif content.startswith("hello"): elif content.startswith("hello"):
try:
await message.channel.send(helloFunc(message.author.display_name)) await message.channel.send(helloFunc(message.author.display_name))
except:
logThis("Something fucked up (error code 310)")
await message.channel.send("Something fucked up (error code 310)")
# Rolls dice with the roll_dice function from funcs/roll/dice.py # Rolls dice with the roll_dice function from funcs/roll/dice.py
elif content.startswith("roll"): elif content.startswith("roll"):
try:
if content == "roll" or content == "roll ": if content == "roll" or content == "roll ":
await message.channel.send(roll_dice(message.author.display_name)) await message.channel.send(roll_dice(message.author.display_name))
else: else:
await message.channel.send(roll_dice(message.author.display_name, content.replace("roll",""))) await message.channel.send(roll_dice(message.author.display_name, content.replace("roll","")))
except:
logThis("Something fucked up (error code 400)")
await message.channel.send("Something fucked up (error code 400)")
# Looks up a spell with the spellFunc function from funcs/lookup/lookuppy # Looks up a spell with the spellFunc function from funcs/lookup/lookuppy
elif content.startswith("spell "): elif content.startswith("spell "):
try:
await message.channel.send(spellFunc(cap(content.replace("spell","")))) await message.channel.send(spellFunc(cap(content.replace("spell",""))))
except:
logThis("Something fucked up (error code 500)")
await message.channel.send("Something fucked up (error code 500)")
# Looks up a monster with the monsterFuncs() from funcs/lookup/lookuppy # Looks up a monster with the monsterFuncs() from funcs/lookup/lookuppy
elif content.startswith("monster "): elif content.startswith("monster "):
try:
title, text1, text2, text3, text4, text5 = monsterFunc(cap(content.replace("monster",""))) title, text1, text2, text3, text4, text5 = monsterFunc(cap(content.replace("monster","")))
em1 = discord.Embed(title = title, description = text1, colour=0xDEADBF) em1 = discord.Embed(title = title, description = text1, colour=0xDEADBF)
@ -122,61 +147,97 @@ async def parseCommands(message,content):
await message.channel.send(embed = em5) await message.channel.send(embed = em5)
em5_2 = discord.Embed(title = "", description = text5[2048:], colour=0xDEADBF) em5_2 = discord.Embed(title = "", description = text5[2048:], colour=0xDEADBF)
await message.channel.send(embed = em5_2) await message.channel.send(embed = em5_2)
except:
logThis("Something fucked up (error code 600)")
await message.channel.send("Something fucked up (error code 600)")
# Sends an image of the Senkulpa map # Sends an image of the Senkulpa map
elif content.startswith("map"): elif content.startswith("map"):
try:
await message.channel.send("https://i.imgur.com/diMXXJs.jpg") await message.channel.send("https://i.imgur.com/diMXXJs.jpg")
except:
logThis("Something fucked up (error code 320)")
await message.channel.send("Something fucked up (error code 320)")
# Finds a random image on the internet with the imageFuncs function from # Finds a random image on the internet with the imageFuncs function from
# funcs/gwendolynpy # funcs/gwendolynpy
elif content.startswith("image"): elif content.startswith("image"):
try:
await message.channel.send(imageFunc()) await message.channel.send(imageFunc())
except:
logThis("Something fucked up (error code 700)")
await message.channel.send("Something fucked up (error code 700)")
# Sends information about a random movie with the movieFunc function from # Sends information about a random movie with the movieFunc function from
# funcs/other/movie.py # funcs/other/movie.py
elif content.startswith("movie"): elif content.startswith("movie"):
try:
async with message.channel.typing(): async with message.channel.typing():
title, plot, cover, cast = movieFunc() title, plot, cover, cast = movieFunc()
if title == "error": if title == "error":
await message.channel.send("An error occurred. Try again") await message.channel.send("An error occurred. Try again (error code "+plot+")")
else: else:
embed = discord.Embed(title=title, description=plot, color=0x24ec19) embed = discord.Embed(title=title, description=plot, color=0x24ec19)
embed.set_thumbnail(url=cover) embed.set_thumbnail(url=cover)
embed.add_field(name="Cast", value=cast,inline = True) embed.add_field(name="Cast", value=cast,inline = True)
await message.channel.send(embed = embed) await message.channel.send(embed = embed)
except:
logThis("Something fucked up (error code 800)")
await message.channel.send("Something fucked up (error code 800)")
# Generates a random name with the nameGen function from funcs/other/generators.py # Generates a random name with the nameGen function from funcs/other/generators.py
elif content.startswith("name"): elif content.startswith("name"):
try:
await message.channel.send(nameGen()) await message.channel.send(nameGen())
except:
logThis("Something fucked up (error code 330)")
await message.channel.send("Something fucked up (error code 330)")
# Generates a random tavern name with the tavernGen function from funcs/other/generators.py # Generates a random tavern name with the tavernGen function from funcs/other/generators.py
elif content.startswith("tavern"): elif content.startswith("tavern"):
try:
await message.channel.send(tavernGen()) await message.channel.send(tavernGen())
except:
logThis("Something fucked up (error code 340)")
await message.channel.send("Something fucked up (error code 340)")
# Changes the "Playing this game" thing in Discord # Changes the "Playing this game" thing in Discord
elif content.startswith("game "): elif content.startswith("game "):
try:
gamePlaying = cap(content.replace("game ","")) gamePlaying = cap(content.replace("game ",""))
game = discord.Game(gamePlaying) game = discord.Game(gamePlaying)
await client.change_presence(activity=game) await client.change_presence(activity=game)
except:
logThis("Something fucked up (error code 350)")
await message.channel.send("Something fucked up (error code 350)")
# Rolls star wars dice with the parseRoll function from funcs/swfuncs/swroll.py # Rolls star wars dice with the parseRoll function from funcs/swfuncs/swroll.py
elif content.startswith("swroll"): elif content.startswith("swroll"):
try:
command = cap(content.replace("swroll","")) command = cap(content.replace("swroll",""))
newMessage = parseRoll(message.author.display_name,command) newMessage = parseRoll(message.author.display_name,command)
messageList = newMessage.split("\n") messageList = newMessage.split("\n")
for messageItem in messageList: for messageItem in messageList:
await message.channel.send(messageItem) await message.channel.send(messageItem)
except:
logThis("Something fucked up (error code 910)")
await message.channel.send("Something fucked up (error code 910)")
# Deals with Destiny Points and stuff # Deals with Destiny Points and stuff
elif content.startswith("swd"): elif content.startswith("swd"):
try:
command = content.replace("swd","") command = content.replace("swd","")
newMessage = parseDestiny(message.author.display_name,command) newMessage = parseDestiny(message.author.display_name,command)
messageList = newMessage.split("\n") messageList = newMessage.split("\n")
for messageItem in messageList: for messageItem in messageList:
await message.channel.send(messageItem) await message.channel.send(messageItem)
except:
logThis("Something fucked up (error code 920)")
await message.channel.send("Something fucked up (error code 920)")
# Rolls for critical injuries # Rolls for critical injuries
elif content.startswith("swcrit"): elif content.startswith("swcrit"):
try:
command = content.replace("swcrit","").replace(" ","").replace("+","") command = content.replace("swcrit","").replace(" ","").replace("+","")
if command == "": if command == "":
@ -185,15 +246,20 @@ async def parseCommands(message,content):
try: try:
newMessage = critRoll(int(command)) newMessage = critRoll(int(command))
except: except:
newMessage = "Try using a number, stupid" logThis("They didn't include a number (error code 931)")
newMessage = "Try using a number, stupid (error code 931)"
messageList = newMessage.split("\n") messageList = newMessage.split("\n")
for messageItem in messageList: for messageItem in messageList:
await message.channel.send(messageItem) await message.channel.send(messageItem)
except:
logThis("Something fucked up (error code 930)")
await message.channel.send("Something fucked up (error code 930)")
# Accesses and changes character sheet data with the parseChar function # Accesses and changes character sheet data with the parseChar function
# from funcs/swfuncs/swchar.py # from funcs/swfuncs/swchar.py
elif content.startswith("swchar") or content.startswith("sw"): elif content.startswith("swchar") or content.startswith("sw"):
try:
command = string.capwords(content.replace("swchar","").replace("sw","").replace("+","+ ").replace("-","- ").replace(",",", ")) command = string.capwords(content.replace("swchar","").replace("sw","").replace("+","+ ").replace("-","- ").replace(",",", "))
title, desc = parseChar(message.author.display_name,command) title, desc = parseChar(message.author.display_name,command)
if title != "": if title != "":
@ -201,10 +267,14 @@ async def parseCommands(message,content):
await message.channel.send(embed = em1) await message.channel.send(embed = em1)
else: else:
await message.channel.send(desc) await message.channel.send(desc)
except:
logThis("Something fucked up (error code 940)")
await message.channel.send("Something fucked up (error code 940)")
# Searches for a specific page on the Senkulpa Wiki # Searches for a specific page on the Senkulpa Wiki
elif content.startswith("wiki "): elif content.startswith("wiki "):
try:
async with message.channel.typing(): async with message.channel.typing():
command = string.capwords(content.replace("wiki ","")) command = string.capwords(content.replace("wiki ",""))
title, content, thumbnail = findWikiPage(command) title, content, thumbnail = findWikiPage(command)
@ -218,10 +288,14 @@ async def parseCommands(message,content):
await message.channel.send(embed = embed) await message.channel.send(embed = embed)
else: else:
await message.channel.send(content) await message.channel.send(content)
except:
logThis("Something fucked up (error code 1000)")
await message.channel.send("Something fucked up (error code 1000)")
# Runs a trivia game # Runs a trivia game
elif content.startswith("trivia"): elif content.startswith("trivia"):
try:
if content == "trivia" or content == "trivia ": if content == "trivia" or content == "trivia ":
question, answers, correctAnswer = triviaStart(str(message.channel)) question, answers, correctAnswer = triviaStart(str(message.channel))
if answers != "": if answers != "":
@ -255,33 +329,45 @@ async def parseCommands(message,content):
else: else:
await message.channel.send(response) await message.channel.send(response)
else: else:
logThis("I didn't understand that") logThis("I didn't understand that (error code 1101)")
await message.channel.send("I didn't understand that") await message.channel.send("I didn't understand that (error code 1101)")
except:
logThis("Something fucked up (error code 1100)")
await message.channel.send("Something fucked up (error code 1100)")
# Checks your GwendoBucks balance # Checks your GwendoBucks balance
elif content.startswith("balance"): elif content.startswith("balance"):
try:
response = checkBalance(message.author.display_name.lower()) response = checkBalance(message.author.display_name.lower())
if response == 1: if response == 1:
new_message = message.author.display_name + " has " + str(response) + " GwendoBuck" new_message = message.author.display_name + " has " + str(response) + " GwendoBuck"
else: else:
new_message = message.author.display_name + " has " + str(response) + " GwendoBucks" new_message = message.author.display_name + " has " + str(response) + " GwendoBucks"
await message.channel.send(new_message) await message.channel.send(new_message)
except:
logThis("Something fucked up (error code 1210)")
await message.channel.send("Something fucked up (error code 1210)")
# Gives money to other player # Gives money to other player
elif content.startswith("give "): elif content.startswith("give "):
try:
commands = content.split(" ") commands = content.split(" ")
if len(commands) >= 3: if len(commands) >= 3:
try: try:
amount = int(commands[2]) amount = int(commands[2])
except:
logThis("Conversion error (error code 1221)")
await message.channel.send("I didn't quite understand that (error code 1221)")
else:
response = giveMoney(message.author.display_name.lower(),commands[1],amount) response = giveMoney(message.author.display_name.lower(),commands[1],amount)
await message.channel.send(response) await message.channel.send(response)
except:
logThis("I didn't quite understand that")
await message.channel.send("I didn't quite understand that")
else: else:
logThis("I didn't understand that") logThis("I didn't understand that (error code 1222)")
await message.channel.send("I didn't understand that") await message.channel.send("I didn't understand that (error code 1222)")
except:
logThis("Something fucked up (error code 1220)")
await message.channel.send("Something fucked up (error code 1220)")
# Runs a game of Blackjack # Runs a game of Blackjack
elif content.startswith("blackjack"): elif content.startswith("blackjack"):
@ -400,6 +486,11 @@ async def parseCommands(message,content):
if showImage: if showImage:
await message.channel.send(file = discord.File("resources/games/4InARowBoards/board"+str(message.channel)+".png")) await message.channel.send(file = discord.File("resources/games/4InARowBoards/board"+str(message.channel)+".png"))
# Not a command
else:
logThis("That's not a command (error code 001)")
await message.channel.send("That's not a command (error code 001)")
# Makes files if they don't exist yet # Makes files if they don't exist yet
makeFiles() makeFiles()
@ -422,10 +513,14 @@ async def on_ready():
# Reads messages and tests if they are Gwendolyn commands # Reads messages and tests if they are Gwendolyn commands
@client.event @client.event
async def on_message(message): async def on_message(message):
try:
content = message.content content = message.content
if content.startswith(commandPrefix): if content.startswith(commandPrefix):
logThis(message.author.display_name+" ran \""+content+"\"") logThis(message.author.display_name+" ran \""+content+"\"")
await parseCommands(message,content.lower()[1:]) await parseCommands(message,content.lower()[1:])
except:
logThis("Something fucked up (error code 000)")
await message.channel.send("Something fucked up (error code 000)")
# Is a bit sassy sometimes # Is a bit sassy sometimes
if ("gwendolyn" in message.content.lower() or message.content.startswith(commandPrefix)) and any(x in message.content.lower() for x in meanWords) and "ikke" not in message.content.lower() and "not" not in message.content.lower(): if ("gwendolyn" in message.content.lower() or message.content.startswith(commandPrefix)) and any(x in message.content.lower() for x in meanWords) and "ikke" not in message.content.lower() and "not" not in message.content.lower():

View File

@ -40,8 +40,8 @@ def giveMoney(user,targetUser,amount):
addMoney(targetUser,amount) addMoney(targetUser,amount)
return "Transferred "+str(amount)+" GwendoBucks to "+user return "Transferred "+str(amount)+" GwendoBucks to "+user
else: else:
logThis("They didn't have enough GwendoBucks") logThis("They didn't have enough GwendoBucks (error code 1223b)")
return "You don't have that many GwendoBucks" return "You don't have that many GwendoBucks (error code 1223b)"
else: else:
logThis("They didn't have enough GwendoBucks") logThis("They didn't have enough GwendoBucks (error code 1223a)")
return "You don't have that many GwendoBucks" return "You don't have that many GwendoBucks (error code 1223a)"

View File

@ -43,8 +43,8 @@ def triviaStart(channel : str):
return question, answers, correctAnswer return question, answers, correctAnswer
else: else:
logThis("There was already a trivia question for that channel") logThis("There was already a trivia question for that channel (error code 1106)")
return "There's already a trivia question going on. Try again in like, a minute", "", "" return "There's already a trivia question going on. Try again in like, a minute (error code 1106)", "", ""
# Lets players answer a trivia question # Lets players answer a trivia question
def triviaAnswer(user : str, channel : str, command : str): def triviaAnswer(user : str, channel : str, command : str):
@ -63,11 +63,14 @@ def triviaAnswer(user : str, channel : str, command : str):
return "Locked in "+user+"'s answer" return "Locked in "+user+"'s answer"
else: else:
return user+" has already answered this question" logThis(user+" has already answered this question (error code 1105)")
return user+" has already answered this question (error code 1105)"
else: else:
return "There's no question right now" logThis("There's no question right now (error code 1104)")
return "There's no question right now (error code 1104)"
else: else:
return "I didn't quite understand that" logThis("I didn't quite understand that (error code 1103)")
return "I didn't quite understand that (error code 1103)"
# Adds 1 GwendoBuck to each player that got the question right and deletes question from games.json. # Adds 1 GwendoBuck to each player that got the question right and deletes question from games.json.
@ -84,6 +87,6 @@ def triviaCountPoints(channel : str):
else: else:
logThis("Couldn't find the question") logThis("Couldn't find the question (error code 1102)")
return None return None

View File

@ -20,8 +20,8 @@ def monsterFunc(command):
# 1-letter monsters don't exist # 1-letter monsters don't exist
if len(command) < 2: if len(command) < 2:
logThis("Monster doesn't exist in database") logThis("Monster name too short (error code 601)")
return("I don't know that monster...","","","","","") return("I don't know that monster... (error code 601)","","","","","")
else: else:
# Opens "mensters.json" # Opens "mensters.json"
data = json.load(open('resources/monsters.json', encoding = "utf8")) data = json.load(open('resources/monsters.json', encoding = "utf8"))
@ -117,8 +117,8 @@ def monsterFunc(command):
logThis("Returning monster information") logThis("Returning monster information")
return(str(command),text1,text2,text3,text4,text5) return(str(command),text1,text2,text3,text4,text5)
logThis("Couldn't find monster") logThis("Monster not in database (error code 602)")
return("I don't know that monster...","","","","","") return("I don't know that monster... (error code 602)","","","","","")
# Looks up a spell # Looks up a spell
def spellFunc(command): def spellFunc(command):
@ -130,7 +130,7 @@ def spellFunc(command):
logThis("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"])) 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: else:
logThis("I don't know that spell") logThis("I don't know that spell (error code 501)")
spell_output = "I don't think that's a spell" spell_output = "I don't think that's a spell (error code 501)"
logThis("Successfully ran !spell") logThis("Successfully ran !spell")
return(spell_output) return(spell_output)

View File

@ -81,6 +81,7 @@ def imageFunc():
logThis("Searching for "+search) logThis("Searching for "+search)
# Searches for the image and reads the resulting web page # Searches for the image and reads the resulting web page
try:
page = urllib.request.urlopen("https://www.bing.com/images/search?q="+search+"&safesearch=off") page = urllib.request.urlopen("https://www.bing.com/images/search?q="+search+"&safesearch=off")
read = page.read() read = page.read()
tree = lxml.etree.HTML(read) tree = lxml.etree.HTML(read)
@ -94,6 +95,9 @@ def imageFunc():
# Returns the image # Returns the image
logThis("Successfully returned an image") logThis("Successfully returned an image")
except:
image = "Couldn't connect to bing (error code 701)"
logThis("Couldn't connect to bing (error code 701)")
return(image) return(image)
def logThis(message : str): def logThis(message : str):
@ -120,11 +124,11 @@ def findWikiPage(search : str):
else: else:
return page.title, content, "" return page.title, content, ""
except: except:
logThis("Fucked up") logThis("Fucked up (error code 1001)")
return "", "Sorry. Fucked that one up", "" return "", "Sorry. Fucked that one up (error code 1001)", ""
else: else:
logThis("Couldn't find the page") logThis("Couldn't find the page (error code 1002)")
return "", "Couldn't find page", "" return "", "Couldn't find page (error code 1002)", ""
def makeFiles(): def makeFiles():
# Creates swcharacters.json if it doesn't exist # Creates swcharacters.json if it doesn't exist

View File

@ -9,15 +9,24 @@ def movieFunc():
logThis("Creating IMDb object") logThis("Creating IMDb object")
ia = imdb.IMDb() ia = imdb.IMDb()
try:
logThis("Picking a movie") logThis("Picking a movie")
movs = open("resources/movies.txt", "r") movs = open("resources/movies.txt", "r")
movlist = movs.read().split("\n") movlist = movs.read().split("\n")
mov = random.choice(movlist) mov = random.choice(movlist)
movs.close() movs.close()
except:
logThis("Problem picking the movie (error code 801)")
return("error","801","","")
try:
logThis("Searching for "+mov) logThis("Searching for "+mov)
s_result = ia.search_movie(mov) s_result = ia.search_movie(mov)
except:
logThis("Couldn't find on imdb (error code 802)")
return("error","802","","")
try:
logThis("Getting the data") logThis("Getting the data")
movie = s_result[0] movie = s_result[0]
ia.update(movie) ia.update(movie)
@ -26,9 +35,12 @@ def movieFunc():
for x in range(3): for x in range(3):
if cast[x]: if cast[x]:
pcast += cast[x]['name']+", " pcast += cast[x]['name']+", "
except:
logThis("Couldn't extract data (error code 803)")
return("error","803","","")
logThis("Successfully ran !movie") logThis("Successfully ran !movie")
return(movie['title'], movie['plot'][0].split("::")[0], movie['cover url'].replace("150","600").replace("101","404"), pcast[:-2]) return(movie['title'], movie['plot'][0].split("::")[0], movie['cover url'].replace("150","600").replace("101","404"), pcast[:-2])
except: except:
logThis("Something bad happened...") logThis("Something bad happened... (error code 800)")
return("error","","","") return("error","800","","")

View File

@ -265,8 +265,8 @@ def charData(user : str,cmd : str):
logThis("Returning a list of weapons") logThis("Returning a list of weapons")
return ", ".join(list(data[user][key])) return ", ".join(list(data[user][key]))
else: else:
logThis("The character doesn't have any weapons. Which is probably for the best. Like, who just walks around with weapons?") logThis("The character doesn't have any weapons. Which is probably for the best. Like, who just walks around with weapons? (error code 941)")
return "There doesn't seem to be anything there..." return "There doesn't seem to be anything there... (error code 941)"
else: else:
return setUpDict(data[user][key]) return setUpDict(data[user][key])
elif cmd[0] == "+": elif cmd[0] == "+":
@ -276,8 +276,8 @@ def charData(user : str,cmd : str):
while cmd[0] == ' ': while cmd[0] == ' ':
cmd = cmd[1:] cmd = cmd[1:]
except: except:
logThis("Nope. That didn't happen") logThis("Nope. That didn't happen (error code 942)")
return "Can't do that" return "Can't do that (error code 942)"
if (key == "Talents" or key == "Force-powers") and "," in cmd: if (key == "Talents" or key == "Force-powers") and "," in cmd:
cmd = cmd.split(",") cmd = cmd.split(",")
@ -297,8 +297,8 @@ def charData(user : str,cmd : str):
try: try:
data[user][key][cmd[0]] = int(cmd[1]) data[user][key][cmd[0]] = int(cmd[1])
except: except:
logThis("Fucked that up") logThis("Fucked that up (error code 949)")
return "Wrong data type" return "Wrong data type (error code 949)"
with open("resources/swcharacters.json", "w") as f: with open("resources/swcharacters.json", "w") as f:
json.dump(data,f,indent = 4) json.dump(data,f,indent = 4)
return cmd[0]+" added to "+key+" for " + data[user]["Name"] return cmd[0]+" added to "+key+" for " + data[user]["Name"]
@ -315,8 +315,8 @@ def charData(user : str,cmd : str):
return cmd+" added to weapons for " + data[user]["Name"] return cmd+" added to weapons for " + data[user]["Name"]
else: else:
logThis("That's not happening") logThis("That's not happening (error code 947d)")
return "Can't add that" return "Can't add that (error code 947d)"
elif cmd[0] == "-": elif cmd[0] == "-":
logThis("Gonna subtract/remove something") logThis("Gonna subtract/remove something")
@ -325,8 +325,8 @@ def charData(user : str,cmd : str):
while cmd[0] == ' ': while cmd[0] == ' ':
cmd = cmd[1:] cmd = cmd[1:]
except: except:
logThis("AAAAAAAAAAAA") logThis("AAAAAAAAAAAA (error code 948)")
return "Can't do that" return "Can't do that (error code 948)"
if key == "Talents" or key == "Force-powers" or key == "Weapons" or key == "Obligations": if key == "Talents" or key == "Force-powers" or key == "Weapons" or key == "Obligations":
logThis("Trying to remove "+cmd+" from "+key) logThis("Trying to remove "+cmd+" from "+key)
@ -337,11 +337,11 @@ def charData(user : str,cmd : str):
logThis("I did that") logThis("I did that")
return cmd+" removed from "+key+" from "+data[user]["Name"] return cmd+" removed from "+key+" from "+data[user]["Name"]
else: else:
logThis("Welp. I fucked that up") logThis("Welp. I fucked that up (error code 946e)")
return "Can't remove that" return "Can't remove that (error code 946e)"
else: else:
logThis("Urgh!") logThis("Urgh! (error code 946d)")
return "Can't remove that" return "Can't remove that (error code 946d)"
else: else:
logThis("Looking up "+cmd+" in "+key) logThis("Looking up "+cmd+" in "+key)
@ -375,8 +375,8 @@ def charData(user : str,cmd : str):
while cmd[0] == ' ': while cmd[0] == ' ':
cmd = cmd[1:] cmd = cmd[1:]
except: except:
logThis("Error message") logThis("Error message (error code 948)")
return "Can't do that" return "Can't do that (error code 948)"
if type(data[user][key]) is int: if type(data[user][key]) is int:
try: try:
@ -387,8 +387,8 @@ def charData(user : str,cmd : str):
json.dump(data,f,indent = 4) json.dump(data,f,indent = 4)
return "Added " + cmd + " to " + data[user]["Name"] + "'s " + key return "Added " + cmd + " to " + data[user]["Name"] + "'s " + key
except: except:
logThis("BITCH SANDWICH") logThis("BITCH SANDWICH (error code 947c)")
return "Can't add that" return "Can't add that (error code 947c)"
elif type(data[user][key]) is list: elif type(data[user][key]) is list:
try: try:
logThis("Adding "+cmd+" to "+key) logThis("Adding "+cmd+" to "+key)
@ -397,11 +397,11 @@ def charData(user : str,cmd : str):
json.dump(data,f,indent = 4) json.dump(data,f,indent = 4)
return "Added " + cmd + " to " + data[user]["Name"] + "'s " + key return "Added " + cmd + " to " + data[user]["Name"] + "'s " + key
except: except:
logThis("tstststststs") logThis("tstststststs (error code 947b)")
return "Can't add that" return "Can't add that (error code 947b)"
else: else:
logThis("Help") logThis("Help (error code 947a)")
return "Can't add that" return "Can't add that (error code 947a)"
elif cmd[0] == '-': elif cmd[0] == '-':
logThis("Removing/subtracting") logThis("Removing/subtracting")
try: try:
@ -409,8 +409,8 @@ def charData(user : str,cmd : str):
while cmd[0] == ' ': while cmd[0] == ' ':
cmd = cmd[1:] cmd = cmd[1:]
except: except:
logThis("lalalala") logThis("lalalala (error code 948)")
return "Can't do that" return "Can't do that (error code 948)"
if type(data[user][key]) is int: if type(data[user][key]) is int:
try: try:
@ -421,8 +421,8 @@ def charData(user : str,cmd : str):
json.dump(data,f,indent = 4) json.dump(data,f,indent = 4)
return "Subtracted " + cmd + " from " + data[user]["Name"] + "'s " + key return "Subtracted " + cmd + " from " + data[user]["Name"] + "'s " + key
except: except:
logThis("Tried it. Didn't want to") logThis("Tried it. Didn't want to (error code 946c)")
return "Can't remove that" return "Can't remove that (error code 946c)"
elif type(data[user][key]) is list: elif type(data[user][key]) is list:
try: try:
logThis("removing "+cmd+" from "+key) logThis("removing "+cmd+" from "+key)
@ -431,38 +431,39 @@ def charData(user : str,cmd : str):
data[user][key].remove(cmd) data[user][key].remove(cmd)
except: except:
logThis("They can only remove stuff that's actually in the list") logThis("They can only remove stuff that's actually in the list")
return "Not in list" return "Not in list (error code 944b)"
with open("resources/swcharacters.json", "w") as f: with open("resources/swcharacters.json", "w") as f:
json.dump(data,f,indent = 4) json.dump(data,f,indent = 4)
return "Removed " + cmd + " from " + data[user]["Name"] + "'s " + key return "Removed " + cmd + " from " + data[user]["Name"] + "'s " + key
except: except:
logThis("nah") logThis("nah (error code 946b)")
return "Can't remove that" return "Can't remove that (error code 946b)"
else: else:
logThis("nyope") logThis("nyope (error code 946a)")
return "Can't remove that" return "Can't remove that (error code 946a)"
else: else:
logThis("Changing "+key+" to "+cmd) logThis("Changing "+key+" to "+cmd)
if type(data[user][key]) is int: if type(data[user][key]) is int:
try: try:
data[user][key] = int(cmd) data[user][key] = int(cmd)
except: except:
return "Can't do that" logThis("I don't wanna tho (error code 945b)")
return "Can't do that (error code 945b)"
elif type(data[user][key]) is str: elif type(data[user][key]) is str:
data[user][key] = cmd data[user][key] = cmd
else: else:
logThis("I don't wanna tho") logThis("I don't wanna tho (error code 945a)")
return "Can't do that" return "Can't do that (error code 945a)"
with open("resources/swcharacters.json", "w") as f: with open("resources/swcharacters.json", "w") as f:
json.dump(data,f,indent = 4) json.dump(data,f,indent = 4)
return "Changed " + data[user]["Name"] + "'s " + key +" to " + cmd return "Changed " + data[user]["Name"] + "'s " + key +" to " + cmd
else: else:
logThis(key+" isn't in there") logThis(key+" isn't in there (error code 944)")
return "Couldn't find that data. Are you sure you spelled it correctly?" return "Couldn't find that data. Are you sure you spelled it correctly? (error code 944)"
else: else:
logThis(user+" doesn't have a character") logThis(user+" doesn't have a character (error code 943)")
return "You don't have a character. You can make one with !swchar" return "You don't have a character. You can make one with !swchar (error code 943)"
def replaceSpaces(cmd : str): def replaceSpaces(cmd : str):
withSpaces = ["Specialization Trees","Wound Threshold","Strain Threshold","Defense - Ranged","Defense - Melee","Force Rating","Core Worlds","Outer Rim","Piloting - Planetary","Piloting - Space","Ranged - Heavy","Ranged - Light","Lightsaber Characteristic","Critical Injuries","Force Powers"] withSpaces = ["Specialization Trees","Wound Threshold","Strain Threshold","Defense - Ranged","Defense - Melee","Force Rating","Core Worlds","Outer Rim","Piloting - Planetary","Piloting - Space","Ranged - Heavy","Ranged - Light","Lightsaber Characteristic","Critical Injuries","Force Powers"]

View File

@ -59,8 +59,8 @@ def parseDestiny(user : str, cmd : str):
if len(commands) > 1: if len(commands) > 1:
return destinyNew(int(commands[1])) return destinyNew(int(commands[1]))
else: else:
return "You need to give an amount of players" return "You need to give an amount of players (error code 921)"
elif commands[0] == "U": elif commands[0] == "U":
return destinyUse(user) return destinyUse(user)
else: else:
return "I didn't quite understand that" return "I didn't quite understand that (error code 922)"

View File

@ -304,7 +304,11 @@ def parseRoll(user : str,cmd : str = ""):
rollParameters = [0,0,0,0,0,0,0] rollParameters = [0,0,0,0,0,0,0]
if string.capwords(commands[0]) == "Obligations": if string.capwords(commands[0]) == "Obligations":
try:
return obligationRoll() return obligationRoll()
except:
logThis("Obligation fucked up (error code 911)")
return "An error occured (error code 911)"
elif string.capwords(commands[0]) in skillData: elif string.capwords(commands[0]) in skillData:
logThis("Oh look! This guy has skills!") logThis("Oh look! This guy has skills!")
@ -324,15 +328,15 @@ def parseRoll(user : str,cmd : str = ""):
commands = [str(abilityDice)] + [str(proficiencyDice)] + commands[1:] commands = [str(abilityDice)] + [str(proficiencyDice)] + commands[1:]
logThis("Converted skill to dice") logThis("Converted skill to dice")
else: else:
logThis("Okay, no they don't i guess") logThis("Okay, no they don't i guess (error code 912)")
return "You don't have a user. You can make one with !swchar" return "You don't have a user. You can make one with !swchar (error code 912)"
elif string.capwords(commands[0]) in ["Ranged","Piloting"]: elif string.capwords(commands[0]) in ["Ranged","Piloting"]:
logThis("They fucked up writing the name of a ranged or piloting skill") logThis("They fucked up writing the name of a ranged or piloting skill")
if string.capwords(commands[0]) == "Ranged": if string.capwords(commands[0]) == "Ranged":
return "Did you mean \"Ranged - Heavy\" or \"Ranged - Light\"" return "Did you mean \"Ranged - Heavy\" or \"Ranged - Light\" (error code 913)"
else: else:
return "Did you mean \"Piloting - Planetary\" or \"Piloting - Space\"" return "Did you mean \"Piloting - Planetary\" or \"Piloting - Space\" (error code 913)"
try: try:
logThis("Converting commands to dice") logThis("Converting commands to dice")
@ -356,8 +360,8 @@ def parseRoll(user : str,cmd : str = ""):
else: else:
rollParameters[x] = int(commands[x]) rollParameters[x] = int(commands[x])
except: except:
logThis("Someone fucked u-up! (it was them)") logThis("Someone fucked u-up! (it was them) (error code 914)")
return "Invalid input!" return "Invalid input! (error code 914)"
logThis("Rolling "+str(rollParameters)) logThis("Rolling "+str(rollParameters))
rollResults, diceResults = roll(rollParameters[0],rollParameters[1],rollParameters[2],rollParameters[3],rollParameters[4],rollParameters[5],rollParameters[6]) rollResults, diceResults = roll(rollParameters[0],rollParameters[1],rollParameters[2],rollParameters[3],rollParameters[4],rollParameters[5],rollParameters[6])

90
resources/errorCodes.txt Normal file
View File

@ -0,0 +1,90 @@
000 - Unspecified error
001 - Not a command
1 - Help
100 - Unspecified error
101 - Couldn't find help.txt
102 - Couldn't find help file for specified command
2 - Stop
200 - Unspecified error
201 - Unauthorized user
3 - Simple Commands
310 - Hello error
320 - Map error
330 - Name error
340 - Tavern error
350 - Game error
4 - Roll
400 - Unspecified error
5 - Spell
500 - Unspecified error
501 - Spell not in database
6 - Monster
600 - Unspecified error
601 - Monster name too short
602 - Monster not in database
7 - Image
700 - Unspecified error
701 - Can't connect to Bing
8 - Movie
800 - Unspecified error
801 - Can't pick movie
802 - Can't find movie on imdb
803 - Can't extract data
9 - Star Wars
910 - Unspecified swroll error
911 - Obligation roll fucked up
912 - No character swroll
913 - Didn't include heavy/light in ranged or planetary/space in piloting
914 - Swroll invalid input
920 - Unspecified swd error
921 - Didn't specify amount of players
922 - Invalid input
930 - Unspecified swcrit
931 - Swcrit didn't include a number
940 - Unspecified swchar error
941 - No weapons
942 - Can't add to character sheet
943 - No character swchar
944 - Not on character sheet
945 - Problem overwriting data
946 - Problem removing data
947 - Problem adding data
948 - Problem removing spaces
949 - Wrong data type
10 - Wiki
1000 - Unspecified error
1001 - Something fucked up
1002 - Can't find page
11 - Trivia
1100 - Unspecified error
1101 - Incorrect input
1102 - Can't find question
1103 - Not an answer
1104 - No question going on
1105 - User has already answered
1106 - There's already a question goin on in the channel
12 - Money
1210 - Unspecified balance error
1220 - Unspecified give error
1221 - Conversion error
1222 - Incorrect input
1223a - User has no money
1223b - Not enough money
13 - Blackjack
1300 - Unspecified
14 - Four in a row
600 - Unspecified