#How to add the image to scheduled event?
1 messages · Page 1 of 1 (latest)
@summer forum are you using slash command?
async def command(..., blah blah , image: disnake.Attachment)
and use
image_for_event = await image.read()
and pass this var when u create event
wow. It's brilliant. also i am interested can we use image by ourself? i mean via link for example. i tried to search how to create Asset obj from an image or a link to the image and did not find anything
If you have link, use aiohttp and get bytes
Use __A__iohttp
__A__iohttp is an __a__synchronous HTTP Client/Server for Python. Best suited for __a__sync projects like discord.py. Documentation
Blocking
Libraries like requests and urllib can block the event loop for a period of time (until the request is finished/timed out).
The bot will not respond to anything (commands, etc).
Example
async with aiohttp.ClientSession() as cs:
async with cs.get('https://httpbin.org/json') as res:
# usually the status code (res.status) -
# - is checked before calling these
# and optionally also the content type (res.content_type)
# bytes? ---
# data = await res.read()
# text? (html, etc) ---
# data = await res.text()
# json? ---
# in this case it's json
data = await res.json()
# data is a python dict{} here
author = data['slideshow']['author']
print(author)
res.read()
did not get. is it necessary? maybe i am doing weird things but with default command it does not work
so read() give us needed type, yeah?
Yeah, bytes and u can pass bytes when u create event
ig i use it wrong cause i can not pass attachment argument
I rewrote to slash command and all works. Thank you so much! If u had not helped me i would have spent forever
Thx))
I love ur avatar