@@ -648,6 +648,21 @@ def joined(self) -> bool:
648648 """
649649 return self .channel_id is not None
650650
651+ @property
652+ def channel (self ) -> Optional [Channel ]:
653+ """
654+ Returns the current channel, if cached.
655+ """
656+ return self ._client .cache [Channel ].get (self .channel_id )
657+
658+ @property
659+ def guild (self ) -> Optional [Guild ]:
660+ """
661+ Returns the current guild, if cached.
662+ """
663+
664+ return self ._client .cache [Guild ].get (self .guild_id )
665+
651666 async def mute_member (self , reason : Optional [str ] = None ) -> Member :
652667 """
653668 Mutes the current member.
@@ -689,15 +704,21 @@ async def get_channel(self) -> Channel:
689704
690705 :rtype: Channel
691706 """
692- return Channel (
693- ** await self ._client .get_channel (int (self .channel_id )),
694- _client = self ._client ,
695- )
707+ if channel := self .channel :
708+ return channel
696709
697- async def get_guild (self ) -> "Guild" :
710+ res = await self ._client .get_channel (int (self .channel_id ))
711+ return Channel (** res , _client = self ._client )
712+
713+ async def get_guild (self ) -> Guild :
698714 """
699715 Gets the guild in what the update took place.
700716
701717 :rtype: Guild
702718 """
703- return Guild (** await self ._client .get_guild (int (self .guild_id )), _client = self ._client )
719+
720+ if guild := self .guild :
721+ return guild
722+
723+ res = await self ._client .get_guild (int (self .guild_id ))
724+ return Guild (** res , _client = self ._client )
0 commit comments