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