Discord Bot: I want to send random quotes from zenquotes.io, but the code does not produce anything nor do I get an error

async def get_quote():
    async with aiohttp.ClientSession() as session:
        async with session.get("https://zenquotes.io/api/random") as response:
            json_data = json.loads(response.text)
            quote = json_data[0]["q"]
            return (quote) 

@client.command(aliases=["wow"])
async def inspire(ctx):
    quote = await get_quote()
    await ctx.send(quote)

I was told to use aiohttp instead of requests module, so I did. Then when I used aiohttp, it said module ‘aiohttp’ has no attribute ‘get’. So this is my final code right now. Please help.

Answer

response.text is an async function, not an attribute, so it must be called and awaited. Try:

async def get_quote():
    async with aiohttp.ClientSession() as session:
        async with session.get("https://zenquotes.io/api/random") as response:
            json_data = json.loads(await response.text())
            quote = json_data[0]["q"]
            return quote