Beta/commandes/salons/deplacer.py

28 lines
1.2 KiB
Python
Raw 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
moved_count = 0
for channel_params in channels:
channel_name = channel_params.get('channel_name')
new_category_name = channel_params.get('new_category_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
category = discord.utils.find(lambda cat: cat.name.casefold() == new_category_name.casefold(), guild.categories)
if not category:
await message.channel.send(f"Catégorie '{new_category_name}' introuvable.")
continue
try:
await channel.edit(category=category)
moved_count += 1
except discord.Forbidden:
await message.channel.send(f"Je n'ai pas les permissions pour déplacer le salon '{channel_name}'.")
if moved_count > 0:
await message.channel.send(f"{moved_count} salon(s) déplacé(s).")