Skip to content

Paginator fails with ctx.defer(ephemeral=True) #2173

Description

@MacKenzieHnC

Summary

Paginator fails when not labeled as ephemeral and responding to an ephemeral defer

Reproduction Steps

See minimal example and attempt to change pages

Minimal Reproducible Code

import discord
import os
from dotenv import load_dotenv
from discord.ext import pages

load_dotenv()
bot = discord.Bot()

@bot.slash_command()
async def paginator(ctx):
    paginator = pages.Paginator(["Pg 1", "Pg 2"])
    await ctx.defer(ephemeral=True)
    await paginator.respond(ctx.interaction)

bot.run(os.getenv('TOKEN'))

Expected Results

paginator works as intended

Actual Results

Paginator displays as expected, but page does not change and raises error:

File "<path-to-pycord>\commands\core.py", line 124, in wrapped
    ret = await coro(arg)
  File "<path-to-pycord>\commands\core.py", line 982, in _invoke
    await self.callback(ctx, **kwargs)
  File "<path-to-bot>\main.py", line 13, in paginator
    await paginator.respond(ctx.interaction)
  File "<path-to-pycord>\ext\pages\pagination.py", line 1171, in respond
    msg = await msg.channel.fetch_message(msg.id)
  File "<path-to-pycord>\abc.py", line 1696, in fetch_message
    data = await self._state.http.get_message(channel.id, id)
  File "<path-to-pycord>\http.py", line 367, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10008): Unknown Message

Intents

?

System Information

  • Python v3.10.3-final
  • py-cord v2.4.1-final
  • aiohttp v3.8.1
  • system info: Windows 10 10.0.19045

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

Easy workaround is await paginator.respond(ctx.interaction, ephemeral=True)

My guess is it's when it tries to edit the message, it can't find it.

Tested buttons and select menus using ctx.send_followup(<etc.>). Both worked as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions