From 59ebfefbf47dba18db7b797febb6de497ccef3b5 Mon Sep 17 00:00:00 2001 From: nickofolas <60761231+nickofolas@users.noreply.github.com> Date: Wed, 1 Jun 2022 01:32:42 -0500 Subject: [PATCH] Use __getitem__ to access channel_id in MessageReference payloads --- discord/message.py | 2 +- discord/types/message.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/discord/message.py b/discord/message.py index 355a43c1b..75afb5c77 100644 --- a/discord/message.py +++ b/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 diff --git a/discord/types/message.py b/discord/types/message.py index 178285ed7..fffe96113 100644 --- a/discord/types/message.py +++ b/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