Skip to content

Commit 1c1852b

Browse files
committed
docs: Add an example how to use Localizations.from_target
1 parent adfe2a0 commit 1c1852b

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

discord/application_commands.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
from .guild import Guild
5858
from .state import ConnectionState
5959
from .ext.commands import Cog, Greedy, Converter
60-
from .interactions import ApplicationCommandInteraction
60+
from .interactions import ApplicationCommandInteraction, BaseInteraction
6161

6262
__all__ = (
6363
'Localizations',
@@ -111,6 +111,21 @@ class Localizations:
111111
ukrainian='Привіт світ!'
112112
)
113113
114+
You can also use this to build localized responses.
115+
116+
.. code-block:: python3
117+
118+
@slash_command(name='hello', description='Says hello to you.')
119+
async def hello_command(interaction: ApplicationCommandInteraction):
120+
response = Localizations(
121+
en_US='Hello World!',
122+
de='Hallo Welt!',
123+
fr='Bonjour le monde!'
124+
uk='Привіт світ!',
125+
...
126+
).from_target(interaction) # of curse you can store the localizations somewhere else and import/load them.
127+
await interaction.respond(response)
128+
114129
Parameters
115130
----------
116131
kwargs: Any

0 commit comments

Comments
 (0)