Repository: Cog-Creators/Red-DiscordBot

Issue:
[Audio] Instructions how to fix "missing" `sqlite3` show when you actually don't have `databases`
# Other bugs

#### What were you trying to do?

Load Audio with missing `databases` requirement.

#### What were you expecting to happen?

I expected error about missing `databases` and just have Audio fail to load. It would also be fine if it would disable caching feature but told me the real cause.

#### What actually happened?

I got error about disabled caching feature (which is fine), but for instructions on fixing, it told me to google `ModuleNotFoundError: No module named '_sqlite3'` which won't help me at all when I don't have `databases` requirement.

#### How can we reproduce this issue?

1. Remove `databases` package
2. Try to load Audio

---

One could say that we can't account for someone missing requirements and that makes sense as long as user regularly gets the actual `ImportError` that occurred and thanks to this can know what's wrong. Getting error that is telling you that something unrelated is wrong just causes unnecessary confusion.


Discussion:

Resolving patch:
diff --git a/redbot/cogs/audio/apis.py b/redbot/cogs/audio/apis.py
--- a/redbot/cogs/audio/apis.py
+++ b/redbot/cogs/audio/apis.py
@@ -7,6 +7,7 @@
 import os
 import random
 import time
+import traceback
 from collections import namedtuple
 from typing import Callable, Dict, List, Mapping, NoReturn, Optional, Tuple, Union
 
@@ -15,11 +16,14 @@
     from databases import Database
 
     HAS_SQL = True
-except ModuleNotFoundError:
+    _ERROR = None
+except ImportError as err:
+    _ERROR = "".join(traceback.format_exception_only(type(err), err)).strip()
     HAS_SQL = False
-    SQLError = ModuleNotFoundError
+    SQLError = err.__class__
     Database = None
 
+
 import aiohttp
 import discord
 import lavalink
diff --git a/redbot/cogs/audio/audio.py b/redbot/cogs/audio/audio.py
--- a/redbot/cogs/audio/audio.py
+++ b/redbot/cogs/audio/audio.py
@@ -35,7 +35,7 @@
 )
 from redbot.core.utils.predicates import MessagePredicate, ReactionPredicate
 from . import dataclasses
-from .apis import MusicCache, HAS_SQL
+from .apis import MusicCache, HAS_SQL, _ERROR
 from .checks import can_have_caching
 from .converters import ComplexScopeParser, ScopeParser, get_lazy_converter, get_playlist_converter
 from .equalizer import Equalizer
@@ -197,16 +197,16 @@ async def initialize(self):
         lavalink.register_event_listener(self.event_handler)
         if not HAS_SQL:
             error_message = (
-                "Audio version: {version}\nThis version requires SQL to "
+                "Audio version: {version}\nThis version requires some SQL dependencies to "
                 "access the caching features, "
-                "your Python install is missing the module sqlite3.\n\n"
+                "your Python install is missing some of them.\n\n"
                 "For instructions on how to fix it Google "
-                "`ModuleNotFoundError: No module named '_sqlite3'`\n"
-                "You will need to reinstall "
-                "Python with SQL dependencies installed.\n\n"
+                f"`{_ERROR}`.\n"
+                "You will need to install the missing SQL dependency.\n\n"
             ).format(version=__version__)
             with contextlib.suppress(discord.HTTPException):
-                await self.bot.send_to_owners(error_message)
+                for page in pagify(error_message):
+                    await self.bot.send_to_owners(page)
             log.critical(error_message)
 
     async def _migrate_config(self, from_version: int, to_version: int):


Test patch: