interactions-py / interactions.py

A highly extensible, easy to use, and feature complete bot framework for Discord
https://interactions-py.github.io/interactions.py/
MIT License
839 stars 184 forks source link

[BUG] Paginator extension throws on footer #1567

Open i0bs opened 1 year ago

i0bs commented 1 year ago

Library Version

5.10.0

Describe the Bug

Using Paginator from the interactions.ext.paginators extension will throw a TypeError for missing embed footers.

From @algorythm_cs on Discord:

  File "...\interactions\ext\paginators.py", line 346, in to_dict
    page.set_footer(f"Page {self.page_index+1}/{len(self.pages)}")
TypeError: Embed.set_footer() takes 1 positional argument but 2 were given

After checking the extension and Embed code, I've flagged the bug as failing to rewrite our embed, due to the method's return:

https://github.com/interactions-py/interactions.py/blob/0129d53b264c72180fc5a616cd95de54da36d1d8/interactions/models/discord/embed.py#L400-L410

This is neglected when converting embeds to dictionaries within the paginator:

https://github.com/interactions-py/interactions.py/blob/0129d53b264c72180fc5a616cd95de54da36d1d8/interactions/ext/paginators.py#L345-L346

Steps to Reproduce

  1. Create a variable containing an Embed omitting footer.
  2. Create a variable declaring a Paginator, whether from one embed, or numerous.
  3. Attempt to use .send() on the paginator.

Expected Results

A paginator should be sent without any bugs (assuming a pragmatic approach)

Minimal Reproducible Code

client = Client(...)
embeds = [Embed(title="foo")]

@slash_command()
async def replicate_bug(ctx):
    paginator = Paginator.create_from_embeds(client, *embeds)
    await paginator.send()
    await ctx.send("bar")

Traceback

No response

Checklist

Additional Information

No response

AstreaTSS commented 11 months ago

I can't seem to replicate this at all.

AstreaTSS commented 11 months ago

To clarify, the "Minimal Reproducible Code" actually works as is with no issues, and the original code was posted in a pastebin that's long since gone. It definitely isn't because of the return type, because while set_footer does return itself, the reference of the original embed should be updated anyways due to how Python works (the return is simply for chaining commands together, not to note that it's a new copy of the embed).

The error in general is very strange. At this point, page absolutely should be an Embed, and Embed has a set_footer function that has two non-self positional arguments. This suggests that either the user who had this bug had a corrupt installation, or this function lost a positional argument due to some situation. Needless to say, it's hard to find out.