Closed
Description
Summary
Embed.thumbnail.url
returns KeyError
from function expecting more keys in the thumbnail data
Reproduction Steps
This only occurs on master possibly since the embed refactor: #2063
- Add a thumbnail to an embed
- Get the thumbnail url using
Embed.thumbnail.url
Minimal Reproducible Code
@bridge.bridge_command(name='test', description="Hello World")
@commands.cooldown(**config.default_cooldown_options)
@commands.bot_has_permissions(send_messages=True)
async def test_cmd(self, ctx: bridge.BridgeContext):
embed = discord.Embed(title="Hello World",
thumbnail="https://i.ytimg.com/vi/dQw4w9WgXcQ/default.jpg")
thumb_url = embed.thumbnail.url
await ctx.respond(embed=embed)
Expected Results
On the stable 2.4.1 and earlier, it just returns the url as a string or None if there isn't one
Actual Results
The classmethod from_dict
for EmbedMedia
on line 184 in embeds.py
is expecting width
and height
keys in the data provided. However, the data only has the url
so it raises a KeyError as follows:
Traceback:
File "bot-dir/venv/lib/python3.11/site-packages/discord/commands/core.py", line 124, in wrapped
ret = await coro(arg)
^^^^^^^^^^^^^^^
File "bot-dir/venv/lib/python3.11/site-packages/discord/commands/core.py", line 978, in _invoke
await self.callback(self.cog, ctx, **kwargs)
File "bot-dir/cogs/testing.py", line 27, in test_cmd
thumb_url = embed.thumbnail.url
^^^^^^^^^^^^^^^
File "bot-dir/venv/lib/python3.11/site-packages/discord/embeds.py", line 687, in thumbnail
return EmbedMedia.from_dict(thumb)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "bot-dir/venv/lib/python3.11/site-packages/discord/embeds.py", line 184, in from_dict
self.height = int(data["height"])
~~~~^^^^^^^^^^
KeyError: 'height'.
Intents
all
System Information
- Python v3.11.3-final
- py-cord v2.4.1-final
- aiohttp v3.8.4
- system info: Linux 6.3.6-arch1-1 Update README.rst #1 SMP PREEMPT_DYNAMIC Mon, 05 Jun 2023 15:12:57 +0000
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
No response