24 lines
992 B
Python
24 lines
992 B
Python
|
|
import discord
|
||
|
|
|
||
|
|
async def execute(bot, params, message):
|
||
|
|
categories = params.get('categories', [])
|
||
|
|
if not categories:
|
||
|
|
# Fallback for single category
|
||
|
|
categories = [params]
|
||
|
|
guild = message.guild
|
||
|
|
moved_count = 0
|
||
|
|
for category_params in categories:
|
||
|
|
category_name = category_params.get('category_name')
|
||
|
|
position = category_params.get('position')
|
||
|
|
category = discord.utils.find(lambda cat: cat.name.casefold() == category_name.casefold(), guild.categories)
|
||
|
|
if not category:
|
||
|
|
await message.channel.send(f"Catégorie '{category_name}' introuvable.")
|
||
|
|
continue
|
||
|
|
try:
|
||
|
|
await category.edit(position=position)
|
||
|
|
moved_count += 1
|
||
|
|
except discord.Forbidden:
|
||
|
|
await message.channel.send(f"Je n'ai pas les permissions pour déplacer la catégorie '{category_name}'.")
|
||
|
|
if moved_count > 0:
|
||
|
|
await message.channel.send(f"{moved_count} catégorie(s) déplacée(s).")
|