Skip to content

Commit 2e256e8

Browse files
authored
feat: add locale and guild_locale to context (#1175)
1 parent 68049fb commit 2e256e8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

interactions/client/context.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from ..base import get_logger
1313
from ..utils.attrs_utils import ClientSerializerMixin, convert_int, define, field
1414
from ..utils.missing import MISSING
15-
from .enums import ComponentType, InteractionCallbackType, InteractionType
15+
from .enums import ComponentType, InteractionCallbackType, InteractionType, Locale
1616
from .models.command import Choice
1717
from .models.component import ActionRow, Button, Modal, SelectMenu, _build_components
1818
from .models.misc import InteractionData
@@ -66,6 +66,8 @@ class _Context(ClientSerializerMixin):
6666
responded: bool = field(default=False)
6767
deferred: bool = field(default=False)
6868
app_permissions: Permissions = field(converter=convert_int(Permissions), default=None)
69+
locale: Optional[Locale] = field(converter=Locale, default=None)
70+
guild_locale: Optional[Locale] = field(converter=Locale, default=None)
6971

7072
def __attrs_post_init__(self) -> None:
7173
if self.member and self.guild_id:
@@ -364,8 +366,8 @@ class CommandContext(_Context):
364366
:ivar Snowflake channel_id: The ID of the current channel.
365367
:ivar bool responded: Whether an original response was made or not.
366368
:ivar bool deferred: Whether the response was deferred or not.
367-
:ivar str locale: The selected language of the user invoking the interaction.
368-
:ivar str guild_locale: The guild's preferred language, if invoked in a guild.
369+
:ivar Optional[Locale] locale: The selected language of the user invoking the interaction.
370+
:ivar Optional[Locale] guild_locale: The guild's preferred language, if invoked in a guild.
369371
:ivar str app_permissions: Bitwise set of permissions the bot has within the channel the interaction was sent from.
370372
:ivar Client client: The client instance that the command belongs to.
371373
:ivar Command command: The command object that is being invoked.

0 commit comments

Comments
 (0)