Defxult / reactionmenu

A library to create a discord.py 2.0+ paginator. Supports pagination with buttons, reactions, and category selection using selects.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How do I use a local image file to an embed that's a page?

Dynamixus opened this issue · comments

Describe the bug

Uhm this is not exactly a Bug Report but there's no other type here. But I wanted to use a local file to set a thumbnail, but I don't see a functionality to it that's there in a normal embed where you can pass the file = f to your await.context.send(embed=e).

So I'm quite unsure how to get to doing this.
I'm using the code below as normally for my embeds.

Minimal Reproducible Code

f = discord.File("./images/bot_icon.png", filename="icon.png")
embed.set_thumbnail(url="attachment://icon.png")
embed.set_footer(text=f"Requested by {context.author}", icon_url = context.author.avatar.url)
await context.send(file=f, embed=embed)

Traceback

None

Library Version

  • Python v3.10.0-final
  • discord.py v2.3.1-final
  • aiohttp v3.8.4
  • system info: Windows 10 10.0.19044

Required Checklist

  • I am using discord.py 2.0 or higher
  • I am using reactionmenu 3.1.0 or higher
  • I have the required intents enabled

Additional Comments

No response

Code

@bot.command()
async def abc(ctx: commands.Context):
    menu = ReactionMenu(ctx, menu_type=ReactionMenu.TypeEmbed)
    
    f = discord.File("car.jpeg", filename="car.jpeg")
    embed = discord.Embed(title="With local image")
    embed.set_thumbnail(url="attachment://car.jpeg")
    embed.set_footer(text=f"Requested by {ctx.author}", icon_url = ctx.author.avatar.url)

    menu.add_page(embed, files=[f])
    menu.add_page(discord.Embed(title="Hello"))
    menu.add_buttons([ReactionButton.back(), ReactionButton.next()])
    
    await menu.start()

Produces

image

Explanation

Method .add_page() has a files parameter.