mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2026-05-05 16:23:27 -04:00
Rip out Downloader's non-UI functionality into private core API (#6706)
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import discord
|
||||
from redbot.core import commands
|
||||
from redbot.core import _downloader, commands
|
||||
from redbot.core.i18n import Translator
|
||||
from .installable import InstalledModule
|
||||
from redbot.core._downloader.installable import InstalledModule
|
||||
from redbot.core._downloader.repo_manager import Repo as _Repo
|
||||
|
||||
_ = Translator("Koala", __file__)
|
||||
|
||||
@@ -9,14 +10,21 @@ _ = Translator("Koala", __file__)
|
||||
class InstalledCog(InstalledModule):
|
||||
@classmethod
|
||||
async def convert(cls, ctx: commands.Context, arg: str) -> InstalledModule:
|
||||
downloader = ctx.bot.get_cog("Downloader")
|
||||
if downloader is None:
|
||||
raise commands.CommandError(_("No Downloader cog found."))
|
||||
|
||||
cog = discord.utils.get(await downloader.installed_cogs(), name=arg)
|
||||
cog = discord.utils.get(await _downloader.installed_cogs(), name=arg)
|
||||
if cog is None:
|
||||
raise commands.BadArgument(
|
||||
_("Cog `{cog_name}` is not installed.").format(cog_name=arg)
|
||||
)
|
||||
|
||||
return cog
|
||||
|
||||
|
||||
class Repo(_Repo):
|
||||
@classmethod
|
||||
async def convert(cls, ctx: commands.Context, argument: str) -> _Repo:
|
||||
poss_repo = _downloader._repo_manager.get_repo(argument)
|
||||
if poss_repo is None:
|
||||
raise commands.BadArgument(
|
||||
_('Repo by the name "{repo_name}" does not exist.').format(repo_name=argument)
|
||||
)
|
||||
return poss_repo
|
||||
|
||||
Reference in New Issue
Block a user