|
6 | 6 | import sys
|
7 | 7 | import typing
|
8 | 8 | import zipfile
|
9 |
| -from importlib import invalidate_caches |
10 | 9 | from difflib import get_close_matches
|
| 10 | +from importlib import invalidate_caches |
11 | 11 | from pathlib import Path, PurePath
|
12 | 12 | from re import match
|
13 | 13 | from site import USER_SITE
|
14 | 14 | from subprocess import PIPE
|
15 | 15 |
|
16 | 16 | import discord
|
17 | 17 | from discord.ext import commands
|
18 |
| - |
19 | 18 | from packaging.version import Version
|
20 | 19 |
|
21 | 20 | from core import checks
|
22 | 21 | from core.models import PermissionLevel, getLogger
|
23 | 22 | from core.paginator import EmbedPaginatorSession
|
24 |
| -from core.utils import truncate, trigger_typing |
| 23 | +from core.utils import trigger_typing, truncate |
25 | 24 |
|
26 | 25 | logger = getLogger(__name__)
|
27 | 26 |
|
@@ -132,8 +131,11 @@ async def cog_load(self):
|
132 | 131 |
|
133 | 132 | async def populate_registry(self):
|
134 | 133 | url = "https://raw.githubusercontent.com/modmail-dev/modmail/master/plugins/registry.json"
|
135 |
| - async with self.bot.session.get(url) as resp: |
136 |
| - 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") |
137 | 139 |
|
138 | 140 | async def initial_load_plugins(self):
|
139 | 141 | for plugin_name in list(self.bot.config["plugins"]):
|
@@ -638,6 +640,14 @@ async def plugins_registry(self, ctx, *, plugin_name: typing.Union[int, str] = N
|
638 | 640 |
|
639 | 641 | registry = sorted(self.registry.items(), key=lambda elem: elem[0])
|
640 | 642 |
|
| 643 | + if not registry: |
| 644 | + embed = discord.Embed( |
| 645 | + color=self.bot.error_color, |
| 646 | + description="Registry is empty. This could be because it failed to load.", |
| 647 | + ) |
| 648 | + await ctx.send(embed=embed) |
| 649 | + return |
| 650 | + |
641 | 651 | if isinstance(plugin_name, int):
|
642 | 652 | index = plugin_name - 1
|
643 | 653 | if index < 0:
|
|
0 commit comments