📄 Logging

This commit is contained in:
NikolajDanger
2020-07-30 11:02:36 +02:00
parent 8e6a6e0b55
commit c6a7f35602
2 changed files with 60 additions and 55 deletions

View File

@@ -22,14 +22,14 @@ meanWords = ["stupid", "bitch", "fuck", "dumb", "idiot"]
# Loop of game rounds # Loop of game rounds
async def blackjackLoop(channel,gameRound,gameID): async def blackjackLoop(channel,gameRound,gameID):
logThis("Loop "+str(gameRound)) logThis("Loop "+str(gameRound),str(channel))
with open("resources/games/oldImages/blackjack"+str(channel), "r") as f: with open("resources/games/oldImages/blackjack"+str(channel), "r") as f:
oldImage = await channel.fetch_message(int(f.read())) oldImage = await channel.fetch_message(int(f.read()))
new_message, allStanding, gamedone = blackjackContinue(str(channel)) new_message, allStanding, gamedone = blackjackContinue(str(channel))
if new_message != "": if new_message != "":
logThis(new_message) logThis(new_message,str(channel))
await channel.send(new_message) await channel.send(new_message)
if gamedone == False: if gamedone == False:
await oldImage.delete() await oldImage.delete()
@@ -50,15 +50,15 @@ async def blackjackLoop(channel,gameRound,gameID):
if gameRound == realRound and realGameID == gameID: if gameRound == realRound and realGameID == gameID:
if gamedone == False: if gamedone == False:
logThis("Loop "+str(gameRound)+" calling blackjackLoop()") logThis("Loop "+str(gameRound)+" calling blackjackLoop()",str(channel))
await blackjackLoop(channel,gameRound+1,gameID) await blackjackLoop(channel,gameRound+1,gameID)
else: else:
new_message = blackjackFinish(str(channel)) new_message = blackjackFinish(str(channel))
await channel.send(new_message) await channel.send(new_message)
else: else:
logThis("Ending loop on round "+str(gameRound)) logThis("Ending loop on round "+str(gameRound),str(channel))
else: else:
logThis("Ending loop on round "+str(gameRound)) logThis("Ending loop on round "+str(gameRound),str(channel))
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.
@@ -71,26 +71,26 @@ async def parseCommands(message,content):
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: except:
logThis("Couldn't find help.txt (error code 101)") logThis("Couldn't find help.txt (error code 101)",str(message.channel))
await message.channel.send("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",str(message.channel))
try: try:
with codecs.open("resources/help/"+command+".txt",encoding="utf-8") as f: with codecs.open("resources/help/"+command+".txt",encoding="utf-8") as f:
text = f.read() text = f.read()
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:
logThis("Couldn't find help for that command (error code 102)") logThis("Couldn't find help for that command (error code 102)",str(message.channel))
await message.channel.send("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: except:
logThis("Something fucked up (error code 100)") logThis("Something fucked up (error code 100)",str(message.channel))
await message.channel.send("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 "):
logThis(content.replace("log ","")) logThis(content.replace("log ",""),str(message.channel))
# Stops the bot # Stops the bot
elif content.startswith("stop"): elif content.startswith("stop"):
@@ -110,10 +110,10 @@ async def parseCommands(message,content):
await client.logout() await client.logout()
else: else:
logThis(message.author.display_name+" tried to run stop me! (error code 201)") logThis(message.author.display_name+" tried to run stop me! (error code 201)",str(message.channel))
await message.channel.send("I don't think I will, "+message.author.display_name+" (error code 201)") await message.channel.send("I don't think I will, "+message.author.display_name+" (error code 201)")
except: except:
logThis("Something fucked up (error code 200)") logThis("Something fucked up (error code 200)",str(message.channel))
await message.channel.send("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
@@ -121,7 +121,7 @@ async def parseCommands(message,content):
try: try:
await message.channel.send(helloFunc(message.author.display_name)) await message.channel.send(helloFunc(message.author.display_name))
except: except:
logThis("Something fucked up (error code 310)") logThis("Something fucked up (error code 310)",str(message.channel))
await message.channel.send("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
@@ -132,7 +132,7 @@ async def parseCommands(message,content):
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: except:
logThis("Something fucked up (error code 400)") logThis("Something fucked up (error code 400)",str(message.channel))
await message.channel.send("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
@@ -140,7 +140,7 @@ async def parseCommands(message,content):
try: try:
await message.channel.send(spellFunc(cap(content.replace("spell","")))) await message.channel.send(spellFunc(cap(content.replace("spell",""))))
except: except:
logThis("Something fucked up (error code 500)") logThis("Something fucked up (error code 500)",str(message.channel))
await message.channel.send("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
@@ -189,7 +189,7 @@ async def parseCommands(message,content):
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: except:
logThis("Something fucked up (error code 600)") logThis("Something fucked up (error code 600)",str(message.channel))
await message.channel.send("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
@@ -197,7 +197,7 @@ async def parseCommands(message,content):
try: try:
await message.channel.send("https://i.imgur.com/diMXXJs.jpg") await message.channel.send("https://i.imgur.com/diMXXJs.jpg")
except: except:
logThis("Something fucked up (error code 320)") logThis("Something fucked up (error code 320)",str(message.channel))
await message.channel.send("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
@@ -206,7 +206,7 @@ async def parseCommands(message,content):
try: try:
await message.channel.send(imageFunc()) await message.channel.send(imageFunc())
except: except:
logThis("Something fucked up (error code 700)") logThis("Something fucked up (error code 700)",str(message.channel))
await message.channel.send("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
@@ -223,7 +223,7 @@ async def parseCommands(message,content):
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: except:
logThis("Something fucked up (error code 800)") logThis("Something fucked up (error code 800)",str(message.channel))
await message.channel.send("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
@@ -231,7 +231,7 @@ async def parseCommands(message,content):
try: try:
await message.channel.send(nameGen()) await message.channel.send(nameGen())
except: except:
logThis("Something fucked up (error code 330)") logThis("Something fucked up (error code 330)",str(message.channel))
await message.channel.send("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
@@ -239,7 +239,7 @@ async def parseCommands(message,content):
try: try:
await message.channel.send(tavernGen()) await message.channel.send(tavernGen())
except: except:
logThis("Something fucked up (error code 340)") logThis("Something fucked up (error code 340)",str(message.channel))
await message.channel.send("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
@@ -249,7 +249,7 @@ async def parseCommands(message,content):
game = discord.Game(gamePlaying) game = discord.Game(gamePlaying)
await client.change_presence(activity=game) await client.change_presence(activity=game)
except: except:
logThis("Something fucked up (error code 350)") logThis("Something fucked up (error code 350)",str(message.channel))
await message.channel.send("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
@@ -261,7 +261,7 @@ async def parseCommands(message,content):
for messageItem in messageList: for messageItem in messageList:
await message.channel.send(messageItem) await message.channel.send(messageItem)
except: except:
logThis("Something fucked up (error code 910)") logThis("Something fucked up (error code 910)",str(message.channel))
await message.channel.send("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
@@ -273,7 +273,7 @@ async def parseCommands(message,content):
for messageItem in messageList: for messageItem in messageList:
await message.channel.send(messageItem) await message.channel.send(messageItem)
except: except:
logThis("Something fucked up (error code 920)") logThis("Something fucked up (error code 920)",str(message.channel))
await message.channel.send("Something fucked up (error code 920)") await message.channel.send("Something fucked up (error code 920)")
# Rolls for critical injuries # Rolls for critical injuries
@@ -287,14 +287,14 @@ async def parseCommands(message,content):
try: try:
newMessage = critRoll(int(command)) newMessage = critRoll(int(command))
except: except:
logThis("They didn't include a number (error code 931)") logThis("They didn't include a number (error code 931)",str(message.channel))
newMessage = "Try using a number, stupid (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: except:
logThis("Something fucked up (error code 930)") logThis("Something fucked up (error code 930)",str(message.channel))
await message.channel.send("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
@@ -309,7 +309,7 @@ async def parseCommands(message,content):
else: else:
await message.channel.send(desc) await message.channel.send(desc)
except: except:
logThis("Something fucked up (error code 940)") logThis("Something fucked up (error code 940)",str(message.channel))
await message.channel.send("Something fucked up (error code 940)") await message.channel.send("Something fucked up (error code 940)")
@@ -320,7 +320,7 @@ async def parseCommands(message,content):
command = string.capwords(content.replace("wiki ","")) command = string.capwords(content.replace("wiki ",""))
title, content, thumbnail = findWikiPage(command) title, content, thumbnail = findWikiPage(command)
if title != "": if title != "":
logThis("Sending the embedded message") logThis("Sending the embedded message",str(message.channel))
content += "\n[Læs mere](https://senkulpa.fandom.com/da/wiki/"+title.replace(" ","_")+")" content += "\n[Læs mere](https://senkulpa.fandom.com/da/wiki/"+title.replace(" ","_")+")"
embed = discord.Embed(title = title, description = content, colour=0xDEADBF) embed = discord.Embed(title = title, description = content, colour=0xDEADBF)
if thumbnail != "": if thumbnail != "":
@@ -330,7 +330,7 @@ async def parseCommands(message,content):
else: else:
await message.channel.send(content) await message.channel.send(content)
except: except:
logThis("Something fucked up (error code 1000)") logThis("Something fucked up (error code 1000)",str(message.channel))
await message.channel.send("Something fucked up (error code 1000)") await message.channel.send("Something fucked up (error code 1000)")
@@ -357,7 +357,7 @@ async def parseCommands(message,content):
with open("resources/games/games.json", "w") as f: with open("resources/games/games.json", "w") as f:
json.dump(data,f,indent=4) json.dump(data,f,indent=4)
logThis("Time's up for the trivia question in "+str(message.channel)) logThis("Time's up for the trivia question",str(message.channel))
await message.channel.send("Time's up The answer was \""+chr(correctAnswer)+") "+answers[correctAnswer-97]+"\". Anyone who answered that has gotten 1 GwendoBuck") await message.channel.send("Time's up The answer was \""+chr(correctAnswer)+") "+answers[correctAnswer-97]+"\". Anyone who answered that has gotten 1 GwendoBuck")
else: else:
await message.channel.send(question) await message.channel.send(question)
@@ -370,10 +370,10 @@ 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 (error code 1101)") logThis("I didn't understand that (error code 1101)",str(message.channel))
await message.channel.send("I didn't understand that (error code 1101)") await message.channel.send("I didn't understand that (error code 1101)")
except: except:
logThis("Something fucked up (error code 1100)") logThis("Something fucked up (error code 1100)",str(message.channel))
await message.channel.send("Something fucked up (error code 1100)") await message.channel.send("Something fucked up (error code 1100)")
@@ -387,7 +387,7 @@ async def parseCommands(message,content):
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: except:
logThis("Something fucked up (error code 1210)") logThis("Something fucked up (error code 1210)",str(message.channel))
await message.channel.send("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
@@ -398,16 +398,16 @@ async def parseCommands(message,content):
try: try:
amount = int(commands[2]) amount = int(commands[2])
except: except:
logThis("Conversion error (error code 1221)") logThis("Conversion error (error code 1221)",str(message.channel))
await message.channel.send("I didn't quite understand that (error code 1221)") await message.channel.send("I didn't quite understand that (error code 1221)")
else: 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)
else: else:
logThis("I didn't understand that (error code 1222)") logThis("I didn't understand that (error code 1222)",str(message.channel))
await message.channel.send("I didn't understand that (error code 1222)") await message.channel.send("I didn't understand that (error code 1222)")
except: except:
logThis("Something fucked up (error code 1220)") logThis("Something fucked up (error code 1220)",str(message.channel))
await message.channel.send("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
@@ -424,7 +424,7 @@ async def parseCommands(message,content):
# Shuffles if not enough cards # Shuffles if not enough cards
if cardsLeft < blackjackMinCards: if cardsLeft < blackjackMinCards:
blackjackShuffle(blackjackDecks) blackjackShuffle(blackjackDecks)
logThis("Shuffling the blackjack deck...") logThis("Shuffling the blackjack deck...",str(message.channel))
await message.channel.send("Shuffling the deck...") await message.channel.send("Shuffling the deck...")
new_message = "Blackjack game started. Use \""+commandPrefix+"blackjack bet [amount]\" to enter the game within the next 30 seconds." new_message = "Blackjack game started. Use \""+commandPrefix+"blackjack bet [amount]\" to enter the game within the next 30 seconds."
@@ -447,7 +447,7 @@ async def parseCommands(message,content):
# Loop of game rounds # Loop of game rounds
if gamedone == False: if gamedone == False:
logThis("!blackjack calling blackjackLoop()") logThis("!blackjack calling blackjackLoop()",str(message.channel))
await blackjackLoop(message.channel,1,gameID) await blackjackLoop(message.channel,1,gameID)
else: else:
new_message = blackjackFinish(str(message.channel)) new_message = blackjackFinish(str(message.channel))
@@ -461,7 +461,7 @@ async def parseCommands(message,content):
try: try:
amount = int(commands[2]) amount = int(commands[2])
except: except:
logThis("I didn't understand that") logThis("I didn't understand that",str(message.channel))
response = "I didn't understand that" response = "I didn't understand that"
else: else:
response = blackjackPlayerDrawHand(str(message.channel),message.author.display_name,amount) response = blackjackPlayerDrawHand(str(message.channel),message.author.display_name,amount)
@@ -485,11 +485,11 @@ async def parseCommands(message,content):
if response[6] == "T": if response[6] == "T":
with open("resources/games/games.json", "r") as f: with open("resources/games/games.json", "r") as f:
gameID = json.load(f)["blackjack games"][str(message.channel)]["id"] gameID = json.load(f)["blackjack games"][str(message.channel)]["id"]
logThis("Hit calling blackjackLoop()") logThis("Hit calling blackjackLoop()",str(message.channel))
await blackjackLoop(message.channel,int(response[7:])+1,gameID) await blackjackLoop(message.channel,int(response[7:])+1,gameID)
except: except:
logThis("Something fucked up") logThis("Something fucked up")
await message.channel.send("something fucked up") await message.channel.send("something fucked up",str(message.channel))
else: else:
await message.channel.send(response) await message.channel.send(response)
@@ -504,10 +504,10 @@ async def parseCommands(message,content):
if response[6] == "T": if response[6] == "T":
with open("resources/games/games.json", "r") as f: with open("resources/games/games.json", "r") as f:
gameID = json.load(f)["blackjack games"][str(message.channel)]["id"] gameID = json.load(f)["blackjack games"][str(message.channel)]["id"]
logThis("Stand calling blackjackLoop()") logThis("Stand calling blackjackLoop()",str(message.channel))
await blackjackLoop(message.channel,int(response[7:])+1,gameID) await blackjackLoop(message.channel,int(response[7:])+1,gameID)
except: except:
logThis("Something fucked up") logThis("Something fucked up",str(message.channel))
await message.channel.send("something fucked up") await message.channel.send("something fucked up")
else: else:
await message.channel.send(response) await message.channel.send(response)
@@ -527,10 +527,10 @@ async def parseCommands(message,content):
if roundDone[0] == "T": if roundDone[0] == "T":
with open("resources/games/games.json", "r") as f: with open("resources/games/games.json", "r") as f:
gameID = json.load(f)["blackjack games"][str(message.channel)]["id"] gameID = json.load(f)["blackjack games"][str(message.channel)]["id"]
logThis("Double calling blackjackLoop()") logThis("Double calling blackjackLoop()",str(message.channel))
await blackjackLoop(message.channel,int(roundDone[1:])+1,gameID) await blackjackLoop(message.channel,int(roundDone[1:])+1,gameID)
except: except:
logThis("Something fucked up") logThis("Something fucked up",str(message.channel))
await message.channel.send("something fucked up") await message.channel.send("something fucked up")
# Splitting hand # Splitting hand
@@ -543,7 +543,7 @@ async def parseCommands(message,content):
if roundDone[0] == "T": if roundDone[0] == "T":
with open("resources/games/games.json", "r") as f: with open("resources/games/games.json", "r") as f:
gameID = json.load(f)["blackjack games"][str(message.channel)]["id"] gameID = json.load(f)["blackjack games"][str(message.channel)]["id"]
logThis("Split calling blackjackLoop()") logThis("Split calling blackjackLoop()",str(message.channel))
await blackjackLoop(message.channel,int(roundDone[1:])+1,gameID) await blackjackLoop(message.channel,int(roundDone[1:])+1,gameID)
#except: #except:
# logThis("Something fucked up") # logThis("Something fucked up")
@@ -558,7 +558,7 @@ async def parseCommands(message,content):
# Shuffles the blackjack deck # Shuffles the blackjack deck
elif content.startswith("blackjack shuffle"): elif content.startswith("blackjack shuffle"):
blackjackShuffle(blackjackDecks) blackjackShuffle(blackjackDecks)
logThis("Shuffling the blackjack deck...") logThis("Shuffling the blackjack deck...",str(message.channel))
await message.channel.send("Shuffling the deck...") await message.channel.send("Shuffling the deck...")
elif content.startswith("blackjack cards"): elif content.startswith("blackjack cards"):
@@ -567,7 +567,7 @@ async def parseCommands(message,content):
for line in f: for line in f:
cardsLeft += 1 cardsLeft += 1
decksLeft = math.round(cardsLeft/52) decksLeft = round(cardsLeft/52,1)
await message.channel.send(str(cardsLeft)+" cards, "+str(decksLeft)+" decks") await message.channel.send(str(cardsLeft)+" cards, "+str(decksLeft)+" decks")
else: else:
@@ -577,13 +577,13 @@ async def parseCommands(message,content):
elif content.startswith("fourinarow"): elif content.startswith("fourinarow"):
response, showImage = parseFourInARow(content.replace("fourinarow",""),str(message.channel),message.author.display_name) response, showImage = parseFourInARow(content.replace("fourinarow",""),str(message.channel),message.author.display_name)
await message.channel.send(response) await message.channel.send(response)
logThis(response) logThis(response,str(message.channel))
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 # Not a command
else: else:
logThis("That's not a command (error code 001)") logThis("That's not a command (error code 001)",str(message.channel))
await message.channel.send("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
@@ -611,7 +611,7 @@ async def on_message(message):
#try: #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+"\"",str(message.channel))
await parseCommands(message,content.lower()[1:]) await parseCommands(message,content.lower()[1:])
#except: #except:
# logThis("Something fucked up (error code 000)") # logThis("Something fucked up (error code 000)")
@@ -619,7 +619,7 @@ async def on_message(message):
# 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():
logThis(message.author.display_name+" was a bit mean") logThis(message.author.display_name+" was a bit mean",str(message.channel))
emoji = random.choice(["😠", "🖕", "👎"]) emoji = random.choice(["😠", "🖕", "👎"])
await message.add_reaction(emoji) await message.add_reaction(emoji)

View File

@@ -100,10 +100,15 @@ def imageFunc():
logThis("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, channel = ""):
localtime = time.asctime(time.localtime(time.time())) localtime = time.asctime(time.localtime(time.time()))
print(localtime+" - "+message) channel = channel.replace("Direct message with ","")
logging.info(localtime+" - "+message) if channel == "":
print(localtime+" - "+message)
logging.info(localtime+" - "+message)
else:
print(localtime+" ("+channel+") - "+message)
logging.info(localtime+" ("+channel+") - "+message)
# Finds a page from the Senkulpa Wikia # Finds a page from the Senkulpa Wikia
def findWikiPage(search : str): def findWikiPage(search : str):