Initialisation du repository de Beta
This commit is contained in:
commit
14985f6dbb
9469 changed files with 1903273 additions and 0 deletions
27
commandes/salons/purge.py
Normal file
27
commandes/salons/purge.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import discord
|
||||
|
||||
async def execute(bot, params, message):
|
||||
purges = params.get('purges', [])
|
||||
if not purges:
|
||||
await message.channel.send("Aucune purge spécifiée.")
|
||||
return
|
||||
|
||||
for purge in purges:
|
||||
channel_name = purge.get('channel_name')
|
||||
amount = purge.get('amount', 0)
|
||||
if not channel_name or amount <= 0 or amount > 1000:
|
||||
await message.channel.send(f"Purge invalide: canal '{channel_name}', quantité {amount} (max 1000).")
|
||||
continue
|
||||
|
||||
channel = discord.utils.find(lambda c: c.name == channel_name, message.guild.channels)
|
||||
if not channel or not isinstance(channel, discord.TextChannel):
|
||||
await message.channel.send(f"Canal '{channel_name}' introuvable ou n'est pas un canal texte.")
|
||||
continue
|
||||
|
||||
try:
|
||||
deleted = await channel.purge(limit=amount, reason=f"Purge par {message.author}")
|
||||
await message.channel.send(f"Supprimé {len(deleted)} message(s) dans {channel.mention}.")
|
||||
except discord.Forbidden:
|
||||
await message.channel.send(f"Je n'ai pas les permissions pour purger dans {channel.mention}.")
|
||||
except Exception as e:
|
||||
await message.channel.send(f"Erreur lors de la purge dans {channel.mention}: {str(e)}")
|
||||
Loading…
Add table
Add a link
Reference in a new issue