Skip to content

Commit

Permalink
Fix iterator instance check + don't re-throw forbidden on reaction add
Browse files Browse the repository at this point in the history
  • Loading branch information
FasterSpeeding committed Nov 23, 2020
1 parent 59d56b3 commit 7b2b726
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions yuyo/paginaton.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ def __init__(
),
timeout: datetime.timedelta = datetime.timedelta(seconds=30),
) -> None:
if isinstance(iterator, typing.Iterator):
if not isinstance(iterator, (typing.Iterator, typing.AsyncIterator)):
raise ValueError(f"Invalid value passed for `iterator`, expected an iterator but got {type(iterator)}")

self._authors = set(map(snowflakes.Snowflake, authors))
Expand Down Expand Up @@ -450,7 +450,7 @@ async def _delete_message(self, message_id: snowflakes.Snowflake, /) -> None:
try:
await self._rest.rest.delete_message(self._channel_id, message_id)

except (errors.NotFoundError, errors.ForbiddenError): # TODO: better permission handling.
except (errors.NotFoundError, errors.ForbiddenError): # TODO: attempt to check permissions first
return

except errors.InternalServerError:
Expand Down Expand Up @@ -598,10 +598,14 @@ async def open(
try:
await self._rest.rest.add_reaction(self._channel_id, message, emoji)

except (errors.NotFoundError, errors.ForbiddenError):
except errors.NotFoundError:
self._message_id = None
raise

except errors.ForbiddenError: # TODO: attempt to check permissions first
# If this is reached then we just don't have reaction permissions in the channel.
return created_message

except errors.RateLimitedError as exc:
if exc.retry_after > max_backoff:
raise
Expand Down

0 comments on commit 7b2b726

Please sign in to comment.