Skip to content

Setting delete_existing=False in sync_commands causes an error. #3277

@Icebluewolf

Description

@Icebluewolf

Minimal Reproducible Code
Precondition: Your bot has 1 or more commands registered already.

import discord
import os

bot = discord.Bot()

@bot.event
async def on_ready():
    print(f"Logged in as {bot.user}")
    await bot.sync_commands(delete_existing=False)

bot.auto_sync_commands = False
bot.run(os.environ['DISCORD_TOKEN'])

Result

Ignoring exception in on_ready
Traceback (most recent call last):
  File "...\discord\client.py", line 465, in _run_event
    await coro(*args, **kwargs)
  File "...\PycordTesting\stand_alone_main.py", line 206, in on_ready
    await bot.sync_commands(delete_existing=False)
  File "...\discord\bot.py", line 766, in sync_commands
    registered_commands = await self.register_commands(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "...\discord\bot.py", line 619, in register_commands
    data = [cmd["command"].to_dict() for cmd in filtered_deleted]
            ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Command' object has no attribute 'to_dict'

This error is pretty self explanatory and will likely be resolved by creating a simple wrapper class for the deleted commands instead of the namedtuple.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No fields configured for Bug.

Projects

Status
Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions