Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import TabItem from "@theme/TabItem";

On May 26, 2021, Discord added a new interaction called buttons. Instead of reactions, bots could now
send buttons and users could use them to interact with bots. This opened up a whole new world of
possibilities for bots. Soon after, developers made calculators, polls, and games like blackjack, Uno,
possibilities for bots. Soon after, developers made calculators, polls, and games like blackjack, Uno,
and even Minecraft! Buttons provided a clear and easy to use interface for interacting with bots.

So, let's see how you can add buttons to your bot!
Expand Down Expand Up @@ -102,7 +102,7 @@ about making your button do amazing things, while Pycord handles the rest!

Check out the [`discord.ButtonStyle`](https://docs.pycord.dev/en/master/api.html#discord.ButtonStyle) class for more information.

![Different Button Styles](../assets/interactions/button-styles.png)
![Different Button Styles](../../assets/interactions/button-styles.png)

You can set a button's style by adding the `style` argument in the [`discord.ui.button`](https://docs.pycord.dev/en/master/api.html#discord.ui.button) decorator.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ bot.run("TOKEN")

Here's what the registered subcommands will look like in the Slash Command Menu:

![Picture of the subcommands in the Slash Command Menu](../assets/interactions/groups-and-subcommands.jpg)
![Picture of the subcommands in the Slash Command Menu](../../assets/interactions/groups-and-subcommands.jpg)

You'll notice that there's the name of the Slash Command Group and then the name of the subcommand separated by a space.

Expand Down Expand Up @@ -218,8 +218,8 @@ bot = discord.Bot()
@bot.command()
# this explicitly tells pycord what types the options are instead of it figuring it out by itself
async def join(
ctx,
first: discord.Option(discord.SlashCommandOptionType.string),
ctx,
first: discord.Option(discord.SlashCommandOptionType.string),
second: discord.Option(discord.SlashCommandOptionType.string)
):
joined = first + second
Expand Down
55 changes: 55 additions & 0 deletions docs/Interactions/localizations.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
title: Localizations
---

Localizations are a way to make your bot more accessible to your users. You can localize the command
name, the names of any arguments, and any text that is displayed to the user.

## Syntax
```python
@commands.slash_command(
name="ping",
name_localizations={
"en-GB": "British_Ping"
},
description="Ping the bot",
description_localizations={
"en-GB": "British ping the bot"
},
options=[
Option(
name="Example",
name_localizations={
"en-GB": "British Example"
},
description="Example option that does nothing",
description_localizations={
"en-GB": "British example option that does nothing"
}
)
]
)
async def ping(ctx, example):
responses = {"en-US": "Pong!",
"en-GB": "British Pong!"}
await ctx.respond(responses.get(ctx.interaction.locale, responses['en-US']))

@commands.slash_command(
name="ping2",
name_localizations={
"en-GB": "British_Ping"
},
description="Ping the bot",
description_localizations={
"en-GB": "British ping the bot"
}
)
async def ping2(ctx, example: Option(str, "example", name_localizations={"en-GB": "British Example"}, description="Example option that does nothing", description_localizations={"en-GB": "British example option that does nothing"})):
responses = {"en-US": "Pong2!",
"en-GB": "British Pong2!"}
await ctx.respond(responses.get(ctx.interaction.locale, responses['en-US']))

```


- [`Locales`](https://discord.com/developers/docs/reference#locales) - List of valid locales recognized by Discord
17 changes: 12 additions & 5 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,18 @@ const sidebars = {
label: "Interactions",
link: { type: "doc", id: "Interactions/index" },
items: [
"Interactions/buttons",
"Interactions/dropdowns",
"Interactions/slash-commands",
"Interactions/context-menus",
"Interactions/modal-dialogs"
{
type: "category",
label: "Application Commands",
items: [
"Interactions/Application-Commands/slash-commands",
"Interactions/Application-Commands/context-menus",
"Interactions/Application-Commands/buttons",
"Interactions/Application-Commands/dropdowns",
"Interactions/Application-Commands/modal-dialogs"
]
},
"Interactions/localizations"
],
},
{
Expand Down