Browse Source

Use __getitem__ to access channel_id in MessageReference payloads

pull/7719/merge
nickofolas 3 years ago
committed by GitHub
parent
commit
59ebfefbf4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      discord/message.py
  2. 4
      discord/types/message.py

2
discord/message.py

@ -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

4
discord/types/message.py

@ -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

Loading…
Cancel
Save