mirror of
https://github.com/uhIgnacio/EmoteManager.git
synced 2024-08-15 02:23:13 +00:00
fix internal errors when passing an invalid converter to export and list
This commit is contained in:
parent
c1592969d5
commit
48f17191a2
1 changed files with 5 additions and 2 deletions
|
@ -14,9 +14,9 @@
|
||||||
# along with Emote Manager. If not, see <https://www.gnu.org/licenses/>.
|
# along with Emote Manager. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import functools
|
import functools
|
||||||
|
from discord.ext.commands import BadArgument
|
||||||
|
|
||||||
_emote_type_predicates = {
|
_emote_type_predicates = {
|
||||||
'': lambda _: True, # allow usage as a "consume rest" converter
|
|
||||||
'all': lambda _: True,
|
'all': lambda _: True,
|
||||||
'static': lambda e: not e.animated,
|
'static': lambda e: not e.animated,
|
||||||
'animated': lambda e: e.animated}
|
'animated': lambda e: e.animated}
|
||||||
|
@ -28,7 +28,10 @@ def emote_type_filter_default(command):
|
||||||
@functools.wraps(old_callback)
|
@functools.wraps(old_callback)
|
||||||
async def callback(self, ctx, *args):
|
async def callback(self, ctx, *args):
|
||||||
image_type = args[-1]
|
image_type = args[-1]
|
||||||
|
try:
|
||||||
image_type = _emote_type_predicates[image_type]
|
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)
|
return await old_callback(self, ctx, *args[:-1], image_type)
|
||||||
|
|
||||||
command.callback = callback
|
command.callback = callback
|
||||||
|
|
Loading…
Reference in a new issue