Fixed no `author` when intent is off
@@ -21,8 +21,8 @@ class SlashContext:
:ivar logger: Logger instance.
:ivar sent: Whether you sent the initial response.
:ivar guild: :class:`discord.Guild` instance of the command message.
- :ivar author: :class:`discord.Member` instance representing author of the command message.
- :ivar channel: :class:`discord.TextChannel` instance representing channel of the command message.
+ :ivar author: :class:`discord.Member` instance or user ID representing author of the command message.
+ :ivar channel: :class:`discord.TextChannel` instance or channel ID representing channel of the command message.
"""
def __init__(self,
@@ -39,8 +39,14 @@ class SlashContext:
self.logger = logger
self.sent = False
self.guild: discord.Guild = _discord.get_guild(int(_json["guild_id"]))
- self.author: discord.Member = self.guild.get_member(int(_json["member"]["user"]["id"])) if self.guild else None
- self.channel = self.guild.get_channel(int(_json["channel_id"])) if self.guild else None
+ self.author: typing.Union[discord.Member, int] = self.guild.get_member(int(_json["member"]["user"]["id"])) \
+ if self.guild else None
+ self.channel: typing.Union[discord.TextChannel, int] = self.guild.get_channel(int(_json["channel_id"])) \
+ if self.guild else None
+ if not self.author:
+ self.author = int(_json["member"]["user"]["id"])
+ if not self.channel:
+ self.channel = int(_json["channel_id"])
async def send(self,
send_type: int = 4,
