Skip to content

Commit ca7e541

Browse files
DorukyumLulalabyBobDotCom
authored
refactor: make ApplicationContext.user non-optional (#1647)
Co-authored-by: Lala Sabathil <[email protected]> Co-authored-by: BobDotCom <[email protected]>
1 parent 5a617ab commit ca7e541

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

discord/commands/context.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,13 @@ def message(self) -> Message | None:
201201
return self.interaction.message
202202

203203
@cached_property
204-
def user(self) -> Member | User | None:
204+
def user(self) -> Member | User:
205205
"""Returns the user that sent this context's command.
206206
Shorthand for :attr:`.Interaction.user`.
207207
"""
208-
return self.interaction.user
208+
return self.interaction.user # type: ignore # command user will never be None
209209

210-
author: Member | User | None = user
210+
author = user
211211

212212
@property
213213
def voice_client(self) -> VoiceProtocol | None:

discord/interactions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class Interaction:
104104
application_id: :class:`int`
105105
The application ID that the interaction was for.
106106
user: Optional[Union[:class:`User`, :class:`Member`]]
107-
The user or member that sent the interaction.
107+
The user or member that sent the interaction. Will be `None` in PING interactions.
108108
message: Optional[:class:`Message`]
109109
The message that sent this interaction.
110110
token: :class:`str`

0 commit comments

Comments
 (0)