From 48f17191a26b9a6575fd6d9af5013d4ac67dc9f7 Mon Sep 17 00:00:00 2001 From: io mintz Date: Thu, 3 Jun 2021 07:46:59 +0000 Subject: [PATCH] fix internal errors when passing an invalid converter to export and list --- utils/converter.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/utils/converter.py b/utils/converter.py index ac8d02a..9de0820 100644 --- a/utils/converter.py +++ b/utils/converter.py @@ -14,9 +14,9 @@ # along with Emote Manager. If not, see . import functools +from discord.ext.commands import BadArgument _emote_type_predicates = { - '': lambda _: True, # allow usage as a "consume rest" converter 'all': lambda _: True, 'static': lambda e: not e.animated, 'animated': lambda e: e.animated} @@ -28,7 +28,10 @@ def emote_type_filter_default(command): @functools.wraps(old_callback) async def callback(self, ctx, *args): image_type = args[-1] - image_type = _emote_type_predicates[image_type] + try: + image_type = _emote_type_predicates[image_type] + except KeyError: + raise BadArgument(f'Invalid emote type. Specify one of "all", "static", or "animated".') return await old_callback(self, ctx, *args[:-1], image_type) command.callback = callback