2424
2525from copy import copy
2626from datetime import datetime
27- from typing import Any , Self , TypeVar , cast
27+ from typing import Any , TypeVar , cast
2828
29- from typing_extensions import override
29+ from typing_extensions import override , Self
3030
3131from discord .abc import GuildChannel , PrivateChannel
3232from discord .app .event_emitter import Event
@@ -53,15 +53,14 @@ async def __load__(cls, data: dict[str, Any], state: ConnectionState) -> Self |
5353
5454 guild_id = get_as_snowflake (data , "guild_id" )
5555 guild = await state ._get_guild (guild_id )
56- if guild is not None :
57- # the factory can't be a DMChannel or GroupChannel here
58- channel = factory (guild = guild , state = self , data = data ) # type: ignore # noqa: F821 # self is unbound
59- guild ._add_channel (channel ) # type: ignore
60- self = cls ()
61- self .__dict__ .update (channel .__dict__ )
62- return self
63- else :
56+ if guild is None :
6457 return
58+ # the factory can't be a DMChannel or GroupChannel here
59+ channel = factory (guild = guild , state = state , data = data ) # type: ignore
60+ guild ._add_channel (channel ) # type: ignore
61+ self = cls ()
62+ self ._populate_from_slots (channel )
63+ return self
6564
6665
6766class PrivateChannelUpdate (Event , PrivateChannel ):
@@ -76,7 +75,7 @@ def __init__(self) -> None: ...
7675 async def __load__ (cls , data : tuple [PrivateChannel | None , PrivateChannel ], state : ConnectionState ) -> Self | None :
7776 self = cls ()
7877 self .old = data [0 ]
79- self .__dict__ . update (data [1 ]. __dict__ )
78+ self ._populate_from_slots (data [1 ])
8079 return self
8180
8281
@@ -92,7 +91,7 @@ def __init__(self) -> None: ...
9291 async def __load__ (cls , data : tuple [GuildChannel | None , GuildChannel ], state : ConnectionState ) -> Self | None :
9392 self = cls ()
9493 self .old = data [0 ]
95- self .__dict__ . update (data [1 ]. __dict__ )
94+ self ._populate_from_slots (data [1 ])
9695 return self
9796
9897
@@ -139,7 +138,7 @@ async def __load__(cls, data: dict[str, Any], state: ConnectionState) -> Self |
139138 if channel is not None :
140139 guild ._remove_channel (channel )
141140 self = cls ()
142- self .__dict__ . update (channel . __dict__ )
141+ self ._populate_from_slots (channel )
143142 return self
144143
145144
0 commit comments