✨ Uses channel ID istead of name
This commit is contained in:
150
Gwendolyn.py
150
Gwendolyn.py
@ -34,26 +34,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)",str(message.channel))
|
logThis("Couldn't find help.txt (error code 101)",str(message.channel.id))
|
||||||
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",str(message.channel))
|
logThis("Looking for "+command+".txt",str(message.channel.id))
|
||||||
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)",str(message.channel))
|
logThis("Couldn't find help for that command (error code 102)",str(message.channel.id))
|
||||||
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)",str(message.channel))
|
logThis("Something fucked up (error code 100)",str(message.channel.id))
|
||||||
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
|
||||||
elif content.startswith("log "):
|
elif content.startswith("log "):
|
||||||
logThis(content.replace("log ",""),str(message.channel))
|
logThis(content.replace("log ",""),str(message.channel.id))
|
||||||
|
|
||||||
# Stops the bot
|
# Stops the bot
|
||||||
elif content.startswith("stop"):
|
elif content.startswith("stop"):
|
||||||
@ -65,10 +65,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)",str(message.channel))
|
logThis(message.author.display_name+" tried to run stop me! (error code 201)",str(message.channel.id))
|
||||||
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)",str(message.channel))
|
logThis("Something fucked up (error code 200)",str(message.channel.id))
|
||||||
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
|
||||||
@ -76,7 +76,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)",str(message.channel))
|
logThis("Something fucked up (error code 310)",str(message.channel.id))
|
||||||
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
|
||||||
@ -87,7 +87,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)",str(message.channel))
|
logThis("Something fucked up (error code 400)",str(message.channel.id))
|
||||||
await message.channel.send("Not a valid command (error code 400)")
|
await message.channel.send("Not a valid command (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
|
||||||
@ -100,7 +100,7 @@ async def parseCommands(message,content):
|
|||||||
else:
|
else:
|
||||||
await message.channel.send(spell)
|
await message.channel.send(spell)
|
||||||
except:
|
except:
|
||||||
logThis("Something fucked up (error code 500)",str(message.channel))
|
logThis("Something fucked up (error code 500)",str(message.channel.id))
|
||||||
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
|
||||||
@ -149,7 +149,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)",str(message.channel))
|
logThis("Something fucked up (error code 600)",str(message.channel.id))
|
||||||
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
|
||||||
@ -157,7 +157,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)",str(message.channel))
|
logThis("Something fucked up (error code 320)",str(message.channel.id))
|
||||||
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
|
||||||
@ -167,7 +167,7 @@ async def parseCommands(message,content):
|
|||||||
randomImage = imageFunc()
|
randomImage = imageFunc()
|
||||||
await message.channel.send(randomImage)
|
await message.channel.send(randomImage)
|
||||||
except:
|
except:
|
||||||
logThis("Something fucked up (error code 700)",str(message.channel))
|
logThis("Something fucked up (error code 700)",str(message.channel.id))
|
||||||
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
|
||||||
@ -187,7 +187,7 @@ async def parseCommands(message,content):
|
|||||||
except:
|
except:
|
||||||
logThis("Error embedding (error code 805)")
|
logThis("Error embedding (error code 805)")
|
||||||
except:
|
except:
|
||||||
logThis("Something fucked up (error code 800)",str(message.channel))
|
logThis("Something fucked up (error code 800)",str(message.channel.id))
|
||||||
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
|
||||||
@ -195,7 +195,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)",str(message.channel))
|
logThis("Something fucked up (error code 330)",str(message.channel.id))
|
||||||
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
|
||||||
@ -203,7 +203,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)",str(message.channel))
|
logThis("Something fucked up (error code 340)",str(message.channel.id))
|
||||||
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
|
||||||
@ -213,7 +213,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)",str(message.channel))
|
logThis("Something fucked up (error code 350)",str(message.channel.id))
|
||||||
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
|
||||||
@ -225,7 +225,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)",str(message.channel))
|
logThis("Something fucked up (error code 910)",str(message.channel.id))
|
||||||
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
|
||||||
@ -237,7 +237,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)",str(message.channel))
|
logThis("Something fucked up (error code 920)",str(message.channel.id))
|
||||||
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
|
||||||
@ -251,14 +251,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)",str(message.channel))
|
logThis("They didn't include a number (error code 931)",str(message.channel.id))
|
||||||
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)",str(message.channel))
|
logThis("Something fucked up (error code 930)",str(message.channel.id))
|
||||||
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
|
||||||
@ -273,7 +273,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)",str(message.channel))
|
logThis("Something fucked up (error code 940)",str(message.channel.id))
|
||||||
await message.channel.send("Something fucked up (error code 940)")
|
await message.channel.send("Something fucked up (error code 940)")
|
||||||
|
|
||||||
|
|
||||||
@ -284,7 +284,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",str(message.channel))
|
logThis("Sending the embedded message",str(message.channel.id))
|
||||||
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 != "":
|
||||||
@ -294,7 +294,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)",str(message.channel))
|
logThis("Something fucked up (error code 1000)",str(message.channel.id))
|
||||||
await message.channel.send("Something fucked up (error code 1000)")
|
await message.channel.send("Something fucked up (error code 1000)")
|
||||||
|
|
||||||
|
|
||||||
@ -302,7 +302,7 @@ async def parseCommands(message,content):
|
|||||||
elif content.startswith("trivia"):
|
elif content.startswith("trivia"):
|
||||||
try:
|
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.id))
|
||||||
if answers != "":
|
if answers != "":
|
||||||
results = "**"+question+"**\n"
|
results = "**"+question+"**\n"
|
||||||
for answer in range(len(answers)):
|
for answer in range(len(answers)):
|
||||||
@ -312,27 +312,27 @@ async def parseCommands(message,content):
|
|||||||
|
|
||||||
await asyncio.sleep(60)
|
await asyncio.sleep(60)
|
||||||
|
|
||||||
triviaCountPoints(str(message.channel))
|
triviaCountPoints(str(message.channel.id))
|
||||||
|
|
||||||
deleteGame("trivia questions",str(message.channel))
|
deleteGame("trivia questions",str(message.channel.id))
|
||||||
|
|
||||||
logThis("Time's up for the trivia question",str(message.channel))
|
logThis("Time's up for the trivia question",str(message.channel.id))
|
||||||
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)
|
||||||
|
|
||||||
elif content.startswith("trivia "):
|
elif content.startswith("trivia "):
|
||||||
command = content.replace("trivia ","")
|
command = content.replace("trivia ","")
|
||||||
response = triviaAnswer("#"+str(message.author.id),str(message.channel),command)
|
response = triviaAnswer("#"+str(message.author.id),str(message.channel.id),command)
|
||||||
if response.startswith("Locked in "):
|
if response.startswith("Locked in "):
|
||||||
await message.add_reaction("👍")
|
await message.add_reaction("👍")
|
||||||
else:
|
else:
|
||||||
await message.channel.send(response)
|
await message.channel.send(response)
|
||||||
else:
|
else:
|
||||||
logThis("I didn't understand that (error code 1101)",str(message.channel))
|
logThis("I didn't understand that (error code 1101)",str(message.channel.id))
|
||||||
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)",str(message.channel))
|
logThis("Something fucked up (error code 1100)",str(message.channel.id))
|
||||||
await message.channel.send("Something fucked up (error code 1100)")
|
await message.channel.send("Something fucked up (error code 1100)")
|
||||||
|
|
||||||
|
|
||||||
@ -346,7 +346,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)",str(message.channel))
|
logThis("Something fucked up (error code 1210)",str(message.channel.id))
|
||||||
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
|
||||||
@ -357,16 +357,16 @@ async def parseCommands(message,content):
|
|||||||
try:
|
try:
|
||||||
amount = int(commands[2])
|
amount = int(commands[2])
|
||||||
except:
|
except:
|
||||||
logThis("Conversion error (error code 1221)",str(message.channel))
|
logThis("Conversion error (error code 1221)",str(message.channel.id))
|
||||||
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("#"+str(message.author.id),commands[1],amount)
|
response = giveMoney("#"+str(message.author.id),commands[1],amount)
|
||||||
await message.channel.send(response)
|
await message.channel.send(response)
|
||||||
else:
|
else:
|
||||||
logThis("I didn't understand that (error code 1222)",str(message.channel))
|
logThis("I didn't understand that (error code 1222)",str(message.channel.id))
|
||||||
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)",str(message.channel))
|
logThis("Something fucked up (error code 1220)",str(message.channel.id))
|
||||||
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
|
||||||
@ -375,25 +375,25 @@ async def parseCommands(message,content):
|
|||||||
# Starts the game
|
# Starts the game
|
||||||
if content == "blackjack" or content == "blackjack ":
|
if content == "blackjack" or content == "blackjack ":
|
||||||
cardsLeft = 0
|
cardsLeft = 0
|
||||||
if os.path.exists("resources/games/blackjackCards/"+str(message.channel)+".txt"):
|
if os.path.exists("resources/games/blackjackCards/"+str(message.channel.id)+".txt"):
|
||||||
with open("resources/games/blackjackCards/"+str(message.channel)+".txt","r") as f:
|
with open("resources/games/blackjackCards/"+str(message.channel.id)+".txt","r") as f:
|
||||||
for _ in f:
|
for _ in f:
|
||||||
cardsLeft += 1
|
cardsLeft += 1
|
||||||
|
|
||||||
# Shuffles if not enough cards
|
# Shuffles if not enough cards
|
||||||
if cardsLeft < blackjackMinCards:
|
if cardsLeft < blackjackMinCards:
|
||||||
blackjackShuffle(blackjackDecks,str(message.channel))
|
blackjackShuffle(blackjackDecks,str(message.channel.id))
|
||||||
logThis("Shuffling the blackjack deck...",str(message.channel))
|
logThis("Shuffling the blackjack deck...",str(message.channel.id))
|
||||||
await message.channel.send("Shuffling the deck...")
|
await message.channel.send("Shuffling the deck...")
|
||||||
|
|
||||||
new_message = blackjackStart(str(message.channel))
|
new_message = blackjackStart(str(message.channel.id))
|
||||||
if new_message == "started":
|
if new_message == "started":
|
||||||
|
|
||||||
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."
|
||||||
await message.channel.send(new_message)
|
await message.channel.send(new_message)
|
||||||
oldImage = await message.channel.send(file = discord.File("resources/games/blackjackTables/blackjackTable"+str(message.channel)+".png"))
|
oldImage = await message.channel.send(file = discord.File("resources/games/blackjackTables/blackjackTable"+str(message.channel.id)+".png"))
|
||||||
|
|
||||||
with open("resources/games/oldImages/blackjack"+str(message.channel), "w") as f:
|
with open("resources/games/oldImages/blackjack"+str(message.channel.id), "w") as f:
|
||||||
f.write(str(oldImage.id))
|
f.write(str(oldImage.id))
|
||||||
|
|
||||||
await asyncio.sleep(30)
|
await asyncio.sleep(30)
|
||||||
@ -402,17 +402,17 @@ async def parseCommands(message,content):
|
|||||||
|
|
||||||
with open("resources/games/games.json", "r") as f:
|
with open("resources/games/games.json", "r") as f:
|
||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
if len(data["blackjack games"][str(message.channel)]["user hands"]) == 0:
|
if len(data["blackjack games"][str(message.channel.id)]["user hands"]) == 0:
|
||||||
gamedone = True
|
gamedone = True
|
||||||
await message.channel.send("No one entered the game. Ending the game.")
|
await message.channel.send("No one entered the game. Ending the game.")
|
||||||
gameID = data["blackjack games"][str(message.channel)]["id"]
|
gameID = data["blackjack games"][str(message.channel.id)]["id"]
|
||||||
|
|
||||||
# Loop of game rounds
|
# Loop of game rounds
|
||||||
if gamedone == False:
|
if gamedone == False:
|
||||||
logThis("!blackjack calling blackjackLoop()",str(message.channel))
|
logThis("!blackjack calling blackjackLoop()",str(message.channel.id))
|
||||||
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.id))
|
||||||
await message.channel.send(new_message)
|
await message.channel.send(new_message)
|
||||||
else:
|
else:
|
||||||
await message.channel.send(new_message)
|
await message.channel.send(new_message)
|
||||||
@ -423,34 +423,34 @@ async def parseCommands(message,content):
|
|||||||
try:
|
try:
|
||||||
amount = int(commands[2])
|
amount = int(commands[2])
|
||||||
except:
|
except:
|
||||||
logThis("I didn't understand that",str(message.channel))
|
logThis("I didn't understand that",str(message.channel.id))
|
||||||
response = "I didn't understand that"
|
response = "I didn't understand that"
|
||||||
else:
|
else:
|
||||||
response = blackjackPlayerDrawHand(str(message.channel),"#"+str(message.author.id),amount)
|
response = blackjackPlayerDrawHand(str(message.channel.id),"#"+str(message.author.id),amount)
|
||||||
await message.channel.send(response)
|
await message.channel.send(response)
|
||||||
|
|
||||||
# Hitting
|
# Hitting
|
||||||
elif content.startswith("blackjack hit"):
|
elif content.startswith("blackjack hit"):
|
||||||
if content == "blackjack hit" or content == "blackjack hit ":
|
if content == "blackjack hit" or content == "blackjack hit ":
|
||||||
response = blackjackHit(str(message.channel),"#"+str(message.author.id))
|
response = blackjackHit(str(message.channel.id),"#"+str(message.author.id))
|
||||||
else:
|
else:
|
||||||
commands = content.split(" ")
|
commands = content.split(" ")
|
||||||
try:
|
try:
|
||||||
handNumber = int(commands[2])
|
handNumber = int(commands[2])
|
||||||
except:
|
except:
|
||||||
handNumber = 0
|
handNumber = 0
|
||||||
response = blackjackHit(str(message.channel),"#"+str(message.author.id),handNumber)
|
response = blackjackHit(str(message.channel.id),"#"+str(message.author.id),handNumber)
|
||||||
|
|
||||||
if response.startswith("accept"):
|
if response.startswith("accept"):
|
||||||
await message.add_reaction("👍")
|
await message.add_reaction("👍")
|
||||||
try:
|
try:
|
||||||
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)]["id"]
|
||||||
logThis("Hit calling blackjackLoop()",str(message.channel))
|
logThis("Hit calling blackjackLoop()",str(message.channel.id))
|
||||||
await blackjackLoop(message.channel,int(response[7:])+1,gameID)
|
await blackjackLoop(message.channel,int(response[7:])+1,gameID)
|
||||||
except:
|
except:
|
||||||
logThis("Something fucked up (error code 1320)",str(message.channel))
|
logThis("Something fucked up (error code 1320)",str(message.channel.id))
|
||||||
else:
|
else:
|
||||||
await message.channel.send(response)
|
await message.channel.send(response)
|
||||||
|
|
||||||
@ -458,25 +458,25 @@ async def parseCommands(message,content):
|
|||||||
# Standing
|
# Standing
|
||||||
elif content.startswith("blackjack stand"):
|
elif content.startswith("blackjack stand"):
|
||||||
if content == "blackjack hit" or content == "blackjack hit ":
|
if content == "blackjack hit" or content == "blackjack hit ":
|
||||||
response = blackjackStand(str(message.channel),"#"+str(message.author.id))
|
response = blackjackStand(str(message.channel.id),"#"+str(message.author.id))
|
||||||
else:
|
else:
|
||||||
commands = content.split(" ")
|
commands = content.split(" ")
|
||||||
try:
|
try:
|
||||||
handNumber = int(commands[2])
|
handNumber = int(commands[2])
|
||||||
except:
|
except:
|
||||||
handNumber = 0
|
handNumber = 0
|
||||||
response = blackjackStand(str(message.channel),"#"+str(message.author.id),handNumber)
|
response = blackjackStand(str(message.channel.id),"#"+str(message.author.id),handNumber)
|
||||||
|
|
||||||
if response.startswith("accept"):
|
if response.startswith("accept"):
|
||||||
await message.add_reaction("👍")
|
await message.add_reaction("👍")
|
||||||
try:
|
try:
|
||||||
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)]["id"]
|
||||||
logThis("Stand calling blackjackLoop()",str(message.channel))
|
logThis("Stand calling blackjackLoop()",str(message.channel.id))
|
||||||
await blackjackLoop(message.channel,int(response[7:])+1,gameID)
|
await blackjackLoop(message.channel,int(response[7:])+1,gameID)
|
||||||
except:
|
except:
|
||||||
logThis("Something fucked up (error code 1320)",str(message.channel))
|
logThis("Something fucked up (error code 1320)",str(message.channel.id))
|
||||||
else:
|
else:
|
||||||
await message.channel.send(response)
|
await message.channel.send(response)
|
||||||
|
|
||||||
@ -487,18 +487,18 @@ async def parseCommands(message,content):
|
|||||||
handNumber = int(commands[2])
|
handNumber = int(commands[2])
|
||||||
except:
|
except:
|
||||||
handNumber = 0
|
handNumber = 0
|
||||||
response, roundDone = blackjackDouble(str(message.channel),"#"+str(message.author.id),handNumber)
|
response, roundDone = blackjackDouble(str(message.channel.id),"#"+str(message.author.id),handNumber)
|
||||||
|
|
||||||
await message.channel.send(response)
|
await message.channel.send(response)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
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)]["id"]
|
||||||
logThis("Double calling blackjackLoop()",str(message.channel))
|
logThis("Double calling blackjackLoop()",str(message.channel.id))
|
||||||
await blackjackLoop(message.channel,int(roundDone[1:])+1,gameID)
|
await blackjackLoop(message.channel,int(roundDone[1:])+1,gameID)
|
||||||
except:
|
except:
|
||||||
logThis("Something fucked up (error code 1320)",str(message.channel))
|
logThis("Something fucked up (error code 1320)",str(message.channel.id))
|
||||||
|
|
||||||
# Splitting hand
|
# Splitting hand
|
||||||
elif content.startswith("blackjack split"):
|
elif content.startswith("blackjack split"):
|
||||||
@ -507,23 +507,23 @@ async def parseCommands(message,content):
|
|||||||
handNumber = int(commands[2])
|
handNumber = int(commands[2])
|
||||||
except:
|
except:
|
||||||
handNumber = 0
|
handNumber = 0
|
||||||
response, roundDone = blackjackSplit(str(message.channel),"#"+str(message.author.id),handNumber)
|
response, roundDone = blackjackSplit(str(message.channel.id),"#"+str(message.author.id),handNumber)
|
||||||
|
|
||||||
await message.channel.send(response)
|
await message.channel.send(response)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
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)]["id"]
|
||||||
logThis("Split calling blackjackLoop()",str(message.channel))
|
logThis("Split calling blackjackLoop()",str(message.channel.id))
|
||||||
await blackjackLoop(message.channel,int(roundDone[1:])+1,gameID)
|
await blackjackLoop(message.channel,int(roundDone[1:])+1,gameID)
|
||||||
except:
|
except:
|
||||||
logThis("Something fucked up (error code 1320)")
|
logThis("Something fucked up (error code 1320)")
|
||||||
|
|
||||||
# Returning current hi-lo value
|
# Returning current hi-lo value
|
||||||
elif content.startswith("blackjack hilo") and "#"+str(message.author.id) == "#266269899859427329":
|
elif content.startswith("blackjack hilo") and "#"+str(message.author.id) == "#266269899859427329":
|
||||||
if os.path.exists("resources/games/blackjackCards/"+str(message.channel)+".txt"):
|
if os.path.exists("resources/games/blackjackCards/"+str(message.channel.id)+".txt"):
|
||||||
with open("resources/games/hilo/"+str(message.channel)+".txt", "r") as f:
|
with open("resources/games/hilo/"+str(message.channel.id)+".txt", "r") as f:
|
||||||
data = f.read()
|
data = f.read()
|
||||||
else:
|
else:
|
||||||
data = "0"
|
data = "0"
|
||||||
@ -531,16 +531,16 @@ 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,str(message.channel))
|
blackjackShuffle(blackjackDecks,str(message.channel.id))
|
||||||
logThis("Shuffling the blackjack deck...",str(message.channel))
|
logThis("Shuffling the blackjack deck...",str(message.channel.id))
|
||||||
await message.channel.send("Shuffling the deck...")
|
await message.channel.send("Shuffling the deck...")
|
||||||
|
|
||||||
|
|
||||||
# Tells you the amount of cards left
|
# Tells you the amount of cards left
|
||||||
elif content.startswith("blackjack cards"):
|
elif content.startswith("blackjack cards"):
|
||||||
cardsLeft = 0
|
cardsLeft = 0
|
||||||
if os.path.exists("resources/games/blackjackCards/"+str(message.channel)+".txt"):
|
if os.path.exists("resources/games/blackjackCards/"+str(message.channel.id)+".txt"):
|
||||||
with open("resources/games/blackjackCards/"+str(message.channel)+".txt","r") as f:
|
with open("resources/games/blackjackCards/"+str(message.channel.id)+".txt","r") as f:
|
||||||
for _ in f:
|
for _ in f:
|
||||||
cardsLeft += 1
|
cardsLeft += 1
|
||||||
|
|
||||||
@ -579,7 +579,7 @@ async def parseCommands(message,content):
|
|||||||
|
|
||||||
# Not a command
|
# Not a command
|
||||||
else:
|
else:
|
||||||
logThis("That's not a command (error code 001)",str(message.channel))
|
logThis("That's not a command (error code 001)",str(message.channel.id))
|
||||||
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
|
||||||
@ -604,7 +604,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+" ("+"#"+str(message.author.id)+") ran \""+content+"\"",str(message.channel))
|
logThis(message.author.display_name+" ("+"#"+str(message.author.id)+") ran \""+content+"\"",str(message.channel.id))
|
||||||
addToDict("#"+str(message.author.id),message.author.display_name)
|
addToDict("#"+str(message.author.id),message.author.display_name)
|
||||||
await parseCommands(message,content.lower()[1:])
|
await parseCommands(message,content.lower()[1:])
|
||||||
except:
|
except:
|
||||||
@ -613,7 +613,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",str(message.channel))
|
logThis(message.author.display_name+" was a bit mean",str(message.channel.id))
|
||||||
emoji = random.choice(["😠", "🖕", "👎"])
|
emoji = random.choice(["😠", "🖕", "👎"])
|
||||||
await message.add_reaction(emoji)
|
await message.add_reaction(emoji)
|
||||||
|
|
||||||
@ -622,7 +622,7 @@ async def on_reaction_add(reaction,user):
|
|||||||
if user.bot == False:
|
if user.bot == False:
|
||||||
message = reaction.message
|
message = reaction.message
|
||||||
channel = message.channel
|
channel = message.channel
|
||||||
logThis(user.display_name+" reacted to a message",str(channel))
|
logThis(user.display_name+" reacted to a message",str(channel.id))
|
||||||
try:
|
try:
|
||||||
fourInARowTheirTurn, piece = fiarReactionTest(channel,message,"#"+str(user.id))
|
fourInARowTheirTurn, piece = fiarReactionTest(channel,message,"#"+str(user.id))
|
||||||
except:
|
except:
|
||||||
|
@ -209,13 +209,13 @@ def fiarReactionTest(channel,message,user):
|
|||||||
with open("resources/games/games.json", "r") as f:
|
with open("resources/games/games.json", "r") as f:
|
||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
|
|
||||||
with open("resources/games/oldImages/fourInARow"+str(channel), "r") as f:
|
with open("resources/games/oldImages/fourInARow"+str(channel.id), "r") as f:
|
||||||
oldImage = int(f.read())
|
oldImage = int(f.read())
|
||||||
|
|
||||||
if message.id == oldImage:
|
if message.id == oldImage:
|
||||||
logThis("They reacted to the fourinarow game")
|
logThis("They reacted to the fourinarow game")
|
||||||
turn = data["4 in a row games"][str(channel)]["turn"]
|
turn = data["4 in a row games"][str(channel.id)]["turn"]
|
||||||
if user == data["4 in a row games"][str(channel)]["players"][turn]:
|
if user == data["4 in a row games"][str(channel.id)]["players"][turn]:
|
||||||
return True, turn+1
|
return True, turn+1
|
||||||
else:
|
else:
|
||||||
logThis("It wasn't their turn")
|
logThis("It wasn't their turn")
|
||||||
@ -224,7 +224,7 @@ def fiarReactionTest(channel,message,user):
|
|||||||
return False, 0
|
return False, 0
|
||||||
|
|
||||||
def monopolyReactionTest(channel,message):
|
def monopolyReactionTest(channel,message):
|
||||||
with open("resources/games/oldImages/monopoly"+str(channel), "r") as f:
|
with open("resources/games/oldImages/monopoly"+str(channel.id), "r") as f:
|
||||||
oldImage = int(f.read())
|
oldImage = int(f.read())
|
||||||
|
|
||||||
if message.id == oldImage:
|
if message.id == oldImage:
|
||||||
|
98
gameLoops.py
98
gameLoops.py
@ -20,34 +20,34 @@ async def deleteMessage(imageLocation,channel):
|
|||||||
# Runs Hex
|
# Runs Hex
|
||||||
async def runHex(channel,command,user):
|
async def runHex(channel,command,user):
|
||||||
try:
|
try:
|
||||||
response, showImage, deleteImage, gameDone, gwendoTurn = parseHex(command,str(channel),user)
|
response, showImage, deleteImage, gameDone, gwendoTurn = parseHex(command,str(channel.id),user)
|
||||||
except:
|
except:
|
||||||
logThis("Error parsing command (error code 1510)")
|
logThis("Error parsing command (error code 1510)")
|
||||||
|
|
||||||
await channel.send(response)
|
await channel.send(response)
|
||||||
logThis(response,str(channel))
|
logThis(response,str(channel.id))
|
||||||
if showImage:
|
if showImage:
|
||||||
if deleteImage:
|
if deleteImage:
|
||||||
try:
|
try:
|
||||||
oldImage = await deleteMessage("hex"+str(channel),channel)
|
oldImage = await deleteMessage("hex"+str(channel.id),channel)
|
||||||
except:
|
except:
|
||||||
logThis("Error deleting old image (error code 1501)")
|
logThis("Error deleting old image (error code 1501)")
|
||||||
oldImage = await channel.send(file = discord.File("resources/games/hexBoards/board"+str(channel)+".png"))
|
oldImage = await channel.send(file = discord.File("resources/games/hexBoards/board"+str(channel.id)+".png"))
|
||||||
if not gameDone:
|
if not gameDone:
|
||||||
if gwendoTurn:
|
if gwendoTurn:
|
||||||
try:
|
try:
|
||||||
response, showImage, deleteImage, gameDone, gwendoTurn = hexAI(str(channel))
|
response, showImage, deleteImage, gameDone, gwendoTurn = hexAI(str(channel.id))
|
||||||
except:
|
except:
|
||||||
logThis("AI error (error code 1520)")
|
logThis("AI error (error code 1520)")
|
||||||
await channel.send(response)
|
await channel.send(response)
|
||||||
logThis(response,str(channel))
|
logThis(response,str(channel.id))
|
||||||
if showImage:
|
if showImage:
|
||||||
if deleteImage:
|
if deleteImage:
|
||||||
await oldImage.delete()
|
await oldImage.delete()
|
||||||
oldImage = await channel.send(file = discord.File("resources/games/hexBoards/board"+str(channel)+".png"))
|
oldImage = await channel.send(file = discord.File("resources/games/hexBoards/board"+str(channel.id)+".png"))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
with open("resources/games/oldImages/hex"+str(channel), "w") as f:
|
with open("resources/games/oldImages/hex"+str(channel.id), "w") as f:
|
||||||
f.write(str(oldImage.id))
|
f.write(str(oldImage.id))
|
||||||
|
|
||||||
if gameDone:
|
if gameDone:
|
||||||
@ -55,52 +55,52 @@ async def runHex(channel,command,user):
|
|||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open("resources/games/oldImages/hex"+str(channel), "r") as f:
|
with open("resources/games/oldImages/hex"+str(channel.id), "r") as f:
|
||||||
oldImage = await channel.fetch_message(int(f.read()))
|
oldImage = await channel.fetch_message(int(f.read()))
|
||||||
await oldImage.delete()
|
await oldImage.delete()
|
||||||
except:
|
except:
|
||||||
logThis("The old image was already deleted")
|
logThis("The old image was already deleted")
|
||||||
|
|
||||||
winner = data["hex games"][str(channel)]["winner"]
|
winner = data["hex games"][str(channel.id)]["winner"]
|
||||||
if winner != 0:
|
if winner != 0:
|
||||||
addMoney(data["hex games"][str(channel)]["players"][winner-1].lower(),20)
|
addMoney(data["hex games"][str(channel.id)]["players"][winner-1].lower(),20)
|
||||||
with open("resources/games/games.json", "r") as f:
|
with open("resources/games/games.json", "r") as f:
|
||||||
data = json.load(f) #why is this here?
|
data = json.load(f) #why is this here?
|
||||||
|
|
||||||
deleteGame("hex games",str(channel))
|
deleteGame("hex games",str(channel.id))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Runs Four in a Row
|
# Runs Four in a Row
|
||||||
async def fiar(channel,command,user):
|
async def fiar(channel,command,user):
|
||||||
try:
|
try:
|
||||||
response, showImage, deleteImage, gameDone, gwendoTurn = parseFourInARow(command,str(channel),user)
|
response, showImage, deleteImage, gameDone, gwendoTurn = parseFourInARow(command,str(channel.id),user)
|
||||||
except:
|
except:
|
||||||
logThis("Error parsing command (error code 1410)")
|
logThis("Error parsing command (error code 1410)")
|
||||||
|
|
||||||
await channel.send(response)
|
await channel.send(response)
|
||||||
logThis(response,str(channel))
|
logThis(response,str(channel.id))
|
||||||
if showImage:
|
if showImage:
|
||||||
if deleteImage:
|
if deleteImage:
|
||||||
try:
|
try:
|
||||||
oldImage = await deleteMessage("fourInARow"+str(channel),channel)
|
oldImage = await deleteMessage("fourInARow"+str(channel.id),channel)
|
||||||
except:
|
except:
|
||||||
logThis("Error deleting message (error code 1401)")
|
logThis("Error deleting message (error code 1401)")
|
||||||
oldImage = await channel.send(file = discord.File("resources/games/4InARowBoards/board"+str(channel)+".png"))
|
oldImage = await channel.send(file = discord.File("resources/games/4InARowBoards/board"+str(channel.id)+".png"))
|
||||||
if gameDone == False:
|
if gameDone == False:
|
||||||
if gwendoTurn:
|
if gwendoTurn:
|
||||||
try:
|
try:
|
||||||
response, showImage, deleteImage, gameDone, gwendoTurn = fourInARowAI(str(channel))
|
response, showImage, deleteImage, gameDone, gwendoTurn = fourInARowAI(str(channel.id))
|
||||||
except:
|
except:
|
||||||
logThis("AI error (error code 1420)")
|
logThis("AI error (error code 1420)")
|
||||||
await channel.send(response)
|
await channel.send(response)
|
||||||
logThis(response,str(channel))
|
logThis(response,str(channel.id))
|
||||||
if showImage:
|
if showImage:
|
||||||
if deleteImage:
|
if deleteImage:
|
||||||
await oldImage.delete()
|
await oldImage.delete()
|
||||||
oldImage = await channel.send(file = discord.File("resources/games/4InARowBoards/board"+str(channel)+".png"))
|
oldImage = await channel.send(file = discord.File("resources/games/4InARowBoards/board"+str(channel.id)+".png"))
|
||||||
if gameDone == False:
|
if gameDone == False:
|
||||||
with open("resources/games/oldImages/fourInARow"+str(channel), "w") as f:
|
with open("resources/games/oldImages/fourInARow"+str(channel.id), "w") as f:
|
||||||
f.write(str(oldImage.id))
|
f.write(str(oldImage.id))
|
||||||
try:
|
try:
|
||||||
reactions = ["1️⃣","2️⃣","3️⃣","4️⃣","5️⃣","6️⃣","7️⃣"]
|
reactions = ["1️⃣","2️⃣","3️⃣","4️⃣","5️⃣","6️⃣","7️⃣"]
|
||||||
@ -111,7 +111,7 @@ async def fiar(channel,command,user):
|
|||||||
logThis("Image deleted before I could react to all of them")
|
logThis("Image deleted before I could react to all of them")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
with open("resources/games/oldImages/fourInARow"+str(channel), "w") as f:
|
with open("resources/games/oldImages/fourInARow"+str(channel.id), "w") as f:
|
||||||
f.write(str(oldImage.id))
|
f.write(str(oldImage.id))
|
||||||
try:
|
try:
|
||||||
reactions = ["1️⃣","2️⃣","3️⃣","4️⃣","5️⃣","6️⃣","7️⃣"]
|
reactions = ["1️⃣","2️⃣","3️⃣","4️⃣","5️⃣","6️⃣","7️⃣"]
|
||||||
@ -125,39 +125,39 @@ async def fiar(channel,command,user):
|
|||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open("resources/games/oldImages/fourInARow"+str(channel), "r") as f:
|
with open("resources/games/oldImages/fourInARow"+str(channel.id), "r") as f:
|
||||||
oldImage = await channel.fetch_message(int(f.read()))
|
oldImage = await channel.fetch_message(int(f.read()))
|
||||||
|
|
||||||
await oldImage.delete()
|
await oldImage.delete()
|
||||||
except:
|
except:
|
||||||
logThis("The old image was already deleted")
|
logThis("The old image was already deleted")
|
||||||
|
|
||||||
winner = data["4 in a row games"][str(channel)]["winner"]
|
winner = data["4 in a row games"][str(channel.id)]["winner"]
|
||||||
difficulty = int(data["4 in a row games"][str(channel)]["difficulty"])
|
difficulty = int(data["4 in a row games"][str(channel.id)]["difficulty"])
|
||||||
reward = difficulty**2 + 5
|
reward = difficulty**2 + 5
|
||||||
if winner != 0:
|
if winner != 0:
|
||||||
if data["4 in a row games"][str(channel)]["players"][winner-1].lower() != "gwendolyn":
|
if data["4 in a row games"][str(channel.id)]["players"][winner-1].lower() != "gwendolyn":
|
||||||
addMoney(data["4 in a row games"][str(channel)]["players"][winner-1].lower(),reward)
|
addMoney(data["4 in a row games"][str(channel.id)]["players"][winner-1].lower(),reward)
|
||||||
with open("resources/games/games.json", "r") as f:
|
with open("resources/games/games.json", "r") as f:
|
||||||
data = json.load(f) #why is this here?
|
data = json.load(f) #why is this here?
|
||||||
|
|
||||||
deleteGame("4 in a row games",str(channel))
|
deleteGame("4 in a row games",str(channel.id))
|
||||||
|
|
||||||
# Loop of blackjack game rounds
|
# Loop of blackjack game rounds
|
||||||
async def blackjackLoop(channel,gameRound,gameID):
|
async def blackjackLoop(channel,gameRound,gameID):
|
||||||
logThis("Loop "+str(gameRound),str(channel))
|
logThis("Loop "+str(gameRound),str(channel.id))
|
||||||
|
|
||||||
with open("resources/games/oldImages/blackjack"+str(channel), "r") as f:
|
with open("resources/games/oldImages/blackjack"+str(channel.id), "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.id))
|
||||||
if new_message != "":
|
if new_message != "":
|
||||||
logThis(new_message,str(channel))
|
logThis(new_message,str(channel.id))
|
||||||
await channel.send(new_message)
|
await channel.send(new_message)
|
||||||
if gamedone == False:
|
if gamedone == False:
|
||||||
await oldImage.delete()
|
await oldImage.delete()
|
||||||
oldImage = await channel.send(file = discord.File("resources/games/blackjackTables/blackjackTable"+str(channel)+".png"))
|
oldImage = await channel.send(file = discord.File("resources/games/blackjackTables/blackjackTable"+str(channel.id)+".png"))
|
||||||
with open("resources/games/oldImages/blackjack"+str(channel), "w") as f:
|
with open("resources/games/oldImages/blackjack"+str(channel.id), "w") as f:
|
||||||
f.write(str(oldImage.id))
|
f.write(str(oldImage.id))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -171,41 +171,41 @@ async def blackjackLoop(channel,gameRound,gameID):
|
|||||||
with open("resources/games/games.json", "r") as f:
|
with open("resources/games/games.json", "r") as f:
|
||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
|
|
||||||
if str(channel) in data["blackjack games"]:
|
if str(channel.id) in data["blackjack games"]:
|
||||||
realRound = data["blackjack games"][str(channel)]["round"]
|
realRound = data["blackjack games"][str(channel.id)]["round"]
|
||||||
realGameID = data["blackjack games"][str(channel)]["id"]
|
realGameID = data["blackjack games"][str(channel.id)]["id"]
|
||||||
|
|
||||||
if gameRound == realRound and realGameID == gameID:
|
if gameRound == realRound and realGameID == gameID:
|
||||||
if gamedone == False:
|
if gamedone == False:
|
||||||
logThis("Loop "+str(gameRound)+" calling blackjackLoop()",str(channel))
|
logThis("Loop "+str(gameRound)+" calling blackjackLoop()",str(channel.id))
|
||||||
await blackjackLoop(channel,gameRound+1,gameID)
|
await blackjackLoop(channel,gameRound+1,gameID)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
new_message = blackjackFinish(str(channel))
|
new_message = blackjackFinish(str(channel.id))
|
||||||
except:
|
except:
|
||||||
logThis("Something fucked up (error code 1310)")
|
logThis("Something fucked up (error code 1310)")
|
||||||
await channel.send(new_message)
|
await channel.send(new_message)
|
||||||
else:
|
else:
|
||||||
logThis("Ending loop on round "+str(gameRound),str(channel))
|
logThis("Ending loop on round "+str(gameRound),str(channel.id))
|
||||||
else:
|
else:
|
||||||
logThis("Ending loop on round "+str(gameRound),str(channel))
|
logThis("Ending loop on round "+str(gameRound),str(channel.id))
|
||||||
|
|
||||||
async def runMonopoly(channel, command, user):
|
async def runMonopoly(channel, command, user):
|
||||||
try:
|
try:
|
||||||
response, showImage, deleteImage, gameStarted, gameContinue = parseMonopoly(command,str(channel),user)
|
response, showImage, deleteImage, gameStarted, gameContinue = parseMonopoly(command,str(channel.id),user)
|
||||||
except:
|
except:
|
||||||
logThis("Error parsing command (error code 1610)")
|
logThis("Error parsing command (error code 1610)")
|
||||||
if response != "":
|
if response != "":
|
||||||
await channel.send(response)
|
await channel.send(response)
|
||||||
logThis(response,str(channel))
|
logThis(response,str(channel.id))
|
||||||
if showImage:
|
if showImage:
|
||||||
if deleteImage:
|
if deleteImage:
|
||||||
try:
|
try:
|
||||||
oldImage = await deleteMessage("monopoly"+str(channel),channel)
|
oldImage = await deleteMessage("monopoly"+str(channel.id),channel)
|
||||||
except:
|
except:
|
||||||
logThis("Error deleting message (error code 1601)")
|
logThis("Error deleting message (error code 1601)")
|
||||||
oldImage = await channel.send(file = discord.File("resources/games/monopolyBoards/monopolyBoard"+str(channel)+".png"))
|
oldImage = await channel.send(file = discord.File("resources/games/monopolyBoards/monopolyBoard"+str(channel.id)+".png"))
|
||||||
with open("resources/games/oldImages/monopoly"+str(channel), "w") as f:
|
with open("resources/games/oldImages/monopoly"+str(channel.id), "w") as f:
|
||||||
f.write(str(oldImage.id))
|
f.write(str(oldImage.id))
|
||||||
|
|
||||||
if gameContinue:
|
if gameContinue:
|
||||||
@ -213,17 +213,17 @@ async def runMonopoly(channel, command, user):
|
|||||||
await asyncio.sleep(60)
|
await asyncio.sleep(60)
|
||||||
else:
|
else:
|
||||||
await asyncio.sleep(5)
|
await asyncio.sleep(5)
|
||||||
response, showImage, deleteImage, gameDone = monopolyContinue(str(channel))
|
response, showImage, deleteImage, gameDone = monopolyContinue(str(channel.id))
|
||||||
em = discord.Embed(description=response,colour = 0x59f442)
|
em = discord.Embed(description=response,colour = 0x59f442)
|
||||||
await channel.send(embed=em)
|
await channel.send(embed=em)
|
||||||
if showImage:
|
if showImage:
|
||||||
if deleteImage:
|
if deleteImage:
|
||||||
try:
|
try:
|
||||||
oldImage = await deleteMessage("monopoly"+str(channel),channel)
|
oldImage = await deleteMessage("monopoly"+str(channel.id),channel)
|
||||||
except:
|
except:
|
||||||
logThis("Error deleting message (error code 1601)")
|
logThis("Error deleting message (error code 1601)")
|
||||||
oldImage = await channel.send(file = discord.File("resources/games/monopolyBoards/monopolyBoard"+str(channel)+".png"))
|
oldImage = await channel.send(file = discord.File("resources/games/monopolyBoards/monopolyBoard"+str(channel.id)+".png"))
|
||||||
with open("resources/games/oldImages/monopoly"+str(channel), "w") as f:
|
with open("resources/games/oldImages/monopoly"+str(channel.id), "w") as f:
|
||||||
f.write(str(oldImage.id))
|
f.write(str(oldImage.id))
|
||||||
if gameDone == False:
|
if gameDone == False:
|
||||||
try:
|
try:
|
||||||
|
Reference in New Issue
Block a user