mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-07-04 01:00:00 +00:00
Add Interaction.locale and Interaction.guild_locale
Co-authored-by: Stocker <44980366+StockerMC@users.noreply.github.com> Co-authored-by: Danny <Rapptz@users.noreply.github.com>
This commit is contained in:
parent
8213603822
commit
02310e4abd
@ -30,7 +30,7 @@ import asyncio
|
|||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from . import utils
|
from . import utils
|
||||||
from .enums import try_enum, InteractionType, InteractionResponseType
|
from .enums import try_enum, Locale, InteractionType, InteractionResponseType
|
||||||
from .errors import InteractionResponded, HTTPException, ClientException
|
from .errors import InteractionResponded, HTTPException, ClientException
|
||||||
from .flags import MessageFlags
|
from .flags import MessageFlags
|
||||||
from .channel import PartialMessageable, ChannelType
|
from .channel import PartialMessageable, ChannelType
|
||||||
@ -103,6 +103,10 @@ class Interaction:
|
|||||||
for 15 minutes.
|
for 15 minutes.
|
||||||
data: :class:`dict`
|
data: :class:`dict`
|
||||||
The raw interaction data.
|
The raw interaction data.
|
||||||
|
locale: :class:`Locale`
|
||||||
|
The locale of the user invoking the interaction.
|
||||||
|
guild_locale: Optional[:class:`Locale`]
|
||||||
|
The preferred locale of the guild the interaction was sent from, if any.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__slots__: Tuple[str, ...] = (
|
__slots__: Tuple[str, ...] = (
|
||||||
@ -116,6 +120,8 @@ class Interaction:
|
|||||||
'user',
|
'user',
|
||||||
'token',
|
'token',
|
||||||
'version',
|
'version',
|
||||||
|
'locale',
|
||||||
|
'guild_locale',
|
||||||
'_permissions',
|
'_permissions',
|
||||||
'_state',
|
'_state',
|
||||||
'_client',
|
'_client',
|
||||||
@ -143,6 +149,13 @@ class Interaction:
|
|||||||
self.guild_id: Optional[int] = utils._get_as_snowflake(data, 'guild_id')
|
self.guild_id: Optional[int] = utils._get_as_snowflake(data, 'guild_id')
|
||||||
self.application_id: int = int(data['application_id'])
|
self.application_id: int = int(data['application_id'])
|
||||||
|
|
||||||
|
self.locale: Locale = try_enum(Locale, data.get('locale', 'en-US'))
|
||||||
|
self.guild_locale: Optional[Locale]
|
||||||
|
try:
|
||||||
|
self.guild_locale = try_enum(Locale, data.get['guild_locale'])
|
||||||
|
except KeyError:
|
||||||
|
self.guild_locale = None
|
||||||
|
|
||||||
self.message: Optional[Message]
|
self.message: Optional[Message]
|
||||||
try:
|
try:
|
||||||
# The channel and message payloads are mismatched yet handled properly at runtime
|
# The channel and message payloads are mismatched yet handled properly at runtime
|
||||||
|
@ -201,6 +201,8 @@ InteractionData = Union[
|
|||||||
class _BaseInteractionOptional(TypedDict, total=False):
|
class _BaseInteractionOptional(TypedDict, total=False):
|
||||||
guild_id: Snowflake
|
guild_id: Snowflake
|
||||||
channel_id: Snowflake
|
channel_id: Snowflake
|
||||||
|
locale: str
|
||||||
|
guild_locale: str
|
||||||
|
|
||||||
|
|
||||||
class _BaseInteraction(_BaseInteractionOptional):
|
class _BaseInteraction(_BaseInteractionOptional):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user