mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-23 11:13:51 -05:00
[V3 Cog/Data Manager] Bundled Cog Data (#1063)
* Refactor find_spec out of core_commands * Fix version error when not installed * initial * Fix find_cogs call * Enable copying * Add helper method for cog creators * Add warning * My dpy skillz need work
This commit is contained in:
@@ -14,9 +14,7 @@ from discord.ext import commands
|
||||
from redbot.core import checks
|
||||
from redbot.core import i18n
|
||||
|
||||
import redbot.cogs # Don't remove this line or core cogs won't load
|
||||
|
||||
__all__ = ["find_spec", "Core"]
|
||||
__all__ = ["Core"]
|
||||
|
||||
log = logging.getLogger("red")
|
||||
|
||||
@@ -26,20 +24,6 @@ OWNER_DISCLAIMER = ("⚠ **Only** the person who is hosting Red should be "
|
||||
"system.** ⚠")
|
||||
|
||||
|
||||
async def find_spec(bot, cog_name: str):
|
||||
try:
|
||||
spec = await bot.cog_mgr.find_cog(cog_name)
|
||||
except RuntimeError:
|
||||
real_name = ".{}".format(cog_name)
|
||||
try:
|
||||
mod = importlib.import_module(real_name, package='redbot.cogs')
|
||||
except ImportError:
|
||||
spec = None
|
||||
else:
|
||||
spec = mod.__spec__
|
||||
return spec
|
||||
|
||||
|
||||
_ = i18n.CogI18n("Core", __file__)
|
||||
|
||||
|
||||
@@ -50,8 +34,9 @@ class Core:
|
||||
@checks.is_owner()
|
||||
async def load(self, ctx, *, cog_name: str):
|
||||
"""Loads a package"""
|
||||
spec = await find_spec(ctx.bot, cog_name)
|
||||
if spec is None:
|
||||
try:
|
||||
spec = await ctx.bot.cog_mgr.find_cog(cog_name)
|
||||
except RuntimeError:
|
||||
await ctx.send(_("No module by that name was found in any"
|
||||
" cog path."))
|
||||
return
|
||||
@@ -83,7 +68,7 @@ class Core:
|
||||
"""Reloads a package"""
|
||||
ctx.bot.unload_extension(cog_name)
|
||||
|
||||
spec = await find_spec(ctx.bot, cog_name)
|
||||
spec = await ctx.bot.cog_mgr.find_cog(cog_name)
|
||||
if spec is None:
|
||||
await ctx.send(_("No module by that name was found in any"
|
||||
" cog path."))
|
||||
|
||||
Reference in New Issue
Block a user