Skip to content

Add a way to pass an interaction for a paginator to update #1093

@Andell4301

Description

@Andell4301

Summary

Addition of a way to pass an existing interaction for a paginator to update

What is the feature request for?

discord.ext.pages

The Problem

Currently, I don't know of a clean and simple way to tell a paginator to update an existing interaction as opposed to sending the paginator as a new response, as in the following scenario:

if condition:
  initial = await ctx.respond(embed=some_embed, view=some_view)
else:
  initial = None

if initial:
"""
Edit initial to be the paginator. So replace its embeds, message content, view, etc. as if it was a totally new response, but its editing the existing interaction
"""
else:
  await paginator.respond(ctx.interaction)

The Ideal Solution

To be able to pass in an interaction for the paginator to edit

The Current Solution

I was able to replicate the functionality I want by doing the following:

if initial:
    paginator.user = ctx.author
    paginator.message = await initial.original_message()
    paginator.update_buttons()
    embed = paginator.pages[paginator.current_page]
    embed = paginator.get_page_content(embed)
    await initial.edit_original_message(view=paginator, embeds=embed)
else:
    await paginator.respond(ctx.interaction)

Additional Context

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions