From adcfefa57f8d4b82386d655cb816d669d29ff48f Mon Sep 17 00:00:00 2001 From: Satyam Sagar Date: Mon, 10 Oct 2022 23:58:55 +0530 Subject: [PATCH 1/2] added horoscope command --- cogs/fun.py | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/cogs/fun.py b/cogs/fun.py index bffeda9..ac3abaf 100644 --- a/cogs/fun.py +++ b/cogs/fun.py @@ -1,8 +1,37 @@ import discord from discord.ext import commands import random +import requests +from datetime import datetime +def get_zodiac(date, month): + if month == 12: + astro_sign = 'sagittarius' if (date < 22) else 'capricorn' + elif month == 1: + astro_sign = 'capricorn' if (date < 20) else 'aquarius' + elif month == 2: + astro_sign = 'aquarius' if (date < 19) else 'pisces' + elif month == 3: + astro_sign = 'pisces' if (date < 21) else 'aries' + elif month == 4: + astro_sign = 'aries' if (date < 20) else 'taurus' + elif month == 5: + astro_sign = 'taurus' if (date < 21) else 'gemini' + elif month == 6: + astro_sign = 'gemini' if (date < 21) else 'cancer' + elif month == 7: + astro_sign = 'cancer' if (date < 23) else 'leo' + elif month == 8: + astro_sign = 'leo' if (date < 23) else 'virgo' + elif month == 9: + astro_sign = 'virgo' if (date < 23) else 'libra' + elif month == 10: + astro_sign = 'libra' if (date < 23) else 'scorpio' + elif month == 11: + astro_sign = 'scorpio' if (date < 22) else 'sagittarius' + return astro_sign + class Fun(commands.Cog): def __init__(self, client): self.client = client @@ -36,5 +65,32 @@ async def _8ball(self, ctx, *, question): colour=discord.Colour.blurple())) + @commands.command(help='', name='horoscope') + async def horoscope(self, ctx): + dob = ctx.message.author.created_at + date = dob.day + month = dob.month + zodiac = get_zodiac(date, month) + # print(date, month, zodiac) + params = ( + ('sign', zodiac), + ('day', 'today'), + ) + + content = requests.post('https://aztro.sameerkumar.website/', params=params) + content = content.json() + + embed = discord.Embed(title=f"Horoscope: {zodiac.capitalize()}", description=f"{content['description']}", color=discord.Colour.blue()) + embed.add_field(name="Compatibility", value=f"{content['compatibility']}", inline=True) + embed.add_field(name="Mood", value=f"{content['mood']}", inline=True) + embed.add_field(name="Color", value=f"{content['color']}", inline=False) + embed.add_field(name="Lucky Number", value=f"{content['lucky_number']}", inline=True) + embed.add_field(name="Lucky Time", value=f"{content['lucky_time']}", inline=True) + + embed.set_footer(text=f"Requested by {ctx.message.author.display_name}") + embed.timestamp = datetime.utcnow() + + await ctx.send(embed=embed) + async def setup(client): await client.add_cog(Fun(client)) From bd38a4c22b3cc16f25d40f534c4280b67db57a04 Mon Sep 17 00:00:00 2001 From: Satyam Sagar Date: Tue, 11 Oct 2022 01:14:37 +0530 Subject: [PATCH 2/2] added help statement and changed embed color to blurple --- cogs/fun.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cogs/fun.py b/cogs/fun.py index ac3abaf..44d68c0 100644 --- a/cogs/fun.py +++ b/cogs/fun.py @@ -65,7 +65,7 @@ async def _8ball(self, ctx, *, question): colour=discord.Colour.blurple())) - @commands.command(help='', name='horoscope') + @commands.command(name='horoscope', help='Get your horoscope for today based on your *discord birthday*') async def horoscope(self, ctx): dob = ctx.message.author.created_at date = dob.day @@ -80,7 +80,7 @@ async def horoscope(self, ctx): content = requests.post('https://aztro.sameerkumar.website/', params=params) content = content.json() - embed = discord.Embed(title=f"Horoscope: {zodiac.capitalize()}", description=f"{content['description']}", color=discord.Colour.blue()) + embed = discord.Embed(title=f"Horoscope: {zodiac.capitalize()}", description=f"{content['description']}", color=discord.Colour.blurple()) embed.add_field(name="Compatibility", value=f"{content['compatibility']}", inline=True) embed.add_field(name="Mood", value=f"{content['mood']}", inline=True) embed.add_field(name="Color", value=f"{content['color']}", inline=False)