Commit hoarding is a terrible practice

This commit is contained in:
2021-12-06 20:14:24 +01:00
parent 76bfd719c3
commit 2a24a4b5f0
15 changed files with 485 additions and 36 deletions
+13 -3
View File
@@ -1,13 +1,15 @@
import asyncio
from typing import Dict
from typing import TYPE_CHECKING
from discord.ext.commands import Cog
from bot import TuneBot
if TYPE_CHECKING:
from tunebot import BasePluginInstance
from bot import TuneBot
class BaseCog(Cog):
def __init__(self, bot: TuneBot) -> None:
def __init__(self, bot: "TuneBot") -> None:
self.bot = bot
slash_descriptions: Dict[str, str] = self.bot.config["slash_descriptions"]
@@ -20,3 +22,11 @@ class BaseCog(Cog):
hasattr(self.bot, "lavalink")
and len(self.bot.lavalink.node_manager.available_nodes) > 0
)
class PluginCog(BaseCog):
def get_plugin_instance(self, name: str) -> "BasePluginInstance":
if plugin := self.bot.plugin_manager.get_plugin(name):
return plugin
raise KeyError(f"Failed to retrieve plugin instance with name: {name}")