mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -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):
|
async def setup(bot: Red):
|
||||||
cog = Mod(bot)
|
cog = Mod(bot)
|
||||||
await cog.initialize()
|
|
||||||
bot.add_cog(cog)
|
bot.add_cog(cog)
|
||||||
|
await cog.initialize()
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
|
import asyncio
|
||||||
|
from abc import ABC
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from typing import List, Tuple
|
from typing import List, Tuple
|
||||||
from abc import ABC
|
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
from redbot.core import Config, modlog, commands
|
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.tban_expiry_task = self.bot.loop.create_task(self.check_tempban_expirations())
|
||||||
self.last_case: dict = defaultdict(dict)
|
self.last_case: dict = defaultdict(dict)
|
||||||
|
|
||||||
|
self._ready = asyncio.Event()
|
||||||
|
|
||||||
async def initialize(self):
|
async def initialize(self):
|
||||||
await self._maybe_update_config()
|
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):
|
def cog_unload(self):
|
||||||
self.tban_expiry_task.cancel()
|
self.tban_expiry_task.cancel()
|
||||||
@ -102,7 +109,7 @@ class Mod(
|
|||||||
"Please use `{prefix}moveignoredchannels` if "
|
"Please use `{prefix}moveignoredchannels` if "
|
||||||
"you were previously using these functions."
|
"you were previously using these functions."
|
||||||
).format(prefix=prefixes[0])
|
).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__)
|
await self.settings.version.set(__version__)
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user