-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathcog.py
39 lines (29 loc) · 1.25 KB
/
cog.py
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
"""
Cog containing information about week (odd/even) and its relation to calendar/academic week.
"""
from datetime import date
import disnake
from disnake.ext import commands
import utils
from cogs.base import Base
from rubbergod import Rubbergod
from utils import cooldowns
from .messages_cz import MessagesCZ
class Week(Base, commands.Cog):
def __init__(self, bot: Rubbergod):
super().__init__()
self.bot = bot
@cooldowns.default_cooldown
@commands.slash_command(name="week", description=MessagesCZ.week_brief)
async def week(self, inter: disnake.ApplicationCommandInteraction):
"""See if the current week is odd or even"""
cal_week = date.today().isocalendar()[1]
stud_week = (cal_week - self.config.starting_week) % 52
even, odd = "sudý", "lichý"
cal_type = even if cal_week % 2 == 0 else odd
embed = disnake.Embed(title="Týden", color=0xE5DC37)
embed.add_field(name="Studijní", value=stud_week)
embed.add_field(name="Kalendářní", value=f"{cal_type} ({cal_week})")
embed.add_field(name="Poznámka", value=MessagesCZ.week_warning, inline=False)
utils.embed.add_author_footer(embed, inter.author)
await inter.response.send_message(embed=embed)