mirror of
https://github.com/Matthww/TuneBot.git
synced 2026-09-21 23:27:47 +00:00
33 lines
968 B
Python
33 lines
968 B
Python
from typing import Dict
|
|
from typing import TYPE_CHECKING
|
|
|
|
from discord.ext.commands import Cog
|
|
|
|
if TYPE_CHECKING:
|
|
from tunebot import BasePluginInstance
|
|
from bot import TuneBot
|
|
|
|
|
|
class BaseCog(Cog):
|
|
def __init__(self, bot: "TuneBot") -> None:
|
|
self.bot = bot
|
|
|
|
slash_descriptions: Dict[str, str] = self.bot.config["slash_descriptions"]
|
|
for command in self.walk_commands():
|
|
if brief := slash_descriptions.get(command.qualified_name):
|
|
command.brief = brief
|
|
|
|
def is_lavalink_ready(self) -> bool:
|
|
return (
|
|
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}")
|