38 lines
1.5 KiB
Python
38 lines
1.5 KiB
Python
|
|
import discord
|
||
|
|
from discord import app_commands
|
||
|
|
from discord.ext import commands
|
||
|
|
# Import ou partage de presence_data selon l'architecture
|
||
|
|
from commandes.annonces_sessions import presence_data # adapte le chemin si besoin
|
||
|
|
|
||
|
|
class ListePresence(commands.Cog):
|
||
|
|
def __init__(self, bot):
|
||
|
|
self.bot = bot
|
||
|
|
|
||
|
|
@app_commands.command(
|
||
|
|
name="liste_presence",
|
||
|
|
description="Liste les présences pour une session RP."
|
||
|
|
)
|
||
|
|
@app_commands.describe(
|
||
|
|
message_id="ID du message d'annonce"
|
||
|
|
)
|
||
|
|
async def liste_presence(self, interaction: discord.Interaction, message_id: str):
|
||
|
|
try:
|
||
|
|
mid = int(message_id)
|
||
|
|
except ValueError:
|
||
|
|
await interaction.response.send_message("ID de message invalide.", ephemeral=True)
|
||
|
|
return
|
||
|
|
if mid not in presence_data:
|
||
|
|
await interaction.response.send_message("Aucune donnée de présence pour ce message.", ephemeral=True)
|
||
|
|
return
|
||
|
|
data = presence_data[mid]
|
||
|
|
def mentions(ids):
|
||
|
|
return ', '.join(f"<@{uid}>" for uid in ids) if ids else "Aucun"
|
||
|
|
await interaction.response.send_message(
|
||
|
|
f"**Présents ({len(data['present'])})** : {mentions(data['present'])}\n"
|
||
|
|
f"**Absents ({len(data['absent'])})** : {mentions(data['absent'])}\n"
|
||
|
|
f"**En retard ({len(data['retard'])})** : {mentions(data['retard'])}",
|
||
|
|
ephemeral=True
|
||
|
|
)
|
||
|
|
|
||
|
|
async def setup(bot):
|
||
|
|
await bot.add_cog(ListePresence(bot))
|