replace sleep until midnight util with built in util

This commit is contained in:
LBlend committed 2024-04-01 20:26:19 +02:00
1 parent d7a76e2ec3
commit 454e865c35
5 files changed
+7 -21

No files matched your search

+1
View File
@@ -14,4 +14,5 @@ pypandoc==1.13.*
pyyaml==6.0.*
regex==2023.12.25
requests==2.31.*
tzdata # This only needed if run on windows. I haven't set a version either to ensure it's up to date.
wordcloud==1.9.*
+1 -1
View File
@@ -47,7 +47,7 @@ class Birthday(commands.Cog):
name="bursdag", description="Se, endre eller fjern bursdager for brukere på serveren"
)
@tasks.loop(hours=24)
@tasks.loop(time=misc_utils.MIDNIGHT)
async def birthday_check(self):
"""
Check if it's someone's birthday every day at midgnight and send a greeting if it is
+1 -1
View File
@@ -102,7 +102,7 @@ class SocialCredit(commands.Cog):
(user_id, self.START_POINTS),
)
@tasks.loop(hours=24.0, reconnect=True)
@tasks.loop(time=misc_utils.MIDNIGHT, reconnect=True)
async def fuck_uwu(self):
"""
Deducts points from people with the weeb role every 24 hours
-19
View File
@@ -37,25 +37,6 @@ async def send_as_txt_file(interaction: discord.Interaction, content: str, file_
pass
async def sleep_until_midnight(bot):
"""
Syncs loop with the time of day
"""
await bot.wait_until_ready()
now = datetime.datetime.now()
if now.hour > 0:
sleep_until = now + datetime.timedelta(days=1)
sleep_until = sleep_until.replace(hour=0, minute=0, second=0, microsecond=0)
else:
sleep_until = now.replace(hour=0, minute=0, second=0, microsecond=0)
bot.logger.info(f"Loop sleeping until {sleep_until}")
await discord.utils.sleep_until(sleep_until)
async def get_file_bytesio(file: discord.Attachment | discord.Asset) -> BytesIO:
"""
Returns a BytesIO object of the file
+4
View File
@@ -1,4 +1,8 @@
import datetime
from math import ceil
from zoneinfo import ZoneInfo
MIDNIGHT = datetime.time(hour=19, minute=48, tzinfo=ZoneInfo("Europe/Oslo"))
class Paginator: