Skip to content

Commit

Permalink
Allow deletion race conditions to work with purge
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeshardmind authored Jun 14, 2024
1 parent fb12d3d commit 9eac365
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions discord/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
from .object import OLDEST_OBJECT, Object
from .context_managers import Typing
from .enums import ChannelType, InviteTarget
from .errors import ClientException
from .errors import ClientException, NotFound
from .mentions import AllowedMentions
from .permissions import PermissionOverwrite, Permissions
from .role import Role
Expand Down Expand Up @@ -122,7 +122,14 @@ def __repr__(self) -> str:

async def _single_delete_strategy(messages: Iterable[Message], *, reason: Optional[str] = None):
for m in messages:
await m.delete()
try:
await m.delete()
except NotFound as exc:
if exc.code == 10008:
continue # bulk deletion ignores not found messages, single deletion does not.
# several other race conditions with deletion should fail without continuing,
# such as the channel being deleted and not found.
raise


async def _purge_helper(
Expand Down

0 comments on commit 9eac365

Please sign in to comment.