diff options
author | 2020-04-02 13:23:18 +0300 | |
---|---|---|
committer | 2020-04-02 13:23:18 +0300 | |
commit | a4a4b987dd0d042e5d4272782c520c53d804470c (patch) | |
tree | b81a1df35b827b25b741c8a34481508c02fd63f0 | |
parent | (Off-Topic Names, discord.py 1.3.x Migration): Replaced `asyncio.sleep` with ... (diff) |
(Reddit, discord.py 1.3.x Migration): Replaced `asyncio.sleep` with `discord.utils.sleep_until`
-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: |