mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-08 12:18:54 -05:00
Merge pull request #4325 from zephyrkul/patch-1
[customcom] Gracefully handle timeouts in cc edit
This commit is contained in:
commit
b0250b91cc
@ -39,6 +39,10 @@ class OnCooldown(CCError):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class CommandNotEdited(CCError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class CommandObj:
|
class CommandObj:
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
self.config = kwargs.get("config")
|
self.config = kwargs.get("config")
|
||||||
@ -164,9 +168,9 @@ class CommandObj:
|
|||||||
pred = MessagePredicate.yes_or_no(ctx)
|
pred = MessagePredicate.yes_or_no(ctx)
|
||||||
try:
|
try:
|
||||||
await self.bot.wait_for("message", check=pred, timeout=30)
|
await self.bot.wait_for("message", check=pred, timeout=30)
|
||||||
except TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
await ctx.send(_("Response timed out, please try again later."))
|
await ctx.send(_("Response timed out, please try again later."))
|
||||||
return
|
raise CommandNotEdited()
|
||||||
if pred.result is True:
|
if pred.result is True:
|
||||||
response = await self.get_responses(ctx=ctx)
|
response = await self.get_responses(ctx=ctx)
|
||||||
else:
|
else:
|
||||||
@ -175,9 +179,9 @@ class CommandObj:
|
|||||||
resp = await self.bot.wait_for(
|
resp = await self.bot.wait_for(
|
||||||
"message", check=MessagePredicate.same_context(ctx), timeout=180
|
"message", check=MessagePredicate.same_context(ctx), timeout=180
|
||||||
)
|
)
|
||||||
except TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
await ctx.send(_("Response timed out, please try again later."))
|
await ctx.send(_("Response timed out, please try again later."))
|
||||||
return
|
raise CommandNotEdited()
|
||||||
response = resp.content
|
response = resp.content
|
||||||
|
|
||||||
if response:
|
if response:
|
||||||
@ -448,6 +452,8 @@ class CustomCommands(commands.Cog):
|
|||||||
)
|
)
|
||||||
except ArgParseError as e:
|
except ArgParseError as e:
|
||||||
await ctx.send(e.args[0])
|
await ctx.send(e.args[0])
|
||||||
|
except CommandNotEdited:
|
||||||
|
pass
|
||||||
|
|
||||||
@customcom.command(name="list")
|
@customcom.command(name="list")
|
||||||
@checks.bot_has_permissions(add_reactions=True)
|
@checks.bot_has_permissions(add_reactions=True)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user