Correction du bug "wl is not found"
This commit is contained in:
parent
dd24225120
commit
6372014c99
2 changed files with 158 additions and 17 deletions
104
commandes/convocation.py
Executable file
104
commandes/convocation.py
Executable file
|
|
@ -0,0 +1,104 @@
|
|||
import discord
|
||||
from discord.ext import commands
|
||||
from discord import app_commands
|
||||
|
||||
class Convocation(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
@app_commands.command(
|
||||
name="convocation",
|
||||
description="Convocation d’un membre"
|
||||
)
|
||||
@app_commands.describe(
|
||||
membre="Le membre à convoquer",
|
||||
raison="La raison de la convocation",
|
||||
heure="L’heure de la convocation"
|
||||
)
|
||||
@app_commands.checks.has_permissions(manage_roles=True)
|
||||
async def convocation(
|
||||
self,
|
||||
interaction: discord.Interaction,
|
||||
membre: discord.Member,
|
||||
raison: str,
|
||||
heure: str
|
||||
):
|
||||
role_convocation_id = 1388607106558726204
|
||||
log_user_ids = [
|
||||
1195440742307467377,
|
||||
689550504963080328,
|
||||
1359253046055534775
|
||||
]
|
||||
log_channel_id = 1389747212837322852
|
||||
|
||||
await interaction.response.defer(ephemeral=True)
|
||||
|
||||
try:
|
||||
roles_to_remove = [
|
||||
r for r in membre.roles if r.id != interaction.guild.id
|
||||
]
|
||||
await membre.remove_roles(*roles_to_remove)
|
||||
role_convocation = interaction.guild.get_role(role_convocation_id)
|
||||
if role_convocation:
|
||||
await membre.add_roles(role_convocation)
|
||||
|
||||
embed_convocation = discord.Embed(
|
||||
title="CONVOCATION | 🔖",
|
||||
description=f"> Bonjour <@{membre.id}>, vous êtes **convoqué** par <@{interaction.user.id}>. Voici les **détails** :",
|
||||
color=0x0099ff
|
||||
)
|
||||
embed_convocation.add_field(name="**Raison de la convocation :**", value=f"➜ {raison}", inline=False)
|
||||
embed_convocation.add_field(name="**Heure de la convocation :**", value=f"➜ {heure}", inline=False)
|
||||
embed_convocation.add_field(name="\u200B", value=(
|
||||
"> Merci de vous présenter dans le vocal attente moov **5 minutes** avant l’heure. "
|
||||
"Soyez **professionnel**, et en cas d’absence, merci de contacter la personne vous ayant convoqué.\n\n"
|
||||
"> La **levée** de suspension se fera uniquement à la **fin** de la convocation."
|
||||
), inline=False)
|
||||
embed_convocation.add_field(name="**__Bien cordialement__**", value="_La Gestion de Alésia | 📑_", inline=False)
|
||||
|
||||
embed_log = discord.Embed(
|
||||
title="📋 CONVOCATION ENVOYÉE",
|
||||
color=0xff9900
|
||||
)
|
||||
embed_log.add_field(name="👤 Membre convoqué", value=f"<@{membre.id}> ({membre.name}#{membre.discriminator})", inline=True)
|
||||
embed_log.add_field(name="👮 Convoqué par", value=f"<@{interaction.user.id}> ({interaction.user.name}#{interaction.user.discriminator})", inline=True)
|
||||
embed_log.add_field(name="📄 Raison", value=raison, inline=False)
|
||||
embed_log.add_field(name="🕒 Heure", value=heure, inline=False)
|
||||
embed_log.add_field(name="📆 Date", value=f"<t:{int(discord.utils.utcnow().timestamp())}:F>", inline=False)
|
||||
embed_log.set_footer(text="Gestion des convocations", icon_url=self.bot.user.display_avatar.url)
|
||||
|
||||
# MP au membre
|
||||
dm_sent = False
|
||||
try:
|
||||
await membre.send(embed=embed_convocation)
|
||||
dm_sent = True
|
||||
except:
|
||||
dm_sent = False
|
||||
|
||||
await interaction.edit_original_response(content=(
|
||||
f"✅ Convocation envoyée à {membre.mention}." if dm_sent else
|
||||
f"⚠️ Convocation enregistrée, mais impossible d'envoyer un MP à {membre.mention}."
|
||||
))
|
||||
|
||||
# Log aux utilisateurs
|
||||
for user_id in log_user_ids:
|
||||
try:
|
||||
user = await self.bot.fetch_user(user_id)
|
||||
await user.send(embed=embed_log)
|
||||
except Exception as e:
|
||||
print(f"Erreur lors de l'envoi du log à {user_id} : {e}")
|
||||
|
||||
# Log dans le salon
|
||||
try:
|
||||
log_channel = await self.bot.fetch_channel(log_channel_id)
|
||||
if isinstance(log_channel, discord.TextChannel):
|
||||
await log_channel.send(embed=embed_log)
|
||||
except Exception as e:
|
||||
print(f"Erreur lors de l'envoi du log dans le salon : {e}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Erreur dans la commande /convocation : {e}")
|
||||
await interaction.edit_original_response(content="❌ Une erreur est survenue.")
|
||||
|
||||
async def setup(bot):
|
||||
await bot.add_cog(Convocation(bot))
|
||||
Loading…
Add table
Add a link
Reference in a new issue