#i need a hand with buttons
1 messages · Page 1 of 1 (latest)
do you want to have multiple buttons?
one button to repeat the animal and then a dropdown to change it
thats what it looks like rn
do you have an API object instance or using async with?
im using aiohttp to send a request to an api
because if you created a api class you could use view rather than low-level
then you could use low-level and have a button handler
elif selected== "Foxes":
async with aiohttp.ClientSession() as session:
async with session.get(f"https://some-random-api.ml/animal/fox") as resp:
data = json.loads(await resp.text())
foxEmbed = disnake.Embed(
title = "Foxes!",
colour = disnake.Colour.random()
).set_image(
url = data['image']
).set_footer(
text = data['fact'])
await inter.response.send_message(embed = foxEmbed)
thats the base for it
i just change the session.get() url
and the selected
then the data parts
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
thats the whole animals.py file
ah the api doesn't return the same data?
I mean for data other than the image
yeah the cat and dog apis have breed data
the fox one has fox facts
the duck one hasnt got anything besides a message saying powered by random-d.uk
ah
without taking it extremely complicated, this is as simple as ive got it
then send the embed with a button and listen for it
i had a previous version for the zookeeper using slash command parameters
don't forget to create a custom id with the endpoint
or well
the animal and you can have a dict with animal key and api value
might do a quick rewrite of sorts
because i think i found a way
but idk
because i dont know how to make it run the request again basically
without copy pasting the code
sounds complicated