converted hangman to buttons

This commit is contained in:
NikolajDanger
2021-08-19 13:12:15 +02:00
parent 3819e56cd6
commit 98988efa4b
8 changed files with 266 additions and 250 deletions

View File

@ -24,11 +24,6 @@ class DatabaseFuncs():
wipe_games()
connect_four_reaction_test(message: discord.Message,
user: discord.User) -> bool
hangman_reaction_test(message: discord.Message,
user: discord.User) -> bool
plex_reaction_test(message: discord.Message,
user: discord.User) -> bool, bool,
list
imdb_commands()
"""
@ -111,8 +106,7 @@ class DatabaseFuncs():
game_types = [
"trivia questions",
"blackjack games",
"connect 4 games",
"hangman games",
"connect 4 games"
"hex games"
]
for game_type in game_types:
@ -163,48 +157,6 @@ class DatabaseFuncs():
return valid_reaction
def hangman_reaction_test(self, message: discord.Message,
user: discord.User):
"""
Test if the given message is the current hangman game.
Also tests if the given user is the one who's playing hangman.
*Parameters*
------------
message: discord.Message
The message to test.
user: discord.User
The user to test.
*Returns*
---------
: bool
Whether the given message is the current hangman game
and if the user who reacted is the user who's playing
hangman.
"""
channel = message.channel
file_path = f"gwendolyn/resources/games/old_images/hangman{channel.id}"
if os.path.isfile(file_path):
with open(file_path, "r") as file_pointer:
old_messages = file_pointer.read().splitlines()
else:
return False
game_message = False
for old_message in old_messages:
old_message_id = int(old_message)
if message.id == old_message_id:
database = self.bot.database["hangman games"]
channel_search = {"_id": str(channel.id)}
game = database.find_one(channel_search)
if user == game["player"]:
game_message = True
break
return game_message
async def imdb_commands(self):
"""Sync the slash commands with the discord API."""
collection = self.bot.database["last synced"]