-
-
Notifications
You must be signed in to change notification settings - Fork 465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: '_io.BytesIO' object has no attribute 'name' in paginator #1869
Conversation
for more information, see https://pre-commit.ci
@yoggys, Thanks for this! |
@yoggys Has the updated code been tested to make sure this works? If so, please provide screenshots and code usages so I can test this out myself with my test build. |
Me and Bob are talking about the |
Here's a screenshot of the embed successfully having the proper image, which was sent with Here's my code: with open(file_name, 'rb') as fp:
data = io.BytesIO(fp.read())
file = discord.File(data, file_name) |
import logging
import sys
from io import StringIO
import discord
from discord.ext import commands, pages
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
class Bot(commands.Bot):
def __init__(self):
super().__init__(command_prefix = '.', intents=discord.Intents.all())
bot = Bot()
@bot.slash_command()
async def teststringio(
ctx: discord.ApplicationContext,
):
test = discord.Embed(title="test", description="test")
p = []
for i in range(5):
p.append(pages.Page(embeds=[test], files=[discord.File(StringIO(f"{i}"), f"test{i}.txt")]))
paginator = pages.Paginator(pages=p, disable_on_timeout=True)
await paginator.respond(ctx.interaction)
@bot.slash_command()
async def testreadingbuffer(
ctx: discord.ApplicationContext,
):
test = discord.Embed(title="test", description="test")
p = []
for i in range(5):
p.append(pages.Page(embeds=[test], files=[discord.File(f"test{i}.txt")]))
paginator = pages.Paginator(pages=p, disable_on_timeout=True)
await paginator.respond(ctx.interaction)
bot.run("token") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check the suggestion I added. Also, please add a changelog entry.
Co-authored-by: BobDotCom <71356958+BobDotCom@users.noreply.github.com> Signed-off-by: Mateusz <61660055+yoggys@users.noreply.github.com>
Co-authored-by: BobDotCom <71356958+BobDotCom@users.noreply.github.com> Signed-off-by: Mateusz <61660055+yoggys@users.noreply.github.com>
whops, wrong section - i moved it to |
Fixes compatibility with older python versions
for more information, see https://pre-commit.ci
Signed-off-by: BobDotCom <71356958+BobDotCom@users.noreply.github.com>
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well then, lgtm
here we go~
Summary
Fix issue with
discord/ext/pages/pagination.py
update function while using e.g.io.BytesIO
.Files that cannot be updated are skipped.
Discord forum post
Information
examples, ...).
Checklist
type: ignore
comments were used, a comment is also left explaining why.