1
0
Fork 0
mirror of https://github.com/uhIgnacio/EmoteManager.git synced 2024-08-15 02:23:13 +00:00

fix some discord.NotFound errors in paginator

This commit is contained in:
Benjamin Mintz 2019-08-05 15:39:42 +00:00
parent 165faa631f
commit 70c88e61f1

View file

@ -5,11 +5,9 @@ import typing
import discord
from discord.ext.commands import Context
# Copyright © 2016-2017 Pandentia and contributors
# https://github.com/Thessia/Liara/blob/75fa11948b8b2ea27842d8815a32e51ef280a999/cogs/utils/paginator.py
class Paginator:
def __init__(self, ctx: Context, pages: typing.Iterable, *, timeout=300, delete_message=False,
delete_message_on_timeout=False, text_message=None):
@ -81,6 +79,7 @@ class Paginator:
delete = self.delete_msg
if delete:
with contextlib.suppress(discord.HTTPException):
await self._message.delete()
else:
await self._clear_reactions()
@ -91,7 +90,10 @@ class Paginator:
await self._message.clear_reactions()
except discord.Forbidden:
for button in self.navigation:
with contextlib.suppress(discord.HTTPException):
await self._message.remove_reaction(button, self._message.author)
except discord.HTTPException:
pass
async def format_page(self):
self._embed.description = self.pages[self._page]
@ -126,7 +128,6 @@ class Paginator:
self._page = len(self.pages) - 1
await self.format_page()
class ListPaginator(Paginator):
def __init__(self, ctx, _list: list, per_page=10, **kwargs):
pages = []