#Paginator Delete after timeout

1 messages · Page 1 of 1 (latest)

tawdry beacon
#

Someone know is there a way to delete the paginator after timeout

I know there is a way to delete after time with
ctx.respond("Text", delete_after=30)

But this will delete it also when i interact with the paginator buttons

So what i need is that it will delete after the on_timeout
on the button it was easy to implement but i didn't know how to do it in the paginator

    async def on_timeout(self):
        self.disable_all_items()
        if isinstance(self.message, discord.Interaction):
            await self.message.edit_original_response(view=self)
        else:
            await self.message.delete()

This is an example how i do it on the select view that works

my script is

async def leaderboard(self, ctx, guild):
    async def on_timeout(self):
        self.disable_all_items()
        if isinstance(self.message, discord.Interaction):
            self.message.delete()
        else:
            self.message.delete()

------- -variable etc. ---------

    paginator = Paginator(pages=pages, timeout=30)
tawdry beacon
#

I found the solution ^^

class TestPaginator(Paginator):
def init(self, pages, timeout):
super().init(pages, timeout=timeout)

async def on_timeout(self) -> None:
    print("Test")
    if isinstance(self.message, discord.Interaction):
        await self.message.delete()
    else:
        await self.message.delete()