Skip to content

Commit

Permalink
feat: birthday task functional
Browse files Browse the repository at this point in the history
  • Loading branch information
Zalk0 committed Apr 5, 2024
1 parent 9571e64 commit ab6dc56
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
Empty file removed data/birthdays.toml
Empty file.
30 changes: 12 additions & 18 deletions tasks.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
from __future__ import annotations

from datetime import time
from datetime import date, time
from typing import TYPE_CHECKING

from discord.ext import tasks
from zoneinfo import ZoneInfo

from utils import birthdays

if TYPE_CHECKING:
from bot import ChouetteBot

TIMEZONE = ZoneInfo("localtime")


async def tasks_list(client: ChouetteBot):
# Loop to send message every 2 hours for pokeroll
Expand All @@ -20,24 +25,13 @@ async def poke_ping():
await client.get_channel(int(client.config["POKE_CHANNEL"])).send(msg_poke)

# Loop to check if it's 8:00 and send a message if it's someone's birthday
@tasks.loop(hours=24)
@tasks.loop(time=time(8, tzinfo=TIMEZONE))
async def check_birthdays():
<<<<<<< HEAD
now = time.now()
if now.hour == 8 and now.minute == 0:
today = now.strftime("%d/%m")
for user_id, birthday in birthdays.items():
if birthday == today:
user = await bot.fetch_user(int(user_id))
msg_birthday = f":tada: {user.mention} is a year older now! Wish them a happy birthday! :tada:"
await client.get_channel(int(client.config["BIRTHDAY_CHANNEL"])).send(
msg_birthday
)
=======
user = "todo"
msg_birthday = f"\N{PARTY POPPER} {user.mention} is a year older now! Wish them a happy birthday! \N{PARTY POPPER}"
await client.get_channel(int(client.config["BIRTHDAY_CHANNEL"])).send(msg_birthday)
>>>>>>> 3435db9 (fix birthday commands)
for user_id, birthday in birthdays.load_birthdays():
if birthday == date.today():
user = client.get_user(user_id)
msg_birthday = f"\N{PARTY POPPER} {user.mention} is a year older now! Wish them a happy birthday! \N{PARTY POPPER}"
await client.get_channel(int(client.config["BIRTHDAY_CHANNEL"])).send(msg_birthday)

# Start loop
poke_ping.start()
Expand Down

0 comments on commit ab6dc56

Please sign in to comment.