Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't pop key in MessageReference.with_state #1093

Merged
merged 1 commit into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions disnake/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ def __init__(
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
Expand Down Expand Up @@ -658,10 +658,9 @@ def __repr__(self) -> str:
return f"<MessageReference message_id={self.message_id!r} channel_id={self.channel_id!r} guild_id={self.guild_id!r}>"

def to_dict(self) -> MessageReferencePayload:
result: MessageReferencePayload = (
{"message_id": self.message_id} if self.message_id is not None else {}
)
result["channel_id"] = self.channel_id
result: MessageReferencePayload = {"channel_id": self.channel_id}
if self.message_id is not None:
result["message_id"] = self.message_id
if self.guild_id is not None:
result["guild_id"] = self.guild_id
if self.fail_if_not_exists is not None:
Expand Down
8 changes: 4 additions & 4 deletions disnake/types/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ class MessageApplication(TypedDict):
cover_image: NotRequired[str]


class MessageReference(TypedDict, total=False):
message_id: Snowflake
class MessageReference(TypedDict):
message_id: NotRequired[Snowflake]
channel_id: Snowflake
guild_id: Snowflake
fail_if_not_exists: bool
guild_id: NotRequired[Snowflake]
fail_if_not_exists: NotRequired[bool]


class RoleSubscriptionData(TypedDict):
Expand Down