From 26f48e3a0acfc22c18cdcddfe65321157484fe82 Mon Sep 17 00:00:00 2001 From: nbowen Date: Sat, 23 Apr 2022 17:34:48 -0700 Subject: [PATCH] Allowing Context.me to return a ClientUser when the guilds intent is absent. (#1286) --- discord/ext/commands/context.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/discord/ext/commands/context.py b/discord/ext/commands/context.py index d49b16fd88..de2097f3f3 100644 --- a/discord/ext/commands/context.py +++ b/discord/ext/commands/context.py @@ -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]: