How to upload a ScheduledEvent cover using py-cord / discord.py?
Question:
I understand from the API docs that there’s no way to upload an image when creating the scheduled event, but the edit()
has a cover
argument, so there must be way to at least add it later. The docs say it takes an Asset()
, but I don’t understand how to create such asset from e.g. a PNG file. Seems like it works in a different way than sending an image with an Embed()
as an attachment.
I’m using the py-cord, but I think discord.py should be similar or the same, I believe scheduled events is something that has been in the discord.py codebase before it was forked.
Answers:
The problem I was facing is specific for py-cord. Things are different in discord.py, with different names.
The cover
argument accepts bytes of the image to be uploaded. There was a bug in the documentation, which made me think that it accepts an Asset
. I found it out by reading the code directly and I’ve sent a fix so that the argument is documented properly.
from pathlib import Path
image_path = Path('images/my-image.jpg')
...
scheduled_event.edit(cover=image_path.read_bytes())
I understand from the API docs that there’s no way to upload an image when creating the scheduled event, but the edit()
has a cover
argument, so there must be way to at least add it later. The docs say it takes an Asset()
, but I don’t understand how to create such asset from e.g. a PNG file. Seems like it works in a different way than sending an image with an Embed()
as an attachment.
I’m using the py-cord, but I think discord.py should be similar or the same, I believe scheduled events is something that has been in the discord.py codebase before it was forked.
The problem I was facing is specific for py-cord. Things are different in discord.py, with different names.
The cover
argument accepts bytes of the image to be uploaded. There was a bug in the documentation, which made me think that it accepts an Asset
. I found it out by reading the code directly and I’ve sent a fix so that the argument is documented properly.
from pathlib import Path
image_path = Path('images/my-image.jpg')
...
scheduled_event.edit(cover=image_path.read_bytes())