Skip to content

Commit

Permalink
implement offset
Browse files Browse the repository at this point in the history
  • Loading branch information
Cryptex-github committed Nov 16, 2021
1 parent 8d83d88 commit 03b3df9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ferris/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async def send(self, content: str) -> Message:
)
return Message(self._connection, m)

async def fetch_messages(self, limit: int = 100) -> List[Message]:
async def fetch_messages(self, limit: int = 100, offset: int = 0) -> List[Message]:
"""
|coro|
Expand All @@ -90,14 +90,18 @@ async def fetch_messages(self, limit: int = 100) -> List[Message]:
The maximum number of messages to fetch.
Defaults to 100.
Set it to None to fetch all messages.
offset: int
The number of messages to skip.
Defaults to 0.
Returns
-------
List[Message]
"""
if limit is None:
limit = 9223372036854775807
data = await self._connection.api.channels(self.id).messages.get(params={'limit': limit})
data = await self._connection.api.channels(self.id).messages.get(params={'limit': limit, 'offset': offset})
return [Message(self._connection, m) for m in data['messages']]

async def edit(self, name: str) -> Channel:
Expand Down

0 comments on commit 03b3df9

Please sign in to comment.