blob: ef9ddc78f48167a3b1e0557f8de1842e9f93b63e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
import logging
import random
from json import load
from pathlib import Path
import discord
from discord.ext import commands
from bot.constants import Colours
log = logging.getLogger(__name__)
LETTER_EMOJI = ':love_letter:'
HEART_EMOJIS = [":heart:", ":gift_heart:", ":revolving_hearts:", ":sparkling_heart:", ":two_hearts:"]
class ValentineZodiac(commands.Cog):
"""A Cog that returns a counter compatible zodiac sign to the given user's zodiac sign."""
def __init__(self, bot: commands.Bot):
self.bot = bot
self.zodiacs = self.load_json()
@staticmethod
def load_json() -> dict:
"""Load zodiac compatibility from static JSON resource."""
p = Path("bot/resources/valentines/zodiac_compatibility.json")
with p.open(encoding="utf8") as json_data:
zodiacs = load(json_data)
return zodiacs
@commands.command(name="partnerzodiac")
async def counter_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.")
emoji1 = random.choice(HEART_EMOJIS)
emoji2 = random.choice(HEART_EMOJIS)
embed = discord.Embed(
title="Zodic Compatibility",
description=f'{zodiac_sign.capitalize()}{emoji1}{compatible_zodiac["Zodiac"]}\n'
f'{emoji2}Compatibility meter : {compatible_zodiac["compatibility_score"]}{emoji2}',
color=Colours.pink
)
embed.add_field(
name=f'A letter from Dr.Zodiac {LETTER_EMOJI}',
value=compatible_zodiac['description']
)
await ctx.send(embed=embed)
def setup(bot: commands.Bot) -> None:
"""Valentine zodiac Cog load."""
bot.add_cog(ValentineZodiac(bot))
|