diff options
| author | 2020-09-22 17:44:52 +0530 | |
|---|---|---|
| committer | 2020-09-22 17:44:52 +0530 | |
| commit | 69b17d575deadbcae3dbc07bd156824a263ebdc2 (patch) | |
| tree | cc8bf8ab2e4f32ea41da1ab0a3f8e49f23a10762 /bot/exts | |
| parent | added zodiac sign list (diff) | |
added subcommand zodiac
Diffstat (limited to 'bot/exts')
| -rw-r--r-- | bot/exts/valentines/valentine_zodiac.py | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/bot/exts/valentines/valentine_zodiac.py b/bot/exts/valentines/valentine_zodiac.py index 5d36314d..f4e4ac34 100644 --- a/bot/exts/valentines/valentine_zodiac.py +++ b/bot/exts/valentines/valentine_zodiac.py @@ -17,6 +17,11 @@ zodiac_signs = ["Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", "Libra", "Scorpio", "Sagittarius", "Capricorn", "Aquarius", "Pisces"] +with open(Path("bot/resources/valentines/zodiac_explanation.json"), "r", encoding="utf8") as file: + """Load zodiac zodiac explanation from static JSON resource.""" + zodiac_fact = load(file) + + class ValentineZodiac(commands.Cog): """A Cog that returns a counter compatible zodiac sign to the given user's zodiac sign.""" @@ -32,13 +37,33 @@ class ValentineZodiac(commands.Cog): zodiacs = load(json_data) return zodiacs - @commands.command(name="partnerzodiac") - async def counter_zodiac(self, ctx: commands.Context, zodiac_sign: str) -> None: + def zodiac_sign_verify(self, zodiac: str) -> discord.Embed: + """Gives informative zodiac embed.""" + c_zodiac = zodiac.capitalize() + embed = discord.Embed() + embed.color = Colours.pink + if c_zodiac in zodiac_signs: + log.info("Making zodiac embed") + embed.title = f"__{c_zodiac}__" + embed.description = zodiac_fact[f"{c_zodiac}"]["About"] + embed.add_field(name='__Full form__', value=zodiac_fact[f"{c_zodiac}"]["full_form"], inline=False) + embed.add_field(name='__Motto__', value=zodiac_fact[f"{c_zodiac}"]["Motto"], inline=False) + embed.add_field(name='__Strengths__', value=zodiac_fact[f"{c_zodiac}"]["Strengths"], inline=False) + embed.add_field(name='__Weaknesses__', value=zodiac_fact[f"{c_zodiac}"]["Weaknesses"], inline=False) + embed.set_thumbnail(url=zodiac_fact[f"{c_zodiac}"]["url"]) + else: + embed.description = "Umm you gave wrong zodiac name so i aren't able to find any :sweat_smile:" + log.info("Wrong Zodiac name provided") + return embed + log.info("Zodiac embed ready") + + @commands.group(name="partnerzodiac", invoke_without_command=True) + async def partner_zodiac(self, ctx: commands.Context, zodiac_sign: str) -> None: """Provides a counter compatible zodiac sign to the given user's zodiac sign.""" try: compatible_zodiac = random.choice(self.zodiacs[zodiac_sign.lower()]) except KeyError: - return await ctx.send(zodiac_sign.capitalize() + " zodiac sign does not exist.") + return await ctx.send(f"`{zodiac_sign.capitalize()}` zodiac sign does not exist.") emoji1 = random.choice(HEART_EMOJIS) emoji2 = random.choice(HEART_EMOJIS) @@ -54,6 +79,13 @@ class ValentineZodiac(commands.Cog): ) await ctx.send(embed=embed) + @partner_zodiac.command(name='zodiac') + async def zodiac(self, ctx: commands.Context, zodiac_sign: str) -> None: + """Provides information about zodiac sign by taking zodiac sign name as input.""" + final_embed = self.zodiac_sign_verify(zodiac_sign) + log.info("Embed successfully sent") + await ctx.send(embed=final_embed) + def setup(bot: commands.Bot) -> None: """Valentine zodiac Cog load.""" |