From 76eb582e304e52d7619c45d181f8cb0f00d2ac90 Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Tue, 25 Jul 2023 11:59:37 +0100 Subject: [PATCH] Add BotBase.wait_until_bot_started which can be used to hold a process until all extensions are loaded. --- docs/changelog.rst | 4 ++++ pydis_core/_bot.py | 6 ++++++ pyproject.toml | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index adad0bc30..2dffd4c02 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -5,6 +5,10 @@ Changelog ========= +- :release:`10.1.0 <25th July 2023>` +- :feature:`190` Overwrite :obj:`discord.ext.commands.Bot.process_commands` to ensure no commands are processed until all extensions are loaded. This only works for clients using :obj:`pydis_core.BotBase.load_extensions` + + - :release:`10.0.0 <14th July 2023>` - :breaking:`188` Support sending multiple files at once to paste service. All calls to :obj:`pydis_core.utils.paste_service.send_to_paste_service` must now provide a list of :obj:`pydis_core.utils.paste_service.PasteFile` - :bug:`187 major` Fix :obj:`pydis_core.utils.channel.get_or_fetch_channel`'s return type to include :obj:`discord.abc.PrivateChannel` and :obj:`discord.Thread`. diff --git a/pydis_core/_bot.py b/pydis_core/_bot.py index 10cab4572..a94dff56a 100644 --- a/pydis_core/_bot.py +++ b/pydis_core/_bot.py @@ -231,6 +231,12 @@ async def wait_until_guild_available(self) -> None: """ await self._guild_available.wait() + async def process_commands(self, message: discord.Message) -> None: + """Wait until all extensions are loaded before processing commands.""" + if self._extension_loading_task: + await self._extension_loading_task + await super().process_commands(message) + async def setup_hook(self) -> None: """ An async init to startup generic services. diff --git a/pyproject.toml b/pyproject.toml index 1f8514e86..d3d55dbb0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pydis_core" -version = "10.0.0" +version = "10.1.0" description = "PyDis core provides core functionality and utility to the bots of the Python Discord community." authors = ["Python Discord "] license = "MIT"