This commit is contained in:
NikolajDanger
2020-07-28 13:05:36 +02:00
parent fc7035ac7c
commit 0ec10dca23

View File

@@ -31,7 +31,7 @@ async def on_ready():
async def on_message(message): async def on_message(message):
# Sends the contents of "help.txt" # Sends the contents of "help.txt"
if message.content.lower().startswith("!help"): if message.content.lower().startswith("!help"):
funcs.logThis(message.author.name+" ran \""+message.content+"\"") funcs.logThis(message.author.display_name+" ran \""+message.content+"\"")
if message.content.lower() == "!help" or message.content.lower() == "!help ": if message.content.lower() == "!help" or message.content.lower() == "!help ":
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()
@@ -50,8 +50,8 @@ async def on_message(message):
# Stops the bot # Stops the bot
elif message.content.lower().startswith("!stop"): elif message.content.lower().startswith("!stop"):
if message.author.name == "Nikolaj": if message.author.display_name == "Nikolaj":
funcs.logThis(message.author.name+" ran \""+message.content+"\"") funcs.logThis(message.author.display_name+" ran \""+message.content+"\"")
await message.channel.send("Logging out...") await message.channel.send("Logging out...")
with open("resources/games/games.json","r") as f: with open("resources/games/games.json","r") as f:
@@ -65,30 +65,30 @@ async def on_message(message):
await client.logout() await client.logout()
else: else:
funcs.logThis(message.author.name+" tried to run "+message.content) funcs.logThis(message.author.display_name+" tried to run "+message.content)
await message.channel.send("I don't think I will, "+message.author.name) await message.channel.send("I don't think I will, "+message.author.display_name)
# Does a hello with the helloFunc function from funcs/gwendolynFuncs.py # Does a hello with the helloFunc function from funcs/gwendolynFuncs.py
elif message.content.lower().startswith("!hello"): elif message.content.lower().startswith("!hello"):
funcs.logThis(message.author.name+" ran \""+message.content+"\"") funcs.logThis(message.author.display_name+" ran \""+message.content+"\"")
await message.channel.send(funcs.helloFunc(message.author.name)) await message.channel.send(funcs.helloFunc(message.author.display_name))
# 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 message.content.lower().startswith("!roll"): elif message.content.lower().startswith("!roll"):
funcs.logThis(message.author.name+" ran \""+message.content+"\"") funcs.logThis(message.author.display_name+" ran \""+message.content+"\"")
if message.content.lower() == "!roll" or message.content.lower() == "!roll ": if message.content.lower() == "!roll" or message.content.lower() == "!roll ":
await message.channel.send(funcs.roll_dice(message.author.name)) await message.channel.send(funcs.roll_dice(message.author.display_name))
else: else:
await message.channel.send(funcs.roll_dice(message.author.name, message.content.lower().replace("!roll",""))) await message.channel.send(funcs.roll_dice(message.author.display_name, message.content.lower().replace("!roll","")))
# Looks up a spell with the spellFunc function from funcs/lookup/lookupFuncs.py # Looks up a spell with the spellFunc function from funcs/lookup/lookupFuncs.py
elif message.content.lower().startswith("!spell "): elif message.content.lower().startswith("!spell "):
funcs.logThis(message.author.name+" ran \""+message.content+"\"") funcs.logThis(message.author.display_name+" ran \""+message.content+"\"")
await message.channel.send(funcs.spellFunc(message.content)) await message.channel.send(funcs.spellFunc(message.content))
# Looks up a monster with the monsterFuncs() from funcs/lookup/lookupFuncs.py # Looks up a monster with the monsterFuncs() from funcs/lookup/lookupFuncs.py
elif message.content.lower().startswith("!monster "): elif message.content.lower().startswith("!monster "):
funcs.logThis(message.author.name+" ran \""+message.content+"\"") funcs.logThis(message.author.display_name+" ran \""+message.content+"\"")
title, text1, text2, text3, text4, text5 = funcs.monsterFunc(message.content) title, text1, text2, text3, text4, text5 = funcs.monsterFunc(message.content)
em1 = discord.Embed(title = title, description = text1, colour=0xDEADBF) em1 = discord.Embed(title = title, description = text1, colour=0xDEADBF)
@@ -134,19 +134,19 @@ async def on_message(message):
# Sends an image of the Senkulpa map # Sends an image of the Senkulpa map
elif message.content.lower().startswith("!map"): elif message.content.lower().startswith("!map"):
funcs.logThis(message.author.name+" ran \""+message.content+"\"") funcs.logThis(message.author.display_name+" ran \""+message.content+"\"")
await message.channel.send("https://i.imgur.com/diMXXJs.jpg") await message.channel.send("https://i.imgur.com/diMXXJs.jpg")
# 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/gwendolynFuncs.py # funcs/gwendolynFuncs.py
elif message.content.lower().startswith("!image"): elif message.content.lower().startswith("!image"):
funcs.logThis(message.author.name+" ran \""+message.content+"\"") funcs.logThis(message.author.display_name+" ran \""+message.content+"\"")
await message.channel.send(funcs.imageFunc()) await message.channel.send(funcs.imageFunc())
# 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 message.content.lower().startswith("!movie"): elif message.content.lower().startswith("!movie"):
funcs.logThis(message.author.name+" ran \""+message.content+"\"") funcs.logThis(message.author.display_name+" ran \""+message.content+"\"")
async with message.channel.typing(): async with message.channel.typing():
title, plot, cover, cast = funcs.movieFunc() title, plot, cover, cast = funcs.movieFunc()
if title == "error": if title == "error":
@@ -159,42 +159,42 @@ async def on_message(message):
# 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 message.content.lower().startswith("!name"): elif message.content.lower().startswith("!name"):
funcs.logThis(message.author.name+" ran \""+message.content+"\"") funcs.logThis(message.author.display_name+" ran \""+message.content+"\"")
await message.channel.send(funcs.nameGen()) await message.channel.send(funcs.nameGen())
# 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 message.content.lower().startswith("!tavern"): elif message.content.lower().startswith("!tavern"):
funcs.logThis(message.author.name+" ran \""+message.content+"\"") funcs.logThis(message.author.display_name+" ran \""+message.content+"\"")
await message.channel.send(funcs.tavernGen()) await message.channel.send(funcs.tavernGen())
# Changes the "Playing this game" thing in Discord # Changes the "Playing this game" thing in Discord
elif message.content.lower().startswith("!game "): elif message.content.lower().startswith("!game "):
funcs.logThis(message.author.name+" ran \""+message.content+"\"") funcs.logThis(message.author.display_name+" ran \""+message.content+"\"")
gamePlaying = funcs.cap(message.content.lower().replace("!game ","")) gamePlaying = funcs.cap(message.content.lower().replace("!game ",""))
game = discord.Game(gamePlaying) game = discord.Game(gamePlaying)
await client.change_presence(activity=game) await client.change_presence(activity=game)
# 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 message.content.lower().startswith("!swroll"): elif message.content.lower().startswith("!swroll"):
funcs.logThis(message.author.name+" ran \""+message.content+"\"") funcs.logThis(message.author.display_name+" ran \""+message.content+"\"")
command = funcs.cap(message.content.lower().replace("!swroll","")) command = funcs.cap(message.content.lower().replace("!swroll",""))
newMessage = funcs.parseRoll(message.author.name,command) newMessage = funcs.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)
# Deals with Destiny Points and stuff # Deals with Destiny Points and stuff
elif message.content.lower().startswith("!swd"): elif message.content.lower().startswith("!swd"):
funcs.logThis(message.author.name+" ran \""+message.content+"\"") funcs.logThis(message.author.display_name+" ran \""+message.content+"\"")
command = message.content.lower().replace("!swd","") command = message.content.lower().replace("!swd","")
newMessage = funcs.parseDestiny(message.author.name,command) newMessage = funcs.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)
# Rolls for critical injuries # Rolls for critical injuries
elif message.content.lower().startswith("!swcrit"): elif message.content.lower().startswith("!swcrit"):
funcs.logThis(message.author.name+" ran \""+message.content+"\"") funcs.logThis(message.author.display_name+" ran \""+message.content+"\"")
command = message.content.lower().replace("!swcrit","").replace(" ","").replace("+","") command = message.content.lower().replace("!swcrit","").replace(" ","").replace("+","")
if command == "": if command == "":
@@ -212,9 +212,9 @@ async def on_message(message):
# 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 message.content.lower().startswith("!swchar") or message.content.lower().startswith("!sw"): elif message.content.lower().startswith("!swchar") or message.content.lower().startswith("!sw"):
funcs.logThis(message.author.name+" ran \""+message.content+"\"") funcs.logThis(message.author.display_name+" ran \""+message.content+"\"")
command = string.capwords(message.content.lower().replace("!swchar","").replace("!sw","").replace("+","+ ").replace("-","- ").replace(",",", ")) command = string.capwords(message.content.lower().replace("!swchar","").replace("!sw","").replace("+","+ ").replace("-","- ").replace(",",", "))
title, desc = funcs.parseChar(message.author.name,command) title, desc = funcs.parseChar(message.author.display_name,command)
if title != "": if title != "":
em1 = discord.Embed(title = title, description = desc, colour=0xDEADBF) em1 = discord.Embed(title = title, description = desc, colour=0xDEADBF)
await message.channel.send(embed = em1) await message.channel.send(embed = em1)
@@ -225,7 +225,7 @@ async def on_message(message):
# Searches for a specific page on the Senkulpa Wiki # Searches for a specific page on the Senkulpa Wiki
elif message.content.lower().startswith("!wiki "): elif message.content.lower().startswith("!wiki "):
async with message.channel.typing(): async with message.channel.typing():
funcs.logThis(message.author.name+" ran \""+message.content+"\"") funcs.logThis(message.author.display_name+" ran \""+message.content+"\"")
command = string.capwords(message.content.lower().replace("!wiki ","")) command = string.capwords(message.content.lower().replace("!wiki ",""))
title, content, thumbnail = funcs.findWikiPage(command) title, content, thumbnail = funcs.findWikiPage(command)
if title != "": if title != "":
@@ -242,7 +242,7 @@ async def on_message(message):
# Runs a trivia game # Runs a trivia game
elif message.content.lower().startswith("!trivia"): elif message.content.lower().startswith("!trivia"):
funcs.logThis(message.author.name+" ran \""+message.content+"\"") funcs.logThis(message.author.display_name+" ran \""+message.content+"\"")
if message.content.lower() == "!trivia" or message.content.lower() == "!trivia ": if message.content.lower() == "!trivia" or message.content.lower() == "!trivia ":
question, answers, correctAnswer = funcs.triviaStart(str(message.channel)) question, answers, correctAnswer = funcs.triviaStart(str(message.channel))
if answers != "": if answers != "":
@@ -270,7 +270,7 @@ async def on_message(message):
elif message.content.lower().startswith("!trivia "): elif message.content.lower().startswith("!trivia "):
command = message.content.lower().replace("!trivia ","") command = message.content.lower().replace("!trivia ","")
response = funcs.triviaOtherThing(message.author.name.lower(),str(message.channel),command) response = funcs.triviaOtherThing(message.author.display_name.lower(),str(message.channel),command)
if response.startswith("Locked in "): if response.startswith("Locked in "):
await message.add_reaction("👍") await message.add_reaction("👍")
else: else:
@@ -282,22 +282,22 @@ async def on_message(message):
#Checks your GwendoBucks balance #Checks your GwendoBucks balance
elif message.content.lower().startswith("!balance"): elif message.content.lower().startswith("!balance"):
funcs.logThis(message.author.name+" ran \""+message.content+"\"") funcs.logThis(message.author.display_name+" ran \""+message.content+"\"")
response = funcs.checkBalance(message.author.name.lower()) response = funcs.checkBalance(message.author.display_name.lower())
if response == 1: if response == 1:
new_message = message.author.name + " has " + str(response) + " GwendoBuck" new_message = message.author.display_name + " has " + str(response) + " GwendoBuck"
else: else:
new_message = message.author.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)
#gives money to other player #gives money to other player
elif message.content.lower().startswith("!give "): elif message.content.lower().startswith("!give "):
funcs.logThis(message.author.name+" ran \""+message.content+"\"") funcs.logThis(message.author.display_name+" ran \""+message.content+"\"")
commands = message.content.lower().split(" ") commands = message.content.lower().split(" ")
if len(commands) >= 3: if len(commands) >= 3:
try: try:
amount = int(commands[2]) amount = int(commands[2])
response = funcs.giveMoney(message.author.name.lower(),commands[1],amount) response = funcs.giveMoney(message.author.display_name.lower(),commands[1],amount)
await message.channel.send(response) await message.channel.send(response)
except: except:
funcs.logThis("I didn't quite understand that") funcs.logThis("I didn't quite understand that")
@@ -307,7 +307,7 @@ async def on_message(message):
await message.channel.send("I didn't understand that") await message.channel.send("I didn't understand that")
elif message.content.lower().startswith("!blackjack"): elif message.content.lower().startswith("!blackjack"):
funcs.logThis(message.author.name+" ran \""+message.content+"\"") funcs.logThis(message.author.display_name+" ran \""+message.content+"\"")
if message.content.lower() == "!blackjack" or message.content.lower() == "!blackjack ": if message.content.lower() == "!blackjack" or message.content.lower() == "!blackjack ":
new_message = funcs.blackjackStart(str(message.channel)) new_message = funcs.blackjackStart(str(message.channel))
if new_message == "started": if new_message == "started":
@@ -361,25 +361,25 @@ async def on_message(message):
funcs.logThis("I didn't understand that") funcs.logThis("I didn't understand that")
response = "I didn't understand that" response = "I didn't understand that"
else: else:
response = funcs.blackjackPlayerDrawHand(str(message.channel),message.author.name,amount) response = funcs.blackjackPlayerDrawHand(str(message.channel),message.author.display_name,amount)
await message.channel.send(response) await message.channel.send(response)
if message.content.lower().startswith("!blackjack hit"): if message.content.lower().startswith("!blackjack hit"):
response = funcs.blackjackHit(str(message.channel),message.author.name) response = funcs.blackjackHit(str(message.channel),message.author.display_name)
if response == "accept": if response == "accept":
await message.add_reaction("👍") await message.add_reaction("👍")
else: else:
await message.channel.send(response) await message.channel.send(response)
if message.content.lower().startswith("!blackjack stand"): if message.content.lower().startswith("!blackjack stand"):
response = funcs.blackjackStand(str(message.channel),message.author.name) response = funcs.blackjackStand(str(message.channel),message.author.display_name)
if response == "accept": if response == "accept":
await message.add_reaction("👍") await message.add_reaction("👍")
else: else:
await message.channel.send(response) await message.channel.send(response)
if message.content.lower().startswith("!blackjack double"): if message.content.lower().startswith("!blackjack double"):
response = funcs.blackjackDouble(str(message.channel),message.author.name) response = funcs.blackjackDouble(str(message.channel),message.author.display_name)
await message.channel.send(response) await message.channel.send(response)
@@ -387,7 +387,7 @@ async def on_message(message):
# Is a bit sassy sometimes # Is a bit sassy sometimes
meanWords = ["stupid", "bitch", "fuck", "dumb", "idiot"] meanWords = ["stupid", "bitch", "fuck", "dumb", "idiot"]
if ("gwendolyn" in message.content.lower() or message.content.startswith("!")) 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("!")) 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():
funcs.logThis(message.author.name+" was a bit mean") funcs.logThis(message.author.display_name+" was a bit mean")
emoji = random.choice(["😠", "🖕", "👎"]) emoji = random.choice(["😠", "🖕", "👎"])
await message.add_reaction(emoji) await message.add_reaction(emoji)