From d95d5b657de2223f46562c3530302281c374a083 Mon Sep 17 00:00:00 2001 From: Om <92863779+Om1609@users.noreply.github.com> Date: Sat, 13 May 2023 11:27:00 +0530 Subject: [PATCH] Update events.rst Signed-off-by: Om <92863779+Om1609@users.noreply.github.com> --- docs/api/events.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/api/events.rst b/docs/api/events.rst index 4903ae8f92..fe339c1166 100644 --- a/docs/api/events.rst +++ b/docs/api/events.rst @@ -7,11 +7,11 @@ Event Reference This section outlines the different types of events listened by :class:`Client`. -There are 4 ways to register an event, the first way is through the use of +There are 3 ways to register an event, the first way is through the use of :meth:`Client.event`. The second way is through subclassing :class:`Client` and overriding the specific events. The third way is through the use of :meth:`Client.listen`, which can be used to assign multiple event handlers instead of only one like in :meth:`Client.event`. -The fourth way is through the use of :meth:`Client.once`, which serves as a one-time event listener. For example: +For example: .. code-block:: python :emphasize-lines: 17, 22 @@ -41,10 +41,10 @@ The fourth way is through the use of :meth:`Client.once`, which serves as a one- async def on_message(message: discord.Message): print(f"Received {message.content}") - # Runs only for the 1st 'on_message' event. Can be useful for listening to 'on_ready' - @client.once() - async def message(message: discord.Message): - print(f"Received {message.content}") + # Runs only for the 1st event dispatch. Can be useful for listening to 'on_ready' + @client.listen(once=True) + async def on_ready(): + print("Client is ready!") If an event handler raises an exception, :func:`on_error` will be called