32 lines
1.3 KiB
Python
32 lines
1.3 KiB
Python
|
|
import discord
|
||
|
|
from discord.ext import commands
|
||
|
|
from discord import app_commands
|
||
|
|
|
||
|
|
# IDs des rôles
|
||
|
|
PERMIS_ROLE_ID = 1357027980056199258
|
||
|
|
AUTO_ECOLE_ROLE_ID = 1338844772118298634
|
||
|
|
|
||
|
|
class PermisCommand(commands.Cog):
|
||
|
|
def __init__(self, bot):
|
||
|
|
self.bot = bot
|
||
|
|
|
||
|
|
@app_commands.command(name="ajouter_permis", description="Ajoute le rôle 'permis' à un membre.")
|
||
|
|
async def ajouter_permis(self, interaction: discord.Interaction, membre: discord.Member):
|
||
|
|
"""Ajoute le rôle 'permis' à un membre sélectionné."""
|
||
|
|
# Vérifier si l'utilisateur a le rôle "auto-école"
|
||
|
|
if AUTO_ECOLE_ROLE_ID not in [role.id for role in interaction.user.roles]:
|
||
|
|
await interaction.response.send_message("❌ Erreur : Vous n'avez pas la permission d'utiliser cette commande.")
|
||
|
|
return
|
||
|
|
|
||
|
|
# Vérifier si le rôle "permis" existe
|
||
|
|
permis_role = interaction.guild.get_role(PERMIS_ROLE_ID)
|
||
|
|
if not permis_role:
|
||
|
|
await interaction.response.send_message("❌ Erreur : Le rôle 'permis' n'existe pas.")
|
||
|
|
return
|
||
|
|
|
||
|
|
# Ajouter le rôle "permis" au membre
|
||
|
|
await membre.add_roles(permis_role)
|
||
|
|
await interaction.response.send_message(f"✅ Le rôle 'permis' a été ajouté à {membre.mention}.")
|
||
|
|
|
||
|
|
async def setup(bot):
|
||
|
|
await bot.add_cog(PermisCommand(bot))
|