Skip to content

Commit 21e0099

Browse files
Update docs and add migration
1 parent 0ee2034 commit 21e0099

File tree

5 files changed

+59
-10
lines changed

5 files changed

+59
-10
lines changed

docs/faq.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ Pretty much anything from the discord's commands extension doesn't work, also so
109109
.. warning::
110110
If you use something that might take a while, eg ``wait_for`` you'll run into two issues:
111111

112-
1. If you don't respond within 3 seconds (``ctx.respond()``) discord invalidates the interaction.
112+
1. If you don't respond within 3 seconds (``ctx.defer()`` or `ctx.send(..)``) discord invalidates the interaction.
113113
2. The interaction only lasts for 15 minutes, so if you try and send something with the interaction (``ctx.send``) more than 15 mins after the command was ran it won't work.
114114

115115
As an alternative you can use ``ctx.channel.send`` but this relies on the the bot being in the guild, and the bot having send perms in that channel.

docs/gettingstarted.rst

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,12 @@ code as shown below:
5454
@slash.slash(name="test",
5555
description="This is just a test command, nothing more.")
5656
async def test(ctx):
57-
await ctx.respond()
5857
await ctx.send(content="Hello World!")
5958
6059
Now that we've gone over how Discord handles the declaration of slash commands
6160
through their Bot API, let's go over what some of the other things mean within
6261
the *logical* part of our code, the command function:
6362

64-
- ``ctx.respond()``: This is a way for us to handle responses. In short, the API
65-
requires some way to "acknowledge" an interaction response that we want to send off.
66-
67-
(An alias of this would be ``ctx.ack()``)
6863

6964
Giving some options for variety.
7065
--------------------------------
@@ -163,7 +158,6 @@ Now, we can finally visualize this by coding an example of this being used in th
163158
)
164159
])
165160
async def test(ctx, optone: str):
166-
await ctx.respond()
167161
await ctx.send(content=f"I got you, you said {optone}!")
168162
169163
Additionally, we could also declare the type of our command's option through this method shown here:
@@ -233,7 +227,6 @@ a string or integer. Below is an implementation of this design in the Python cod
233227
)
234228
])
235229
async def test(ctx, optone: str):
236-
await ctx.respond()
237230
await ctx.send(content=f"Wow, you actually chose {optone}? :(")
238231
239232
.. _quickstart: https://discord-py-slash-command.readthedocs.io/en/latest/quickstart.html

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ discussion on GitHub!
2626

2727
quickstart.rst
2828
gettingstarted.rst
29-
migrate_to_109.rst
29+
migration.rst
3030
discord_slash.rst
3131
events.rst
3232
discord_slash.utils.rst

docs/migrate_to_109.rst renamed to docs/migration.rst

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,60 @@
1+
Migration
2+
+++++++++
3+
This page contains instructions on how to migrate between versions with breaking changes.
4+
5+
Migrate To V1.0.10
6+
==================
7+
Changes that you'll need to make in this version are mainly becuase of a new ui from discord, more info `here <https://github.com/discord/discord-api-docs/pull/2615>`_
8+
9+
Responding / Deferring
10+
**********************
11+
12+
In regards to :class:`SlashContext` the methods ``.respond`` and ``.ack`` have been removed, and ``.defer`` added.
13+
Deferring a message will allow you to respond for up to 15 mins, but you'll have to defer within three seconds.
14+
When you defer the user will see a "this bot is thinking" message until you send a message, This message can be ephermical (hidden) or visible.
15+
``.defer`` has a ``hidden`` parameter, which will make the deferred message ephermical.
16+
17+
We suggest deferring if you might take more than three seconds to respond, but if you will call ``.send`` before three seconds then don't.
18+
19+
.. note::
20+
You **must** respond with ``.send`` within 15 minutes of the command being invoked to avoid an "interaction failed" message, if you defer.
21+
This is especially relevant for bots that had 'invisible' commands, where the invocation was not shown.
22+
If you wish to have the invocation of the command not visible, send an ephermical success message, and then do what you used to.
23+
It is no longer possible to "eat" the invocation.
24+
``ctx.channel.send`` does **not** count as responding.
25+
26+
Example
27+
--------
28+
29+
.. code-block:: python
30+
31+
# Before
32+
@slash.slash(...)
33+
async def command(ctx, ...):
34+
await ctx.respond()
35+
await ctx.send(...)
36+
37+
# After 1
38+
@slash.slash(...)
39+
async def command(ctx, ...):
40+
await ctx.send(...)
41+
42+
# After 2
43+
@slash.slash(...)
44+
async def command(ctx, ...):
45+
await ctx.defer()
46+
# Process that takes time
47+
await ctx.send(...)
48+
49+
50+
Sending hidden messages
51+
***********************
52+
The method ``.send_hidden`` on :class:`SlashContext` has been removed. Use ``.send(hidden = True, ..)`` instead.
53+
54+
55+
56+
57+
158
Migrate To 1.0.9
259
================
360

docs/quickstart.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ slash commands just yet. We can do that by adding this code shown here:
5252
5353
@slash.slash(name="ping", guild_ids=guild_ids)
5454
async def _ping(ctx): # Defines a new "context" (ctx) command called "ping."
55-
await ctx.respond()
5655
await ctx.send(f"Pong! ({client.latency*1000}ms)")
5756
5857
Let's compare some of the major code differences between the prior examples in order

0 commit comments

Comments
 (0)