Skip to content

Commit

Permalink
Fix member.ban and TypeError in guild.ban (#1666)
Browse files Browse the repository at this point in the history
* Adjust defaults for `delete_message_`

* Update Member.ban to support delete_message_seconds

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update guild.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* update default

* Fix CI

* update defaults

Co-authored-by: BobDotCom <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 4, 2022
1 parent 30e0de4 commit d5c59ea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
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

0 comments on commit d5c59ea

Please sign in to comment.