diff --git a/bot.py b/bot.py index d9da571..83b425b 100644 --- a/bot.py +++ b/bot.py @@ -34,7 +34,15 @@ class MusicBot(commands.Cog): import json with open(config_path, "r") as f: data = json.load(f) - self.history[guild_id] = data.get(str(guild_id), []) + raw_history = data.get(str(guild_id), []) + unique_history = [] + seen = set() + for item in raw_history: + key = (item.get("title", ""), item.get("url", "")) + if key not in seen: + seen.add(key) + unique_history.append(item) + self.history[guild_id] = unique_history except Exception as e: print(f"Error loading history: {e}") self.history[guild_id] = [] @@ -69,6 +77,7 @@ class MusicBot(commands.Cog): "is_local": player.data.get("is_local", False), "filepath": player.data.get("filepath") } + history = [h for h in history if h.get("title") != entry["title"] and (not entry.get("url") or h.get("url") != entry["url"])] history.insert(0, entry) self.history[guild_id] = history[:50] self.save_history(guild_id)