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/getting-started/creating-your-first-bot.mdx
+8-6Lines changed: 8 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -134,8 +134,8 @@ bot = discord.Bot()
134
134
asyncdefon_ready():
135
135
print(f"{bot.user} is ready and online!")
136
136
137
-
@bot.slash_command(name="hello", description="Say hello to the bot")
138
-
asyncdefhello(ctx):
137
+
@bot.slash_command(name="hello", description="Say hello to the bot")
138
+
asyncdefhello(ctx: discord.ApplicationContext):
139
139
await ctx.respond("Hey!")
140
140
141
141
bot.run(os.getenv('TOKEN')) # run the bot with the token
@@ -190,8 +190,8 @@ the [`on_ready`](https://docs.pycord.dev/en/stable/api/events.html#discord.on_re
190
190
event that is automatically called when the bot is ready to use.
191
191
192
192
```py
193
-
@bot.slash_command(name="hello", description="Say hello to the bot")
194
-
asyncdefsay_hello(ctx):
193
+
@bot.slash_command(name="hello", description="Say hello to the bot")
194
+
asyncdefhello(ctx: discord.ApplicationContext):
195
195
await ctx.respond("Hey!")
196
196
```
197
197
@@ -200,6 +200,8 @@ decorator to define a slash command. We specify the `name` and `description` arg
200
200
specified, the name of the slash command would be the function name and the command description would
201
201
be empty.
202
202
203
+
Optional: We type-hint the context parameter (`ctx`) as [`discord.ApplicationContext`](https://docs.pycord.dev/en/stable/api/application_commands.html#discord.ApplicationContext). In modern IDEs, type-hinting allows access to autocompletion and docstrings. You can read more about type-hinting [here](https://docs.python.org/3/library/typing.html).
204
+
203
205
Finally, you want to run the bot using the token specified in the `.env` file.
204
206
205
207
Now you have finished creating your first Pycord bot! What we have shown you is just the basic structure
@@ -223,8 +225,8 @@ bot = discord.Bot()
223
225
asyncdefon_ready():
224
226
print(f"{bot.user} is ready and online!")
225
227
226
-
@bot.slash_command(name="hello", description="Say hello to the bot")
227
-
asyncdefhello(ctx):
228
+
@bot.slash_command(name="hello", description="Say hello to the bot")
0 commit comments