async def call_of_cthulhu_check(self, ctx: Context, *arguments: str) -> None: command_prefix: str = ctx.prefix + ctx.invoked_with skill_result = check_skill(ctx.author.name, command_prefix, arguments) discord_result = crate_embed(skill_result, ctx.message, SIMPLE_PRESENTATION) await self._send_message(ctx, discord_result, skill_result)
async def tales_from_the_loop_check(self, ctx: Context, *arguments: str) -> None: command_prefix: str = ctx.prefix + ctx.invoked_with roll_result = overcome_trouble_check(ctx.author.name, command_prefix, arguments) discord_result = crate_embed(roll_result, ctx.message, SIMPLE_PRESENTATION) await self._send_message(ctx, discord_result, roll_result)
async def info(self, ctx: Context) -> None: logging.info('Received info command') message: str = ( 'Author: **bonczeq**\n' 'Please check [GitHub project page](https://github.com/bonczeq/FateOfDice/blob/master/README.md)' ) discord_result = crate_embed(message) await ctx.send(**discord_result)
def test_string(self): description: str = "testDescription" result = crate_embed(description) self.assertTrue('embed' in result) embed = result.get('embed') self.assertEqual(embed.colour.value, 0xff00a2) self.assertEqual(embed.description, description)
def test_dice_exception(self): error = DiceException("testDescription") result = crate_embed(error) self.assertTrue('embed' in result) embed = result.get('embed') self.assertEqual(embed.colour.value, 0xae6229) self.assertEqual(embed.description, str(error))
def test_exception(self): error = Exception("testDescription") result = crate_embed(error) self.assertTrue('embed' in result) embed = result.get('embed') self.assertEqual(embed.title, 'Error') self.assertEqual(embed.description, str(error))
def test_roll_result(self): descriptions = ["testDescription1", "testDescription2"] result = RollResult(descriptions=descriptions) message = MockMessage() result = crate_embed(result, message, False) self.assertTrue('embed' in result) embed = result.get('embed') self.assertEqual(embed.colour.value, 0x4dd5d3) for description, field in zip(descriptions, embed.fields): self.assertRegex(str(field), description)
def test_action_check_result(self): descriptions = ["testDescription1", "testDescription2"] result_type = ActionCheckResultType.FAILURE result = ActionCheckResult(descriptions=descriptions, type=result_type) message = MockMessage() result = crate_embed(result, message, False) self.assertTrue('embed' in result) embed = result.get('embed') self.assertEqual(embed.title, result_type.title) self.assertEqual(embed.colour.value, result_type.colour) for description, field in zip(descriptions, embed.fields): self.assertRegex(str(field), description)
def test_overcome_trouble_result(self): descriptions = ["testDescription1", "testDescription2"] result_type = OvercomeTroubleResultType.SUCCESS result = OvercomeTroubleResult(descriptions=descriptions, type=result_type) message = MockMessage() result = crate_embed(result, message, False) self.assertTrue('embed' in result) embed = result.get('embed') self.assertEqual(embed.title, result_type.title) self.assertEqual(embed.colour.value, result_type.colour) for description, field in zip(descriptions, embed.fields): self.assertRegex(str(field), description)
async def alien_check(self, ctx: Context, *arguments: str) -> None: command_prefix: str = ctx.prefix + ctx.invoked_with check_result = check_action(ctx.author.name, command_prefix, arguments) discord_result = crate_embed(check_result, ctx.message, SIMPLE_PRESENTATION) await self._send_message(ctx, discord_result, check_result)
async def universal_roll(self, ctx: Context, *arguments: str) -> None: command_prefix: str = ctx.prefix + ctx.invoked_with roll_result = roll(ctx.author.name, command_prefix, arguments) discord_result = crate_embed(roll_result, ctx.message, SIMPLE_PRESENTATION) await self._send_message(ctx, discord_result, roll_result)
async def on_command_error(ctx, error): original = error if hasattr(error, 'original'): original = error.original await ctx.send(**crate_embed(original))