From 1d514f80c696e0b7170cbf168a86862747fab540 Mon Sep 17 00:00:00 2001 From: Brad Duncan <51077147+XargsUK@users.noreply.github.com> Date: Thu, 8 Jul 2021 07:37:37 +0100 Subject: [PATCH] adding no response exit condition Previously, if no response was provided by the user, the function would continuously loop. I've modified the timeout to 20 seconds. When there's no response, +! to timeoutcount variable. When there's been 3 timeouts, break. --- recyclingplant/recyclingplant.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/recyclingplant/recyclingplant.py b/recyclingplant/recyclingplant.py index cc7bf57..2bf0753 100644 --- a/recyclingplant/recyclingplant.py +++ b/recyclingplant/recyclingplant.py @@ -32,6 +32,7 @@ class RecyclingPlant(Cog): x = 0 reward = 0 + timeoutcount = 0 await ctx.send( "{0} has signed up for a shift at the Recycling Plant! Type ``exit`` to terminate it early.".format( ctx.author.display_name @@ -53,7 +54,7 @@ class RecyclingPlant(Cog): return m.author == ctx.author and m.channel == ctx.channel try: - answer = await self.bot.wait_for("message", timeout=120, check=check) + answer = await self.bot.wait_for("message", timeout=20, check=check) except asyncio.TimeoutError: answer = None