From cf48e7c9463c26f390d72c48bdfd50c94cb2836c Mon Sep 17 00:00:00 2001 From: victormylle Date: Thu, 19 Nov 2020 12:11:11 +0100 Subject: [PATCH] fixed playerlink issue --- cogs/playerlink.py | 11 +++++++++++ cogs/quiz.py | 4 ---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/cogs/playerlink.py b/cogs/playerlink.py index 27e5e67..fd1616f 100755 --- a/cogs/playerlink.py +++ b/cogs/playerlink.py @@ -24,6 +24,8 @@ class PlayerError(Exception): pass class WrongCodeError(Exception): pass +class TimerExpiredError(Exception): + pass def get_player_uuid(minecraftname): HOST = '192.168.1.214' # The server's hostname or IP address @@ -91,6 +93,9 @@ class PlayerLink(commands.Cog): if isinstance(error, WrongCodeError): embed.add_field(name="Error", value=f"The code is wrong!", inline=False) embed.colour = discord.Colour.red() + elif isinstance(error, TimerExpiredError): + embed.colour = discord.Colour.red() + embed.add_field(name="Timer", value=f"The timer expired!", inline=False) elif (success == True): embed.add_field(name="Success", value=f"The link was successfull!", inline=False) embed.colour = discord.Colour.green() @@ -116,6 +121,7 @@ class PlayerLink(commands.Cog): asyncio.create_task(message.edit(embed=create_embed(ctx.author, arg, timer))) await asyncio.sleep(1) + message = None try: @@ -151,6 +157,11 @@ class PlayerLink(commands.Cog): except PlayerError: await ctx.send("Player '" + arg + "' not found") + except asyncio.TimeoutError: + if message != None: + await message.edit(embed=create_embed(ctx.author, arg, timer, TimerExpiredError())) + + # except: # await ctx.send("Something went wrong") diff --git a/cogs/quiz.py b/cogs/quiz.py index 2891886..8f8dbc5 100755 --- a/cogs/quiz.py +++ b/cogs/quiz.py @@ -246,10 +246,6 @@ class Quiz(commands.Cog): playerdblinker = PlayerDBLinker() linked = playerdblinker.discordidused(message.author.id) await message.channel.send(embed=self.create_answer_embed(question[1], question[2], question[3] * streak, streak, message.author, linked, True)) - - if streak > 1: - await message.channel.send(f"{message.author.mention} has a streak going of {streak}") - playerdblinker.close() except asyncio.TimeoutError: self.reset_current_streak()