Example #1
0
    async def test_handle_input_error_handler_errors(self):
        """Should handle each error probably."""
        test_cases = ({
            "error": errors.MissingRequiredArgument(MagicMock()),
            "call_prepared": True
        }, {
            "error": errors.TooManyArguments(),
            "call_prepared": True
        }, {
            "error": errors.BadArgument(),
            "call_prepared": True
        }, {
            "error":
            errors.BadUnionArgument(MagicMock(), MagicMock(), MagicMock()),
            "call_prepared":
            True
        }, {
            "error": errors.ArgumentParsingError(),
            "call_prepared": False
        }, {
            "error": errors.UserInputError(),
            "call_prepared": True
        })

        for case in test_cases:
            with self.subTest(error=case["error"],
                              call_prepared=case["call_prepared"]):
                self.ctx.reset_mock()
                self.assertIsNone(await self.cog.handle_user_input_error(
                    self.ctx, case["error"]))
                self.ctx.send.assert_awaited_once()
                if case["call_prepared"]:
                    self.ctx.send_help.assert_awaited_once()
                else:
                    self.ctx.send_help.assert_not_awaited()
Example #2
0
 async def default(self, ctx, param):
     async for message in utils.CachedHistoryIterator(ctx, limit=100):
         for embed in message.embeds:
             if embed.thumbnail and embed.thumbnail.proxy_url:
                 return embed.thumbnail.proxy_url
         for attachment in message.attachments:
             if attachment.proxy_url:
                 return attachment.proxy_url
     raise errors.MissingRequiredArgument(param)
Example #3
0
 async def default(self, ctx, param):
     if not ctx.guild:
         raise errors.MissingRequiredArgument(param)
     return ctx.guild