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.
This commit is contained in:
parent
92b0bc5804
commit
134506e6ba
@ -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"])
|
||||
|
@ -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"<TextChannel id='{self.id}' name='{self.name}' guild_id='{self.guild_id}'>"
|
||||
|
Loading…
x
Reference in New Issue
Block a user