From 1aebafc64809ead5da400d5496ac4e0fb40d868e Mon Sep 17 00:00:00 2001 From: yuki Date: Tue, 7 Oct 2025 01:50:51 -0300 Subject: [PATCH] merge lastfm client into bot class --- bot.py | 7 ++++++- main.py | 12 ++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/bot.py b/bot.py index 85b197e..df6b610 100644 --- a/bot.py +++ b/bot.py @@ -2,10 +2,15 @@ import os import importlib import nerimity +import pylast class Bot(nerimity.Client): """Extended client class for extra functionality.""" - def __init__(self, *args, **kwargs): + 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): diff --git a/main.py b/main.py index 3c20073..439b494 100644 --- a/main.py +++ b/main.py @@ -8,16 +8,12 @@ import bot with open("config.toml", "rb") as f: config = tomllib.load(f) -# last.fm client -network = pylast.LastFMNetwork( - api_key = config['api_key'], - api_secret = config['api_secret'] -) - # nerimity client bot = bot.Bot( - token=config['token'], - prefix='!' + token = config['token'], + prefix = '!', + lastfm_api_key = config['api_key'], + lastfm_api_secret = config['api_secret'] ) bot.load_commands("commands")