Fully converted to slash commands

This commit is contained in:
NikolajDanger
2021-03-31 00:38:51 +02:00
parent a8a7e5eabd
commit b345720468
50 changed files with 1102 additions and 1111 deletions

View File

@ -1,7 +1,6 @@
import json, urllib, datetime, string
from .hangmanDraw import DrawHangman
from funcs import logThis
apiUrl = "https://api.wordnik.com/v4/words.json/randomWords?hasDictionaryDef=true&minCorpusCount=5000&maxCorpusCount=-1&minDictionaryCount=1&maxDictionaryCount=-1&minLength=3&maxLength=11&limit=1&api_key="
@ -19,7 +18,7 @@ class Hangman():
while "-" in word or "." in word:
with urllib.request.urlopen(apiUrl+apiKey) as p:
word = list(json.load(p)[0]["word"].upper())
logThis("Found the word \""+"".join(word)+"\"")
self.bot.log("Found the word \""+"".join(word)+"\"", level = 10)
guessed = [False] * len(word)
gameID = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
newGame = {"_id":channel,"player" : user,"guessed letters" : [],"word" : word,"game ID" : gameID,"misses" : 0,"guessed" : guessed}
@ -30,8 +29,8 @@ class Hangman():
try:
self.draw.drawImage(channel)
except:
logThis("Error drawing image (error code 1710)")
return f"{self.bot.funcs.getName(user)} started game of hangman.", True, False, remainingLetters
self.bot.log("Error drawing image (error code 1710)")
return f"{self.bot.databaseFuncs.getName(user)} started game of hangman.", True, False, remainingLetters
else:
return "There's already a Hangman game going on in the channel", False, False, []
@ -74,7 +73,7 @@ class Hangman():
try:
self.draw.drawImage(channel)
except:
logThis("Error drawing image (error code 1710)")
self.bot.log("Error drawing image (error code 1710)")
if game["misses"] == 6:
self.hangmanStop(channel)
@ -99,7 +98,7 @@ class Hangman():
try:
return self.hangmanStart(channel,user)
except:
logThis("Error starting game (error code 1730)")
self.bot.log("Error starting game (error code 1730)")
elif command == "stop":
return self.hangmanStop(channel)
elif command.startswith("guess "):
@ -107,6 +106,6 @@ class Hangman():
try:
return self.hangmanGuess(channel,user,guess)
except:
logThis("Error in guessing (Error Code 1720)")
self.bot.log("Error in guessing (Error Code 1720)")
else:
return "I didn't understand that", False, False, []