From cfc1d8797aba5481bb485c5ab3899283e8422c08 Mon Sep 17 00:00:00 2001 From: Raiden Sakura Date: Sun, 31 Mar 2024 15:41:09 +0800 Subject: [PATCH] Pull #3330 --- cogs/plugins.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cogs/plugins.py b/cogs/plugins.py index fda74d0593..766beb5c03 100644 --- a/cogs/plugins.py +++ b/cogs/plugins.py @@ -131,8 +131,11 @@ async def cog_load(self): async def populate_registry(self): url = "https://raw.githubusercontent.com/modmail-dev/modmail/master/plugins/registry.json" - async with self.bot.session.get(url) as resp: - self.registry = json.loads(await resp.text()) + try: + async with self.bot.session.get(url) as resp: + self.registry = json.loads(await resp.text()) + except asyncio.TimeoutError: + logger.warning("Failed to fetch registry. Loading with empty registry") async def initial_load_plugins(self): for plugin_name in list(self.bot.config["plugins"]): @@ -622,6 +625,13 @@ async def plugins_registry(self, ctx, *, plugin_name: typing.Union[int, str] = N registry = sorted(self.registry.items(), key=lambda elem: elem[0]) + if not registry: + embed = discord.Embed( + color=self.bot.error_color, + description="Registry is empty. This could be because it failed to load.", + ) + return await ctx.send(embed=embed) + if isinstance(plugin_name, int): index = plugin_name - 1 if index < 0: