Discord-Raid-bot/cogs/top10.py
LE BERRE Mickael 85942723ab feat: rebrand RTF→TEA, clan detection via Discord roles
Replaces display-name prefix parsing ([RTF]/[RTFC]/[RTFR]) with
Discord role-based clan detection (TEAI/TEAF/TEAC/TEACO).

- config: new CLAN_CONFIG with 4 TEA clans, CLAN_ROLE_IDS, CLAN_MIGRATION
- helpers: get_user_clan() replaced by get_clan_from_member()
- DatabaseManager: adds clan column on startup, auto-migrates existing
  records from old username prefixes, filters leaderboard by clan column
- pb_handler: detects clan from roles on submission, passes it to DB
- leaderboard_handler: reads clan from DB column instead of username
- top10: new commands !teai*/!teaf*/!teac*/!teaco* (removes !rtf*)
- guide: updated command list and bot title

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 10:51:26 +02:00

103 lines
4.4 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# -*- coding: utf-8 -*-
import discord
from discord.ext import commands
from utils.leaderboard_handler import show_leaderboard
from utils.helpers import normalize_difficulty
from config import BOSS_CONFIG
class Top10(commands.Cog):
"""Cog regroupant toutes les commandes de leaderboard globales et par clan"""
def __init__(self, bot):
self.bot = bot
# --- Commandes globales ---
@commands.command()
async def top10hydra(self, ctx, difficulty: str = None):
if difficulty and normalize_difficulty(difficulty) in BOSS_CONFIG['hydra']['difficulties']:
await show_leaderboard(ctx, 'hydra', difficulty)
else:
difficulties = " | ".join(BOSS_CONFIG['hydra']['difficulties'])
await ctx.send(f"❌ Please specify difficulty: `!top10hydra <difficulty>`\n**Available:** {difficulties}\n**Shortcuts:** `nm` = Nightmare")
@commands.command()
async def top10chimera(self, ctx, difficulty: str = None):
if difficulty and normalize_difficulty(difficulty) in BOSS_CONFIG['chimera']['difficulties']:
await show_leaderboard(ctx, 'chimera', difficulty)
else:
difficulties = " | ".join(BOSS_CONFIG['chimera']['difficulties'])
await ctx.send(f"❌ Please specify difficulty: `!top10chimera <difficulty>`\n**Available:** {difficulties}\n**Shortcuts:** `nm` = Nightmare, `unm` = Ultra")
@commands.command()
async def top10cvc(self, ctx):
await show_leaderboard(ctx, 'cvc')
# --- Commandes par clan TEAI (Inferno) ---
@commands.command()
async def teaihydra(self, ctx, difficulty: str = None):
await self._show_clan_leaderboard(ctx, 'hydra', difficulty, 'TEAI')
@commands.command()
async def teaichimera(self, ctx, difficulty: str = None):
await self._show_clan_leaderboard(ctx, 'chimera', difficulty, 'TEAI')
@commands.command()
async def teaicvc(self, ctx):
await show_leaderboard(ctx, 'cvc', clan='TEAI')
# --- Commandes par clan TEAF (Flame) ---
@commands.command()
async def teafhydra(self, ctx, difficulty: str = None):
await self._show_clan_leaderboard(ctx, 'hydra', difficulty, 'TEAF')
@commands.command()
async def teafchimera(self, ctx, difficulty: str = None):
await self._show_clan_leaderboard(ctx, 'chimera', difficulty, 'TEAF')
@commands.command()
async def teafcvc(self, ctx):
await show_leaderboard(ctx, 'cvc', clan='TEAF')
# --- Commandes par clan TEAC (Cinder) ---
@commands.command()
async def teachydra(self, ctx, difficulty: str = None):
await self._show_clan_leaderboard(ctx, 'hydra', difficulty, 'TEAC')
@commands.command()
async def teachimera(self, ctx, difficulty: str = None):
await self._show_clan_leaderboard(ctx, 'chimera', difficulty, 'TEAC')
@commands.command()
async def teaccvc(self, ctx):
await show_leaderboard(ctx, 'cvc', clan='TEAC')
# --- Commandes par clan TEACO (Corrupted Olympians) ---
@commands.command()
async def teacohydra(self, ctx, difficulty: str = None):
await self._show_clan_leaderboard(ctx, 'hydra', difficulty, 'TEACO')
@commands.command()
async def teacochimera(self, ctx, difficulty: str = None):
await self._show_clan_leaderboard(ctx, 'chimera', difficulty, 'TEACO')
@commands.command()
async def teacocvc(self, ctx):
await show_leaderboard(ctx, 'cvc', clan='TEACO')
# --- Méthode interne pour éviter la répétition ---
async def _show_clan_leaderboard(self, ctx, boss_type, difficulty, clan):
"""Affiche le leaderboard pour un boss et un clan spécifique"""
if difficulty and normalize_difficulty(difficulty) in BOSS_CONFIG[boss_type]['difficulties']:
await show_leaderboard(ctx, boss_type, difficulty, clan)
elif boss_type != 'cvc': # CvC na pas de difficultés
difficulties = " | ".join(BOSS_CONFIG[boss_type]['difficulties'])
await ctx.send(
f"❌ Please specify difficulty: `!{ctx.command.name} <difficulty>`\n"
f"**Available:** {difficulties}\n"
f"**Shortcuts:** `nm` = Nightmare, `unm` = Ultra"
)
else:
await show_leaderboard(ctx, boss_type, clan=clan)
async def setup(bot):
await bot.add_cog(Top10(bot))