Вот мой репозиторий git, где CappaBot.py является местом, где я определяю и синхронизирую команды.
Вот команда ping
Код: Выделить всё
@tree.command(
description="I will reply with 'pong' as fast as I can."
)
async def ping(interaction: discord.Interaction):
print("Got ping command")
print(interaction)
await interaction.response.send_message("Pong")
Код: Выделить всё
# This will run when the bot is ready to take inputs
@client.event
async def on_ready():
# Print that we have connected to discord.
print(f'{client.user} has connected to Discord!')
# Add the voice commands to the command tree
voiceGroup = VoiceGroup(name="voice", description="The voice commands can make me connect and disconnect from a voice call.")
tree.add_command(voiceGroup)
# Sync to testing servers
print("Syncing servers...")
for server in SERVERS:
server = discord.Object(server)
# Copy the commands to the server
tree.copy_global_to(guild=server)
# Sync the commands to the server
await tree.sync(guild=server)
# Sync globally
print("Syncing globally...")
await tree.sync()
if DEBUG:
user = client.get_user(CAPPABOT)
await user.send("Cappa Bot has started")
print("Finished loading.")
Я попробовал изменить синхронизацию, но это либо приведет к тому, что команды не будут синхронизироваться глобально, либо не будут синхронизироваться немедленно для тестовых серверов.
Как мне сделать так, чтобы мои тестовые серверы обновлялись немедленно, но все равно обновлялись глобально для другого сервера?
Изменить:
Посмотрите на github, что я изменил.
Удален цикл for, который синхронизируется с серверами, и добавлено несколько команд для очистки старых команд и синхронизации.< /p>
Редактирование 2:
Архив репозитория GitHub, создание нового бота
Подробнее здесь: https://stackoverflow.com/questions/785 ... d-globally