fix(meta): Catch TransformerError.
This commit is contained in:
@@ -7,7 +7,7 @@ import discord
|
|||||||
from discord.utils import MISSING
|
from discord.utils import MISSING
|
||||||
from discord.ext.commands import Bot, Cog, HybridCommand, HybridCommandError
|
from discord.ext.commands import Bot, Cog, HybridCommand, HybridCommandError
|
||||||
from discord.ext.commands.errors import CommandInvokeError, CheckFailure
|
from discord.ext.commands.errors import CommandInvokeError, CheckFailure
|
||||||
from discord.app_commands.errors import CommandInvokeError as appCommandInvokeError
|
from discord.app_commands.errors import CommandInvokeError as appCommandInvokeError, TransformerError
|
||||||
from aiohttp import ClientSession
|
from aiohttp import ClientSession
|
||||||
|
|
||||||
from data import Database
|
from data import Database
|
||||||
@@ -161,6 +161,17 @@ class LionBot(Bot):
|
|||||||
raise original
|
raise original
|
||||||
except HandledException:
|
except HandledException:
|
||||||
pass
|
pass
|
||||||
|
except TransformerError as e:
|
||||||
|
msg = str(e)
|
||||||
|
if msg:
|
||||||
|
try:
|
||||||
|
await ctx.error_reply(msg)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
logger.debug(
|
||||||
|
f"Caught a transformer error: {repr(e)}",
|
||||||
|
extra={'action': 'BotError', 'with_ctx': True}
|
||||||
|
)
|
||||||
except SafeCancellation:
|
except SafeCancellation:
|
||||||
if original.msg:
|
if original.msg:
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -40,7 +40,10 @@ class DurationTransformer(Transformer):
|
|||||||
duration = parse_duration(value)
|
duration = parse_duration(value)
|
||||||
if duration is None:
|
if duration is None:
|
||||||
raise UserInputError(
|
raise UserInputError(
|
||||||
t(_p('utils:parse_dur|error', "Cannot parse `{value}` as a duration.")).format(
|
t(_p(
|
||||||
|
'utils:parse_dur|error',
|
||||||
|
"Cannot parse `{value}` as a duration."
|
||||||
|
)).format(
|
||||||
value=value
|
value=value
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user