#How to add the image to scheduled event?

1 messages · Page 1 of 1 (latest)

summer forum
#

It is written in docs that i should use "Asset" object. However, to create this type object i need some strange fields such as "key" or "state". I will not bbelieve that it is so hard to upload an image

fresh garnet
#

@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

summer forum
fresh garnet
#

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()

summer forum
summer forum
fresh garnet
#

Yeah, bytes and u can pass bytes when u create event

summer forum
#

ig i use it wrong cause i can not pass attachment argument

fresh garnet
#

Not attachment, image iirc
image=your bytes

#

Nice nick and banner btw

summer forum
#

I rewrote to slash command and all works. Thank you so much! If u had not helped me i would have spent forever

summer forum
summer forum