Browse Source
Add __repr__ method to various classes
pull/10215/head
owocado
2 weeks ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with
18 additions and
0 deletions
-
discord/app_commands/installs.py
-
discord/app_commands/models.py
-
discord/ext/commands/parameters.py
-
discord/interactions.py
|
|
@ -57,6 +57,9 @@ class AppInstallationType: |
|
|
|
self._guild: Optional[bool] = guild |
|
|
|
self._user: Optional[bool] = user |
|
|
|
|
|
|
|
def __repr__(self): |
|
|
|
return f'<AppInstallationType guild={self.guild!r} user={self.user!r}>' |
|
|
|
|
|
|
|
@property |
|
|
|
def guild(self) -> bool: |
|
|
|
""":class:`bool`: Whether the integration is a guild install.""" |
|
|
@ -142,6 +145,9 @@ class AppCommandContext: |
|
|
|
self._dm_channel: Optional[bool] = dm_channel |
|
|
|
self._private_channel: Optional[bool] = private_channel |
|
|
|
|
|
|
|
def __repr__(self) -> str: |
|
|
|
return f'<AppCommandContext guild={self.guild!r} dm_channel={self.dm_channel!r} private_channel={self.private_channel!r}>' |
|
|
|
|
|
|
|
@property |
|
|
|
def guild(self) -> bool: |
|
|
|
""":class:`bool`: Whether the context allows usage in a guild.""" |
|
|
|
|
|
@ -1063,6 +1063,9 @@ class AppCommandPermissions: |
|
|
|
|
|
|
|
self.target: Union[Object, User, Member, Role, AllChannels, GuildChannel] = _object |
|
|
|
|
|
|
|
def __repr__(self) -> str: |
|
|
|
return f'<AppCommandPermissions id={self.id} type={self.type!r} guild={self.guild!r} permission={self.permission}>' |
|
|
|
|
|
|
|
def to_dict(self) -> ApplicationCommandPermissions: |
|
|
|
return { |
|
|
|
'id': self.target.id, |
|
|
@ -1106,6 +1109,9 @@ class GuildAppCommandPermissions: |
|
|
|
AppCommandPermissions(data=value, guild=guild, state=self._state) for value in data['permissions'] |
|
|
|
] |
|
|
|
|
|
|
|
def __repr__(self) -> str: |
|
|
|
return f'<GuildAppCommandPermissions id={self.id!r} guild_id={self.guild_id!r} permissions={self.permissions!r}>' |
|
|
|
|
|
|
|
def to_dict(self) -> Dict[str, Any]: |
|
|
|
return {'permissions': [p.to_dict() for p in self.permissions]} |
|
|
|
|
|
|
|
|
|
@ -109,6 +109,9 @@ class Parameter(inspect.Parameter): |
|
|
|
self._fallback = False |
|
|
|
self._displayed_name = displayed_name |
|
|
|
|
|
|
|
def __repr__(self) -> str: |
|
|
|
return f'<{self.__class__.__name__} name={self._name!r} required={self.required}>' |
|
|
|
|
|
|
|
def replace( |
|
|
|
self, |
|
|
|
*, |
|
|
|
|
|
@ -712,6 +712,9 @@ class InteractionCallbackResponse(Generic[ClientT]): |
|
|
|
self.type: InteractionResponseType = type |
|
|
|
self._update(data) |
|
|
|
|
|
|
|
def __repr__(self) -> str: |
|
|
|
return f'<InteractionCallbackResponse id={self.id} type={self.type!r}>' |
|
|
|
|
|
|
|
def _update(self, data: InteractionCallbackPayload) -> None: |
|
|
|
interaction = data['interaction'] |
|
|
|
|
|
|
|