def _get_preset(preset_json: dict) -> VersionedPreset: try: preset = VersionedPreset(preset_json) preset.get_preset() # test if valid return preset except Exception as e: raise InvalidAction(f"invalid preset: {e}")
async def reply_for_preset(message: discord.Message, versioned_preset: VersionedPreset): try: preset = versioned_preset.get_preset() except ValueError as e: logging.info("Invalid preset '{}' from {}: {}".format(versioned_preset.name, message.author.display_name, e)) return embed = discord.Embed(title=preset.name, description=preset.description) _add_preset_description_to_embed(embed, preset) await message.reply(embed=embed, mention_author=False)