Skip to content

Commit cfc1d87

Browse files
committed
1 parent 0d1e460 commit cfc1d87

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

cogs/plugins.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,11 @@ async def cog_load(self):
131131

132132
async def populate_registry(self):
133133
url = "https://raw.githubusercontent.com/modmail-dev/modmail/master/plugins/registry.json"
134-
async with self.bot.session.get(url) as resp:
135-
self.registry = json.loads(await resp.text())
134+
try:
135+
async with self.bot.session.get(url) as resp:
136+
self.registry = json.loads(await resp.text())
137+
except asyncio.TimeoutError:
138+
logger.warning("Failed to fetch registry. Loading with empty registry")
136139

137140
async def initial_load_plugins(self):
138141
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
622625

623626
registry = sorted(self.registry.items(), key=lambda elem: elem[0])
624627

628+
if not registry:
629+
embed = discord.Embed(
630+
color=self.bot.error_color,
631+
description="Registry is empty. This could be because it failed to load.",
632+
)
633+
return await ctx.send(embed=embed)
634+
625635
if isinstance(plugin_name, int):
626636
index = plugin_name - 1
627637
if index < 0:

0 commit comments

Comments
 (0)