Пытаюсь освоить слэш-команды на discord.py. Прошерстила форумы, но решения своей проблемы не нашла. При запуске бота выдает ошибку:
Traceback (most recent call last):
File "d:\vip_files\code\bot\testbot.py", line 9, in <module>
tree = app_commands.CommandTree(bot)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\mimi\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands\tree.py", line 132, in __init__
raise ClientException('This client already has an associated command tree.')
discord.errors.ClientException: This client already has an associated command tree.
PS D:\vip_files\code\bot>
Вот весь код:
import discord
from discord import app_commands
from discord.ext import commands
TOKEN ='токен'
intents = discord.Intents.all()
bot = commands.Bot(command_prefix='?', intents=intents)
tree = app_commands.CommandTree(bot)
@bot.event
async def on_ready():
await tree.sync(guild=discord.Object(id=id сервера))
print('Im ready!')
# Клин
@tree.command(name = 'Клин', description = 'Очистка сообщений', guild=discord.Object(id=id сервера))
@commands.has_any_role(ids ролей)
async def клин(interaction: discord.Interaction, количество = 100):
await interaction.channel.purge(limit = int(количество))
await interaction.send('Готово!', ephemeral=True)
bot.run(TOKEN)