Skip to content

Paginators don't display emojis properly after defer #1189

@Andell4301

Description

@Andell4301

Summary

If and only if you defer, paginators do not display custom emojis from servers the bot is not in on any pages after the first page.

Reproduction Steps

Set up a basic paginator that will display custom emojis from servers that the bot is NOT in. Defer, and then send the paginator.

Minimal Reproducible Code

import discord
from discord.ext import pages
bot = discord.Bot()

@bot.slash_command()
async def test(ctx):
    await ctx.defer()
    # Emojis from a server the bot is not in
    paginator = pages.Paginator(["<:pycord:881477002991915048>", "<:LovePycord:881608951668564098>"])
    await paginator.respond(ctx.interaction)

bot.run("Token")

Expected Results

The bot properly displays emojis.
Video of expected behavior after making the change in the additional context section:
https://user-images.githubusercontent.com/56235026/159435321-cda0b348-e45a-4833-bb98-08e43878d1a7.mp4

Actual Results

The bot does not display emojis once it has switched pages at least once.
Video of broken behavior:
https://user-images.githubusercontent.com/56235026/159435094-6b74f4fa-0e2d-4511-abc0-6c92a491b1ee.mp4

Intents

None

System Information

  • Python v3.10.1-final
  • py-cord v2.0.0-beta
    • py-cord pkg_resources: v2.0.0b5
  • aiohttp v3.8.1
  • system info: Windows 10 10.0.19044

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

This appears to have been broken by #1088.

Changing:

                # convert from WebhookMessage to Message reference to bypass 15min webhook token timeout
                msg = await msg.channel.fetch_message(msg.id)
            else:
                msg = await interaction.response.send_message(
                    content=page_content.content,
                    embeds=page_content.embeds,
                    view=self,
                    ephemeral=ephemeral,
                )
            if isinstance(msg, discord.WebhookMessage):
                self.message = await msg.channel.fetch_message(msg.id)
            elif isinstance(msg, discord.Message):
                self.message = msg
            elif isinstance(msg, discord.Interaction):
                self.message = await msg.original_message()

to

            else:
                msg = await interaction.response.send_message(
                    content=page_content.content,
                    embeds=page_content.embeds,
                    view=self,
                    ephemeral=ephemeral,
                )
            if isinstance(msg, (discord.WebhookMessage, discord.Message)):
                self.message = msg
            elif isinstance(msg, discord.Interaction):
                self.message = await msg.original_message()

appears to fix the issue.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

No status

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions