Не добавляются слеш-команды discord.py 2.1.0
У меня есть этот код
main.py
import discord
from discord.utils import get
from discord.ext import commands
from colorama import Fore, Back, Style
import random
from modules.logger import Logger
from modules.configuration import *
logger = Logger()
database = Database()
class PersistentView(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
@discord.ui.button(label='Начать верификацию!', style=discord.ButtonStyle.green, custom_id='persistent_view:green')
async def green(self, interaction: discord.Interaction, button: discord.ui.button):
#Всяческие действия.
class PersistentViewBot(commands.Bot):
def __init__(self):
intents = discord.Intents.default()
intents.message_content = True
super().__init__(command_prefix=commands.when_mentioned_or('$'), intents=intents)
async def setup_hook(self) -> None:
self.add_view(PersistentView())
async def on_ready(self):
await tree.sync(guild=discord.Object(id=guilds))
print(f'Logged in as {self.user} (ID: {self.user.id})')
print('------')
bot = PersistentViewBot()
tree = bot.tree
@tree.command(name="test-command", description="Testing...")
async def tester(interaction: discord.Interaction):
await interaction.response("Test!")
@bot.command()
@commands.is_owner()
async def syncer(ctx: commands.Context):
await ctx.send("Syncing...")
await tree.sync(guild=discord.Object(id=guilds))
await ctx.send("Synced!")
@bot.command()
@commands.is_owner()
async def prepare(ctx: commands.Context):
embed = discord.Embed(title="**Верификация**", description=verif_text, color=0xff6f00)
await ctx.send(embed=embed, view=PersistentView())
bot.run(token)
modules.configuration
token = "token"
guilds = 881260305315946496
supportChannel = 1032252896303132792
moderationChannel = 1025827723068850346
verificationPingRole = 1068552248013094944
verif_category = 1068460766182789201
modules.logger
from colorama import Fore, Style
class Logger:
def error(self, message: str):
print(Fore.RED + "[ERROR] " + Style.RESET_ALL + message)
def warning(self, message: str):
print(Fore.YELLOW + "[WARN ] " + Style.RESET_ALL + message)
def info(self, message: str):
print("[INFO ] " + message)
def debug(self, message: str):
print(Fore.CYAN + "[DEBUG] " + Style.RESET_ALL + message)
Данный код заточен под то, чтобы бот мог работать с кнопками после перезагрузки.
Но, когда я пытаюсь добавить слеш-команду (/test-command), у меня ничего не добавляется. Даже после того, когда я синхронизирую дерево команд на сервере командой ($syncer).
Боту выдано право на создание слеш-команд на сервере. Как это исправить?