Beta/commandes/salons/modifier.py

24 lines
954 B
Python
Raw Permalink Normal View History

2026-02-06 22:23:20 +01:00
import discord
async def execute(bot, params, message):
channels = params.get('channels', [])
if not channels:
# Fallback for single channel
channels = [params]
guild = message.guild
modified_count = 0
for channel_params in channels:
channel_name = channel_params.get('channel_name')
new_name = channel_params.get('new_name')
channel = discord.utils.find(lambda c: c.name.casefold() == channel_name.casefold(), guild.channels)
if not channel:
await message.channel.send(f"Salon '{channel_name}' introuvable.")
continue
try:
await channel.edit(name=new_name)
modified_count += 1
except discord.Forbidden:
await message.channel.send(f"Je n'ai pas les permissions pour modifier le salon '{channel_name}'.")
if modified_count > 0:
await message.channel.send(f"{modified_count} salon(s) modifié(s).")