Check for unload and cancel announce task properly.
This commit is contained in:
parent
477364f9bf
commit
70f4b0b716
@ -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())
|
||||
|
@ -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()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user