diff --git a/discord/bot.py b/discord/bot.py index 697a9be144..94cb4ec032 100644 --- a/discord/bot.py +++ b/discord/bot.py @@ -645,7 +645,15 @@ async def sync_commands( register all commands. By default, this coroutine is called inside the :func:`.on_connect` event. If you choose to override the - :func:`.on_connect` event, then you should invoke this coroutine as well. + :func:`.on_connect` event, then you should invoke this coroutine as well such as the follwing: + + .. code-block:: python + + @bot.event + async def on_connect(): + if bot.auto_sync_commands: + await bot.sync_commands() + print(f"{bot.user.name} connected.") .. note:: If you remove all guild commands from a particular guild, the library may not be able to detect and update @@ -1500,7 +1508,7 @@ class Bot(BotBase, Client): .. versionadded:: 2.0 auto_sync_commands: :class:`bool` - Whether to automatically sync slash commands. This will call sync_commands in on_connect, and in + Whether to automatically sync slash commands. This will call :meth:`~.Bot.sync_commands` in :func:`discord.on_connect`, and in :attr:`.process_application_commands` if the command is not found. Defaults to ``True``. .. versionadded:: 2.0 diff --git a/docs/api.rst b/docs/api.rst index 8c390adcaf..6da8fd479a 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -572,6 +572,11 @@ Connection The warnings on :func:`on_ready` also apply. + .. warning:: + + Overriding this event will not call :meth:`Bot.sync_commands`. + As a result, :class:`ApplicationCommand` will not be registered. + .. function:: on_shard_connect(shard_id) Similar to :func:`on_connect` except used by :class:`AutoShardedClient`