#Ephemeral message not ephemeral?

1 messages · Page 1 of 1 (latest)

rocky spade
#

I have the following piece of code

# if the user isn't found, show an ephemeral message
  if response.json().get("error") is not None:
    # with an ephemeral message
    ctx.respond(f"I couldn't find a Last.fm user with the name **{user}**. Please try again.", ephemeral=True)
    return

The weird thing is that the message doesn't appear to be ephemeral, seems like it's being sent as a regular message and I have no idea why, any help?

#

(I know it's not really needed but this is what I get)

hardy harness
#

those arent the same messages

#

also you arent awaiting ctx.respond ?

rocky spade
hardy harness
#

can you share pip list

rocky spade
#

sure thing, one second

#

actually I just noticed that I'm in the wrong venv environment, the packages should still be there though

rocky spade
#

I started the project during the last few days, plus it works on other messages

#

not sure what's going on to be honest, I could just send the whole file on a hastebin link, though the code is really really bad, hope that's not a problem

hardy harness
#

ngl idk what could cause this either

rocky spade
#

again, it's a mess, going for the raw first improve later way 😅

hardy harness
rocky spade
#

oh

#

thanks!

#

I'll try right away, just a second

hardy harness
#

||ok on second thoughts i doubt thats the reason||

rocky spade
#

from what I'm seeing it doesn't have an ephermal argument

#

the response takes less than 3 seconds, I could try without and see if it changes anything

#

yeap without defer it seems to be working

hardy harness
hardy harness
#

btw dont use requests library

#

.tag requests

spring vesselBOT
#

Why you should not use the requests library for your bot
requests is a popular HTTP library for Python. It is however not a good option for Discord bots, since it is not async and blocking.

This essentially means that your bot will not be able to execute any code at all while a request is happening. Since requests usually take a few seconds to complete, this can have a detrimental effect on your bot's performance. E.g if a user executes a command that performs a request taking 5 seconds to complete, no one else will be able to use your bot for those 5 seconds.

Please look at using a HTTP library that has async support, such as aiohttp or httpx

hardy harness
#

.tag aiohttp

spring vesselBOT
#

Use aiohttp.
requests and urllib are blocking. Do not use these libraries within your asynchronous code as they're not asynchronous.
(https://docs.pycord.dev/en/stable/faq.html#what-does-blocking-mean)

Py-cord uses aiohttp, so it should already be installed. An example of code using aiohttp and Py-cord:

async with aiohttp.ClientSession() as cs:
    async with cs.get('https://httpbin.org/json%27') as r:
        res = await r.json()  # returns dict
        await ctx.send(res['slideshow']['author']) 

For more help, see aiohttp's documentation: https://docs.aiohttp.org/en/stable/

rocky spade
#

yeah I'm slowly shifting to aiohttp, thanks though!

hardy harness
#

so this is resolved?

#

.close

spring vesselBOT
#

Done with your help thread?

Please close your own help thread by using </close:1009144375709814897> with @burnt sluice.