Correction des multiples bugs
This commit is contained in:
parent
5fe70d754b
commit
07198c20b7
15 changed files with 707 additions and 348 deletions
73
commandes/staff_leaderboard.py
Normal file
73
commandes/staff_leaderboard.py
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
import discord
|
||||
from discord.ext import commands
|
||||
from discord import app_commands
|
||||
from datetime import datetime
|
||||
|
||||
from commandes.ticket.data.storage import get_storage
|
||||
from commandes.ticket.staff_analytics import StaffAnalytics
|
||||
|
||||
|
||||
class StaffLeaderboard(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
@app_commands.command(name="staff-leaderboard", description="Affiche le classement du staff")
|
||||
async def staff_leaderboard(self, interaction: discord.Interaction):
|
||||
"""Commande pour afficher le classement du staff"""
|
||||
await interaction.response.defer(ephemeral=False)
|
||||
|
||||
try:
|
||||
storage = get_storage()
|
||||
analytics = StaffAnalytics(self.bot)
|
||||
|
||||
# Get staff list
|
||||
staff_list = await analytics.get_staff_list(interaction.guild_id)
|
||||
|
||||
if not staff_list:
|
||||
await interaction.followup.send("Aucun membre du staff n'a été trouvé.", ephemeral=True)
|
||||
return
|
||||
|
||||
# Sort by average rating (descending)
|
||||
staff_list.sort(key=lambda x: x['average_rating'], reverse=True)
|
||||
|
||||
# Create embed
|
||||
embed = discord.Embed(
|
||||
title="🏆 Classement du Staff",
|
||||
description="Classement des meilleurs membres du staff",
|
||||
color=discord.Color.gold(),
|
||||
timestamp=datetime.now()
|
||||
)
|
||||
|
||||
# Add top 10 staff members
|
||||
top_staff = staff_list[:10]
|
||||
for i, staff in enumerate(top_staff, 1):
|
||||
rating = staff['average_rating']
|
||||
count = staff['total_ratings']
|
||||
name = staff['name']
|
||||
|
||||
# Add emoji based on rating
|
||||
if rating >= 4.5:
|
||||
emoji = "🥇"
|
||||
elif rating >= 4.0:
|
||||
emoji = "🥈"
|
||||
elif rating >= 3.5:
|
||||
emoji = "🥉"
|
||||
else:
|
||||
emoji = "⭐"
|
||||
|
||||
embed.add_field(
|
||||
name=f"{emoji} #{i} {name}",
|
||||
value=f"Note: {rating:.1f}⭐ ({count} évaluations)",
|
||||
inline=False
|
||||
)
|
||||
|
||||
# Send embed
|
||||
await interaction.followup.send(embed=embed)
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error in staff_leaderboard command: {e}")
|
||||
await interaction.followup.send("Une erreur est survenue lors de la génération du classement.", ephemeral=True)
|
||||
|
||||
|
||||
async def setup(bot):
|
||||
await bot.add_cog(StaffLeaderboard(bot))
|
||||
Loading…
Add table
Add a link
Reference in a new issue