Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
raidensakura committed Mar 31, 2024
1 parent 0d1e460 commit cfc1d87
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions cogs/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]):
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit cfc1d87

Please sign in to comment.