🗃️ Better modules and init files
This commit is contained in:
53
Gwendolyn.py
53
Gwendolyn.py
@ -7,7 +7,7 @@ import codecs
|
||||
import string
|
||||
import json
|
||||
import random
|
||||
import math
|
||||
#import math
|
||||
import os
|
||||
|
||||
from funcs import *
|
||||
@ -122,10 +122,14 @@ async def blackjackLoop(channel,gameRound,gameID):
|
||||
oldImage = await channel.send(file = discord.File("resources/games/blackjackTables/blackjackTable"+str(channel)+".png"))
|
||||
with open("resources/games/oldImages/blackjack"+str(channel), "w") as f:
|
||||
f.write(str(oldImage.id))
|
||||
if allStanding:
|
||||
await asyncio.sleep(5)
|
||||
else:
|
||||
await asyncio.sleep(120)
|
||||
|
||||
try:
|
||||
if allStanding:
|
||||
await asyncio.sleep(5)
|
||||
else:
|
||||
await asyncio.sleep(120)
|
||||
except:
|
||||
logThis("Loop "+str(gameRound)+" interrupted (error code 1321)")
|
||||
|
||||
with open("resources/games/games.json", "r") as f:
|
||||
data = json.load(f)
|
||||
@ -139,7 +143,10 @@ async def blackjackLoop(channel,gameRound,gameID):
|
||||
logThis("Loop "+str(gameRound)+" calling blackjackLoop()",str(channel))
|
||||
await blackjackLoop(channel,gameRound+1,gameID)
|
||||
else:
|
||||
new_message = blackjackFinish(str(channel))
|
||||
try:
|
||||
new_message = blackjackFinish(str(channel))
|
||||
except:
|
||||
logThis("Something fucked up (error code 1310)")
|
||||
await channel.send(new_message)
|
||||
else:
|
||||
logThis("Ending loop on round "+str(gameRound),str(channel))
|
||||
@ -216,7 +223,12 @@ async def parseCommands(message,content):
|
||||
# Looks up a spell with the spellFunc function from funcs/lookup/lookuppy
|
||||
elif content.startswith("spell "):
|
||||
try:
|
||||
await message.channel.send(spellFunc(cap(content.replace("spell",""))))
|
||||
spell = spellFunc(cap(content.replace("spell","")))
|
||||
if len(spell) > 2000:
|
||||
await message.channel.send(spell[:2000])
|
||||
await message.channel.send(spell[2000:])
|
||||
else:
|
||||
await message.channel.send(spell)
|
||||
except:
|
||||
logThis("Something fucked up (error code 500)",str(message.channel))
|
||||
await message.channel.send("Something fucked up (error code 500)")
|
||||
@ -282,7 +294,8 @@ async def parseCommands(message,content):
|
||||
# funcs/gwendolynpy
|
||||
elif content.startswith("image"):
|
||||
try:
|
||||
await message.channel.send(imageFunc())
|
||||
randomImage = imageFunc()
|
||||
await message.channel.send(randomImage)
|
||||
except:
|
||||
logThis("Something fucked up (error code 700)",str(message.channel))
|
||||
await message.channel.send("Something fucked up (error code 700)")
|
||||
@ -290,19 +303,22 @@ async def parseCommands(message,content):
|
||||
# Sends information about a random movie with the movieFunc function from
|
||||
# funcs/other/movie.py
|
||||
elif content.startswith("movie"):
|
||||
try:
|
||||
async with message.channel.typing():
|
||||
title, plot, cover, cast = movieFunc()
|
||||
if title == "error":
|
||||
await message.channel.send("An error occurred. Try again (error code "+plot+")")
|
||||
else:
|
||||
#try:
|
||||
async with message.channel.typing():
|
||||
title, plot, cover, cast = movieFunc()
|
||||
if title == "error":
|
||||
await message.channel.send("An error occurred. Try again (error code "+plot+")")
|
||||
else:
|
||||
try:
|
||||
embed = discord.Embed(title=title, description=plot, color=0x24ec19)
|
||||
embed.set_thumbnail(url=cover)
|
||||
embed.add_field(name="Cast", value=cast,inline = True)
|
||||
await message.channel.send(embed = embed)
|
||||
except:
|
||||
logThis("Something fucked up (error code 800)",str(message.channel))
|
||||
await message.channel.send("Something fucked up (error code 800)")
|
||||
except:
|
||||
logThis("Error embedding (error code 805)")
|
||||
#except:
|
||||
# logThis("Something fucked up (error code 800)",str(message.channel))
|
||||
# await message.channel.send("Something fucked up (error code 800)")
|
||||
|
||||
# Generates a random name with the nameGen function from funcs/other/generators.py
|
||||
elif content.startswith("name"):
|
||||
@ -564,8 +580,7 @@ async def parseCommands(message,content):
|
||||
logThis("Hit calling blackjackLoop()",str(message.channel))
|
||||
await blackjackLoop(message.channel,int(response[7:])+1,gameID)
|
||||
except:
|
||||
logThis("Something fucked up")
|
||||
await message.channel.send("something fucked up",str(message.channel))
|
||||
logThis("Something fucked up",str(message.channel))
|
||||
else:
|
||||
await message.channel.send(response)
|
||||
|
||||
|
Reference in New Issue
Block a user