diff options
| -rw-r--r-- | bot/cogs/reddit.py | 7 | 
1 files changed, 4 insertions, 3 deletions
diff --git a/bot/cogs/reddit.py b/bot/cogs/reddit.py index 5a7fa100f..7f0ba98d2 100644 --- a/bot/cogs/reddit.py +++ b/bot/cogs/reddit.py @@ -10,6 +10,7 @@ from aiohttp import BasicAuth, ClientError  from discord import Colour, Embed, TextChannel  from discord.ext.commands import Cog, Context, group  from discord.ext.tasks import loop +from discord.utils import sleep_until  from bot.bot import Bot  from bot.constants import Channels, ERROR_REPLIES, Emojis, Reddit as RedditConfig, STAFF_ROLES, Webhooks @@ -200,13 +201,13 @@ class Reddit(Cog):      @loop()      async def auto_poster_loop(self) -> None:          """Post the top 5 posts daily, and the top 5 posts weekly.""" -        # once we upgrade to d.py 1.3 this can be removed and the loop can use the `time=datetime.time.min` parameter +        # once d.py get support for `time` parameter in loop decorator, +        # this can be removed and the loop can use the `time=datetime.time.min` parameter          now = datetime.utcnow()          tomorrow = now + timedelta(days=1)          midnight_tomorrow = tomorrow.replace(hour=0, minute=0, second=0) -        seconds_until = (midnight_tomorrow - now).total_seconds() -        await asyncio.sleep(seconds_until) +        await sleep_until(midnight_tomorrow)          await self.bot.wait_until_guild_available()          if not self.webhook:  |