fix: '_io.BytesIO' object has no attribute 'name' in paginator#1869
fix: '_io.BytesIO' object has no attribute 'name' in paginator#1869BobDotCom merged 10 commits intoPycord-Development:masterfrom yoggys:paginator-fix
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") |
BobDotCom
left a comment
There was a problem hiding this comment.
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


Summary
Fix issue with
discord/ext/pages/pagination.pyupdate function while using e.g.io.BytesIO.Files that cannot be updated are skipped.
Discord forum post
Information
examples, ...).
Checklist
type: ignorecomments were used, a comment is also left explaining why.