Initialisation du repository de Beta
This commit is contained in:
commit
14985f6dbb
9469 changed files with 1903273 additions and 0 deletions
32
commandes/security/purge.py
Normal file
32
commandes/security/purge.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import discord
|
||||
|
||||
async def execute(bot, params, message):
|
||||
purges = params.get('purges', [])
|
||||
if not purges:
|
||||
# Fallback for single purge
|
||||
purges = [params]
|
||||
total_deleted = 0
|
||||
for purge_params in purges:
|
||||
channel_name = purge_params.get('channel_name')
|
||||
channel_id = purge_params.get('channel_id')
|
||||
amount = purge_params.get('amount', 10)
|
||||
guild = message.guild
|
||||
channel = None
|
||||
if channel_id:
|
||||
try:
|
||||
channel = guild.get_channel(int(channel_id))
|
||||
except ValueError:
|
||||
pass
|
||||
elif channel_name:
|
||||
channel = discord.utils.find(lambda c: c.name.casefold() == channel_name.casefold(), guild.channels)
|
||||
if not channel:
|
||||
identifier = channel_id or channel_name or 'inconnu'
|
||||
await message.channel.send(f"Salon '{identifier}' introuvable.")
|
||||
continue
|
||||
try:
|
||||
deleted = await channel.purge(limit=amount)
|
||||
total_deleted += len(deleted)
|
||||
except discord.Forbidden:
|
||||
await message.channel.send(f"Je n'ai pas les permissions pour purger {channel.mention}.")
|
||||
if total_deleted > 0:
|
||||
await message.channel.send(f"{total_deleted} messages supprimés au total.")
|
||||
Loading…
Add table
Add a link
Reference in a new issue