diff --git a/discord/abc.py b/discord/abc.py index 7a7a8c4ba..f05e271ef 100644 --- a/discord/abc.py +++ b/discord/abc.py @@ -1170,7 +1170,6 @@ class GuildChannel: ------- ~discord.HTTPException Invite creation failed. - ~discord.NotFound The channel that was passed is a category or an invalid channel. @@ -1462,7 +1461,6 @@ class Messageable: *Typing* indicator will go away after 10 seconds, or after a message is sent. """ - channel = await self._get_channel() await self._state.http.send_typing(channel.id) @@ -1508,7 +1506,6 @@ class Messageable: :class:`~discord.Message` The message asked for. """ - channel = await self._get_channel() data = await self._state.http.get_message(channel.id, id) return self._state.create_message(channel=channel, data=data) @@ -1520,8 +1517,8 @@ class Messageable: Raises ------- - HTTPException - Acking failed. + ~discord.HTTPException + Acking the channel failed. """ channel = await self._get_channel() await self._state.http.ack_message(channel.id, channel.last_message_id or utils.time_snowflake(utils.utcnow())) @@ -1560,7 +1557,6 @@ class Messageable: List[:class:`~discord.Message`] The messages that are currently pinned. """ - channel = await self._get_channel() state = self._state data = await state.http.pins_from(channel.id) diff --git a/discord/activity.py b/discord/activity.py index e9005fa67..bd4a99e2e 100644 --- a/discord/activity.py +++ b/discord/activity.py @@ -754,7 +754,7 @@ class CustomActivity(BaseActivity): Technically, the name of custom activities is hardcoded to "Custom Status", and the state parameter has the actual custom text. This is confusing, so here, the name represents the actual custom text. - However, the "correct" way still works. + However, the "correct" way of initialization still works. Attributes ----------- diff --git a/discord/appinfo.py b/discord/appinfo.py index 26ec2cc66..415be02d2 100644 --- a/discord/appinfo.py +++ b/discord/appinfo.py @@ -135,6 +135,24 @@ class PartialApplication(Hashable): .. versionadded:: 2.0 + .. container:: operations + + .. describe:: x == y + + Checks if two applications are equal. + + .. describe:: x != y + + Checks if two applications are not equal. + + .. describe:: hash(x) + + Return the application's hash. + + .. describe:: str(x) + + Returns the application's name. + Attributes ------------- id: :class:`int` @@ -196,6 +214,9 @@ class PartialApplication(Hashable): self._state: ConnectionState = state self._update(data) + def __str__(self) -> str: + return self.name + def _update(self, data: PartialAppInfoPayload) -> None: self.id: int = int(data['id']) self.name: str = data['name'] @@ -504,6 +525,24 @@ class InteractionApplication(Hashable): .. versionadded:: 2.0 + .. container:: operations + + .. describe:: x == y + + Checks if two applications are equal. + + .. describe:: x != y + + Checks if two applications are not equal. + + .. describe:: hash(x) + + Return the application's hash. + + .. describe:: str(x) + + Returns the application's name. + Attributes ------------- id: :class:`int` @@ -537,6 +576,9 @@ class InteractionApplication(Hashable): self._state: ConnectionState = state self._update(data) + def __str__(self) -> str: + return self.name + def _update(self, data: dict) -> None: self.id: int = int(data['id']) self.name: str = data['name'] diff --git a/discord/commands.py b/discord/commands.py index ce53e2144..e79cae122 100644 --- a/discord/commands.py +++ b/discord/commands.py @@ -88,6 +88,9 @@ class ApplicationCommand(Protocol): target_channel: Optional[Messageable] default_permission: bool + def __str__(self) -> str: + return self.name + async def __call__(self, data, channel: Optional[Messageable] = None) -> Interaction: channel = channel or self.target_channel if channel is None: @@ -117,6 +120,24 @@ class ApplicationCommand(Protocol): class BaseCommand(ApplicationCommand, Hashable): """Represents a base command. + .. container:: operations + + .. describe:: x == y + + Checks if two commands are equal. + + .. describe:: x != y + + Checks if two commands are not equal. + + .. describe:: hash(x) + + Return the command's hash. + + .. describe:: str(x) + + Returns the command's name. + Attributes ---------- id: :class:`int` @@ -163,7 +184,7 @@ class BaseCommand(ApplicationCommand, Hashable): self._default_member_permissions = data['default_member_permissions'] def __repr__(self) -> str: - return f'<{self.__class__.__name__} id={self.id} name={self.name}>' + return f'<{self.__class__.__name__} id={self.id} name={self.name!r}>' def is_group(self) -> bool: """Query whether this command is a group. @@ -451,7 +472,7 @@ class SlashCommand(BaseCommand, SlashMixin): return await super().__call__(self._parse_kwargs(kwargs), channel) def __repr__(self) -> str: - BASE = f' str: + return self.name + def _walk_parents(self): parent = self.parent while True: @@ -554,7 +584,7 @@ class SubCommand(SlashMixin): return await super().__call__(options, channel) def __repr__(self) -> str: - BASE = f' str: + return self.name + def __repr__(self) -> str: - return f'