mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
[Mod] Delegate send_to_owners call in initialize() to a task (#3573)
* fix(mod): delegate send_to_owners call in initialize() to a task * enhance(mod): reorder cog's setup()
This commit is contained in:
parent
9a8c134c97
commit
4956e67348
@ -4,5 +4,5 @@ from .mod import Mod
|
||||
|
||||
async def setup(bot: Red):
|
||||
cog = Mod(bot)
|
||||
await cog.initialize()
|
||||
bot.add_cog(cog)
|
||||
await cog.initialize()
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import asyncio
|
||||
from abc import ABC
|
||||
from collections import defaultdict
|
||||
from typing import List, Tuple
|
||||
from abc import ABC
|
||||
|
||||
import discord
|
||||
from redbot.core import Config, modlog, commands
|
||||
@ -77,8 +78,14 @@ class Mod(
|
||||
self.tban_expiry_task = self.bot.loop.create_task(self.check_tempban_expirations())
|
||||
self.last_case: dict = defaultdict(dict)
|
||||
|
||||
self._ready = asyncio.Event()
|
||||
|
||||
async def initialize(self):
|
||||
await self._maybe_update_config()
|
||||
self._ready.set()
|
||||
|
||||
async def cog_before_invoke(self, ctx: commands.Context) -> None:
|
||||
await self._ready.wait()
|
||||
|
||||
def cog_unload(self):
|
||||
self.tban_expiry_task.cancel()
|
||||
@ -102,7 +109,7 @@ class Mod(
|
||||
"Please use `{prefix}moveignoredchannels` if "
|
||||
"you were previously using these functions."
|
||||
).format(prefix=prefixes[0])
|
||||
await self.bot.send_to_owners(msg)
|
||||
self.bot.loop.create_task(self.bot.send_to_owners(msg))
|
||||
await self.settings.version.set(__version__)
|
||||
|
||||
@commands.command()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user