diff --git a/announcedaily/__init__.py b/announcedaily/__init__.py index 8cc69d5..f1db8c0 100644 --- a/announcedaily/__init__.py +++ b/announcedaily/__init__.py @@ -6,4 +6,4 @@ from .announcedaily import AnnounceDaily def setup(bot: Red): daily = AnnounceDaily(bot) bot.add_cog(daily) - bot.loop.create_task(daily.check_day()) + daily.announce_task = bot.loop.create_task(daily.check_day()) diff --git a/announcedaily/announcedaily.py b/announcedaily/announcedaily.py index aa50e6c..fb31b89 100644 --- a/announcedaily/announcedaily.py +++ b/announcedaily/announcedaily.py @@ -1,6 +1,8 @@ import asyncio import random +from asyncio import Task from datetime import datetime, timedelta +from typing import Optional import discord from redbot.core import Config, checks, commands @@ -38,10 +40,16 @@ class AnnounceDaily(Cog): self.config.register_global(**default_global) self.config.register_guild(**default_guild) + self.announce_task = None + async def red_delete_data_for_user(self, **kwargs): """Nothing to delete""" return + def __unload(self): + if self.announce_task is not None: + self.announce_task.cancel() + async def _get_msgs(self): return DEFAULT_MESSAGES + await self.config.messages()