async def test_handle_check_failure_errors(self): """Should await `ctx.send` when error is check failure.""" test_cases = ({ "error": errors.BotMissingPermissions(MagicMock()), "call_ctx_send": True }, { "error": errors.BotMissingRole(MagicMock()), "call_ctx_send": True }, { "error": errors.BotMissingAnyRole(MagicMock()), "call_ctx_send": True }, { "error": errors.NoPrivateMessage(), "call_ctx_send": True }, { "error": InWhitelistCheckFailure(1234), "call_ctx_send": True }, { "error": ResponseCodeError(MagicMock()), "call_ctx_send": False }) for case in test_cases: with self.subTest(error=case["error"], call_ctx_send=case["call_ctx_send"]): self.ctx.reset_mock() await self.cog.handle_check_failure(self.ctx, case["error"]) if case["call_ctx_send"]: self.ctx.send.assert_awaited_once() else: self.ctx.send.assert_not_awaited()
async def user_info(self, ctx: Context, user: Member = None) -> None: """Returns info about a user.""" if user is None: user = ctx.author # Do a role check if this is being executed on someone other than the caller elif user != ctx.author and not with_role_check(ctx, *constants.MODERATION_ROLES): await ctx.send("You may not use this command on users other than yourself.") return # Non-staff may only do this in #bot-commands if not with_role_check(ctx, *constants.STAFF_ROLES): if not ctx.channel.id == constants.Channels.bot_commands: raise InWhitelistCheckFailure(constants.Channels.bot_commands) embed = await self.create_user_embed(ctx, user) await ctx.send(embed=embed)