mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-08 04:38:42 +00:00
Allow deletion race conditions to work with purge
This commit is contained in:
parent
fb12d3d546
commit
9eac36501a
@ -49,7 +49,7 @@ from typing import (
|
|||||||
from .object import OLDEST_OBJECT, Object
|
from .object import OLDEST_OBJECT, Object
|
||||||
from .context_managers import Typing
|
from .context_managers import Typing
|
||||||
from .enums import ChannelType, InviteTarget
|
from .enums import ChannelType, InviteTarget
|
||||||
from .errors import ClientException
|
from .errors import ClientException, NotFound
|
||||||
from .mentions import AllowedMentions
|
from .mentions import AllowedMentions
|
||||||
from .permissions import PermissionOverwrite, Permissions
|
from .permissions import PermissionOverwrite, Permissions
|
||||||
from .role import Role
|
from .role import Role
|
||||||
@ -122,7 +122,14 @@ _undefined: Any = _Undefined()
|
|||||||
|
|
||||||
async def _single_delete_strategy(messages: Iterable[Message], *, reason: Optional[str] = None):
|
async def _single_delete_strategy(messages: Iterable[Message], *, reason: Optional[str] = None):
|
||||||
for m in messages:
|
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(
|
async def _purge_helper(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user