diff --git a/cogs/plugins.py b/cogs/plugins.py index fc6e09f05d..4d698440bb 100644 --- a/cogs/plugins.py +++ b/cogs/plugins.py @@ -132,8 +132,12 @@ 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.warn("Failed to fetch registry. Loading with empty registry") + self.registry = {} async def initial_load_plugins(self): for plugin_name in list(self.bot.config["plugins"]): @@ -638,6 +642,14 @@ async def plugins_registry(self, ctx, *, plugin_name: typing.Union[int, str] = N registry = sorted(self.registry.items(), key=lambda elem: elem[0]) + if registry == {}: + embed = discord.Embed( + color=self.bot.error_color, + description='Registry is empty. This could be because it failed to load.' + ) + await ctx.send(embed=embed) + return + if isinstance(plugin_name, int): index = plugin_name - 1 if index < 0: