24 lines
890 B
Python
24 lines
890 B
Python
import os
|
|
import importlib
|
|
|
|
import nerimity
|
|
import pylast
|
|
|
|
class Bot(nerimity.Client):
|
|
"""Extended client class for extra functionality."""
|
|
def __init__(self, lastfm_api_key: str, lastfm_api_secret: str, *args, **kwargs):
|
|
self.lastfm = pylast.LastFMNetwork(
|
|
api_key = lastfm_api_key,
|
|
api_secret = lastfm_api_secret
|
|
)
|
|
super().__init__(*args, **kwargs)
|
|
|
|
def load_commands(self, commands_dir: str):
|
|
for filename in os.listdir(commands_dir):
|
|
if filename.endswith(".py") and not filename.startswith("_"):
|
|
module_name = f"{commands_dir}.{filename[:-3]}"
|
|
module = importlib.import_module(module_name)
|
|
if hasattr(module, "setup"):
|
|
module.setup(self)
|
|
print(f"Loaded {module_name}")
|
|
print("Registered commands:", self.commands)
|