mirror of
https://github.com/UiO-Gaming/mustafa.git
synced 2026-11-05 13:56:48 +01:00
replace sleep until midnight util with built in util
This commit is contained in:
5 files changed
+7
-21
No files matched your search
@@ -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.*
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in new issue
Block a user