Skip to content

Commit

Permalink
Allowing Context.me to return a ClientUser when the guilds intent is …
Browse files Browse the repository at this point in the history
…absent. (#1286)
  • Loading branch information
ashdouble authored Apr 24, 2022
1 parent 4279f2a commit 26f48e3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions discord/ext/commands/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,11 @@ def author(self) -> Union[User, Member]:
@discord.utils.cached_property
def me(self) -> Union[Member, ClientUser]:
"""Union[:class:`.Member`, :class:`.ClientUser`]:
Similar to :attr:`.Guild.me` except it may return the :class:`.ClientUser` in private message contexts.
Similar to :attr:`.Guild.me` except it may return the :class:`.ClientUser` in private message
message contexts, or when :meth:`Intents.guilds` is absent.
"""
# bot.user will never be None at this point.
return self.guild.me if self.guild is not None else self.bot.user # type: ignore
return self.guild.me if self.guild is not None and self.guild.me is not None else self.bot.user # type: ignore

@property
def voice_client(self) -> Optional[VoiceProtocol]:
Expand Down

0 comments on commit 26f48e3

Please sign in to comment.