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

prod sync #453

Merged
merged 1 commit into from
Apr 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
added type hinting in code examples (#451)
Signed-off-by: Lala Sabathil <[email protected]>
Co-authored-by: Lala Sabathil <[email protected]>
Co-authored-by: Dorukyum <[email protected]>
3 people authored Apr 20, 2024

Partially verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
commit 39a721df152b2c70d3f67d2073f8f02627391461
14 changes: 8 additions & 6 deletions docs/getting-started/creating-your-first-bot.mdx
Original file line number Diff line number Diff line change
@@ -134,8 +134,8 @@ bot = discord.Bot()
async def on_ready():
print(f"{bot.user} is ready and online!")

@bot.slash_command(name = "hello", description = "Say hello to the bot")
async def hello(ctx):
@bot.slash_command(name="hello", description="Say hello to the bot")
async def hello(ctx: discord.ApplicationContext):
await ctx.respond("Hey!")

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
event that is automatically called when the bot is ready to use.

```py
@bot.slash_command(name = "hello", description = "Say hello to the bot")
async def say_hello(ctx):
@bot.slash_command(name="hello", description="Say hello to the bot")
async def hello(ctx: discord.ApplicationContext):
await ctx.respond("Hey!")
```

@@ -200,6 +200,8 @@ decorator to define a slash command. We specify the `name` and `description` arg
specified, the name of the slash command would be the function name and the command description would
be empty.

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).

Finally, you want to run the bot using the token specified in the `.env` file.

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()
async def on_ready():
print(f"{bot.user} is ready and online!")

@bot.slash_command(name = "hello", description = "Say hello to the bot")
async def hello(ctx):
@bot.slash_command(name="hello", description="Say hello to the bot")
async def hello(ctx: discord.ApplicationContext):
await ctx.send("Hey!")

bot.run("TOKEN")