Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix member.ban and TypeError in guild.ban #1666

Merged
merged 10 commits into from
Oct 4, 2022
4 changes: 3 additions & 1 deletion discord/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -3071,7 +3071,9 @@ async def ban(
"delete_message_seconds and delete_message_days are mutually exclusive."
)

if not (0 <= delete_message_seconds <= 604800):
if delete_message_seconds is not None and not (
0 <= delete_message_seconds <= 604800
):
raise TypeError(
"delete_message_seconds must be between 0 and 604800 seconds."
)
Expand Down
8 changes: 6 additions & 2 deletions discord/member.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,15 +663,19 @@ def timed_out(self) -> bool:
async def ban(
self,
*,
delete_message_days: Literal[0, 1, 2, 3, 4, 5, 6, 7] = 1,
delete_message_seconds: int | None = None,
delete_message_days: Literal[0, 1, 2, 3, 4, 5, 6, 7] | None = None,
reason: str | None = None,
) -> None:
"""|coro|

Bans this member. Equivalent to :meth:`Guild.ban`.
"""
await self.guild.ban(
self, reason=reason, delete_message_days=delete_message_days
self,
reason=reason,
delete_message_seconds=delete_message_seconds,
delete_message_days=delete_message_days,
)

async def unban(self, *, reason: str | None = None) -> None:
Expand Down