Use __getitem__ to access channel_id in MessageReference payloads

This commit is contained in:
nickofolas 2022-06-01 01:32:42 -05:00 committed by GitHub
parent e543abd950
commit 59ebfefbf4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -468,7 +468,7 @@ class MessageReference:
def with_state(cls, state: ConnectionState, data: MessageReferencePayload) -> Self:
self = cls.__new__(cls)
self.message_id = utils._get_as_snowflake(data, 'message_id')
self.channel_id = int(data.pop('channel_id'))
self.channel_id = int(data['channel_id'])
self.guild_id = utils._get_as_snowflake(data, 'guild_id')
self.fail_if_not_exists = data.get('fail_if_not_exists', True)
self._state = state

View File

@ -25,7 +25,7 @@ DEALINGS IN THE SOFTWARE.
from __future__ import annotations
from typing import List, Literal, Optional, TypedDict, Union
from typing_extensions import NotRequired
from typing_extensions import NotRequired, Required
from .snowflake import Snowflake, SnowflakeList
from .member import Member, UserWithMember
@ -88,7 +88,7 @@ class MessageApplication(TypedDict):
class MessageReference(TypedDict, total=False):
message_id: Snowflake
channel_id: Snowflake
channel_id: Required[Snowflake]
guild_id: Snowflake
fail_if_not_exists: bool