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.
pull/193/head
Brad Duncan 4 years ago
parent b752bfd153
commit 1d514f80c6

@ -32,6 +32,7 @@ class RecyclingPlant(Cog):
x = 0 x = 0
reward = 0 reward = 0
timeoutcount = 0
await ctx.send( await ctx.send(
"{0} has signed up for a shift at the Recycling Plant! Type ``exit`` to terminate it early.".format( "{0} has signed up for a shift at the Recycling Plant! Type ``exit`` to terminate it early.".format(
ctx.author.display_name ctx.author.display_name
@ -53,7 +54,7 @@ class RecyclingPlant(Cog):
return m.author == ctx.author and m.channel == ctx.channel return m.author == ctx.author and m.channel == ctx.channel
try: 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: except asyncio.TimeoutError:
answer = None answer = None

Loading…
Cancel
Save