Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(docs): warning on overriding on_connect #1689

Merged
merged 8 commits into from
Oct 16, 2022
Merged
12 changes: 10 additions & 2 deletions discord/bot.py
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions docs/api.rst
Expand Up @@ -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`
Expand Down