You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/extensions/tasks/tasks.mdx
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -35,7 +35,7 @@ doing very useful stuff.
35
35
doing very useful stuff.
36
36
```
37
37
38
-
For a more useful example here's a task in a cog context ripped straight from the [docs](https://docs.pycord.dev/en/stable/ext/tasks/index.html#recepies):
38
+
For a more useful example here's a task in a cog context ripped straight from the [docs](https://docs.pycord.dev/en/stable/ext/tasks/index.html#recipes):
Copy file name to clipboardExpand all lines: docs/interactions/application-commands/slash-commands.mdx
+37-8Lines changed: 37 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -119,6 +119,14 @@ Here's what the registered subcommands will look like in the Slash Command Menu:
119
119
120
120
You'll notice that there's the name of the Slash Command Group and then the name of the subcommand separated by a space.
121
121
122
+
:::
123
+
124
+
:::info Cogs
125
+
126
+
If you are looking to add Slash Command Groups to cogs, please look at our [Cogs page](../../popular-topics/cogs)!
127
+
128
+
:::
129
+
122
130
## Sub-groups
123
131
124
132
We've made a subcommand group, but did you know that you could create a group inside another?
@@ -143,12 +151,14 @@ The command created above can be invoked by typing `/math advanced square_root`.
143
151
144
152
Whenever you're using Slash Commands, you might notice that you can specify parameters that the user has to set or can optionally set. These are called Options.
145
153
146
-
Since you want different inputs from Options, you'll have to specify the type for that Option. There are a few ways of doing this.
154
+
Options can also include a description to provide more information. [You can learn more about Options in our documentation!](https://docs.pycord.dev/en/stable/api/application_commands.html#discord.Option)
155
+
156
+
Since you want different inputs from Options, you'll have to specify the type for that Option; there are a few ways of doing this.
147
157
148
158
<Tabs>
149
159
<TabItemvalue="0"label="Using Type Annotations"default>
150
160
151
-
You could use Type Annotations and let Pycord figure out the option type, like shown below.
161
+
You could use Type Annotations and let Pycord figure out the option type or explicitly specified using the [`SlashCommandOptionType`](https://docs.pycord.dev/en/stable/api/enums.html#discord.SlashCommandOptionType) enum.
await ctx.respond(f"When you join \"{first}\" and \"{second}\", you get: \"{joined}\".")
184
+
165
185
bot.run("TOKEN")
166
186
```
167
187
@@ -174,24 +194,33 @@ bot.run("TOKEN")
174
194
</div>
175
195
The sum of 1 and 1 is 2.
176
196
</DiscordMessage>
197
+
<DiscordMessageprofile="robocord">
198
+
<divslot="interactions">
199
+
<DiscordInteractionprofile="bob"command>
200
+
join
201
+
</DiscordInteraction>
202
+
</div>
203
+
When you join "Py" and "cord", you get: "Pycord".
204
+
</DiscordMessage>
177
205
</DiscordComponent>
178
206
179
207
</TabItem>
180
-
<TabItemvalue="1"label="Using the SlashCommandOptionType enum">
208
+
<TabItemvalue="1"label="Using option decorator">
181
209
182
-
You could also explicitly declare the type using the [`SlashCommandOptionType`](https://docs.pycord.dev/en/stable/api/enums.html#discord.SlashCommandOptionType) enum.
210
+
Instead of Type Annotations, you can also use the option decorator. This is usually done to have type-hinting.
183
211
184
212
```python title="Slash Command Type"
185
213
import discord
186
214
187
215
bot = discord.Bot()
188
216
189
217
@bot.command()
190
-
# this explicitly tells pycord what types the options are instead of it figuring it out by itself
218
+
@discord.option("first", type=discord.SlashCommandOptionType.string) # type = str also works
219
+
@discord.option("second", type=discord.SlashCommandOptionType.string) # type = str also works
0 commit comments