From 70c88e61f182db3670352f7a0c7d7b26ec69ef12 Mon Sep 17 00:00:00 2001 From: Benjamin Mintz Date: Mon, 5 Aug 2019 15:39:42 +0000 Subject: [PATCH] fix some discord.NotFound errors in paginator --- utils/paginator.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/utils/paginator.py b/utils/paginator.py index 41b52fd..6fc6993 100644 --- a/utils/paginator.py +++ b/utils/paginator.py @@ -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,7 +79,8 @@ class Paginator: delete = self.delete_msg if delete: - await self._message.delete() + with contextlib.suppress(discord.HTTPException): + await self._message.delete() else: await self._clear_reactions() self._stopped = True @@ -91,7 +90,10 @@ class Paginator: await self._message.clear_reactions() except discord.Forbidden: 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): 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 = []