From 134506e6baad73c3a0b8d06e454e13550021a52e Mon Sep 17 00:00:00 2001 From: Slipstream Date: Tue, 10 Jun 2025 18:06:50 -0600 Subject: [PATCH] Removes duplicate code and unnecessary imports Cleans up codebase by removing redundant type casting, unused imports, and duplicate method definitions. Eliminates duplicate embeds list comprehension that was accidentally duplicated. Removes unnecessary typing imports and cast operation that were no longer needed. Deletes duplicate history method implementation that was redundant. --- disagreement/interactions.py | 5 +---- disagreement/models.py | 30 +----------------------------- 2 files changed, 2 insertions(+), 33 deletions(-) diff --git a/disagreement/interactions.py b/disagreement/interactions.py index 35fab77..8bca1eb 100644 --- a/disagreement/interactions.py +++ b/disagreement/interactions.py @@ -395,8 +395,6 @@ class Interaction: async def respond_modal(self, modal: "Modal") -> None: """|coro| Send a modal in response to this interaction.""" - from typing import Any, cast - payload = InteractionResponsePayload( type=InteractionCallbackType.MODAL, data=modal.to_dict(), @@ -404,7 +402,7 @@ class Interaction: await self._client._http.create_interaction_response( interaction_id=self.id, interaction_token=self.token, - payload=cast(Any, payload.to_dict()), + payload=payload, ) async def edit( @@ -506,7 +504,6 @@ class InteractionCallbackData: self.content: Optional[str] = data.get("content") self.embeds: Optional[List[Embed]] = ( [Embed(e) for e in data.get("embeds", [])] if data.get("embeds") else None - [Embed(e) for e in data.get("embeds", [])] if data.get("embeds") else None ) self.allowed_mentions: Optional[AllowedMentions] = ( AllowedMentions(data["allowed_mentions"]) diff --git a/disagreement/models.py b/disagreement/models.py index 6887324..1f6e9fc 100644 --- a/disagreement/models.py +++ b/disagreement/models.py @@ -1087,6 +1087,7 @@ class TextChannel(Channel): ) self.last_pin_timestamp: Optional[str] = data.get("last_pin_timestamp") + def history( self, *, @@ -1142,35 +1143,6 @@ class TextChannel(Channel): self._client._messages.pop(mid, None) return ids - async def history( - self, - *, - limit: Optional[int] = 100, - before: "Snowflake | None" = None, - ): - """An async iterator over messages in the channel.""" - - params: Dict[str, Union[int, str]] = {} - if before is not None: - params["before"] = before - - fetched = 0 - while True: - to_fetch = 100 if limit is None else min(100, limit - fetched) - if to_fetch <= 0: - break - params["limit"] = to_fetch - messages = await self._client._http.request( - "GET", f"/channels/{self.id}/messages", params=params.copy() - ) - if not messages: - break - params["before"] = messages[-1]["id"] - for msg in messages: - yield Message(msg, self._client) - fetched += 1 - if limit is not None and fetched >= limit: - return def __repr__(self) -> str: return f""