Giter Club home page Giter Club logo

Comments (10)

1oonie avatar 1oonie commented on August 24, 2024

You have to send an initial response to an interaction within 3 seconds:
image

However, if you manually defer the interaction e.g. doing

    async def select_page(self, interaction: discord.Interaction):
        await interaction.response.defer()
        await asyncio.sleep(4)

then you have up to 15 minutes (since that is how long the interaction token is valid for) to send follow-up messages.

The reason that you are getting this error is because pycord automatically defers the response if you do not respond yourself, and since you slept for more than 3 seconds in the component callback, the interaction token is invalidated.

from pycord.

Luc1412 avatar Luc1412 commented on August 24, 2024

Yeah, am aware of the reason. But I think that the library should catch the 404. Depending on the load of the server the bot is not able to respond in the given time which results in this error.

from pycord.

1oonie avatar 1oonie commented on August 24, 2024

You can catch it yourself? discord.ui.View provides a on_error function for this
image

from pycord.

Luc1412 avatar Luc1412 commented on August 24, 2024

I think the library shouldn't throw errors without the developer really expecting them. You also can also barely differentiate those library exceptions from those who get thrown in the callback.

from pycord.

1oonie avatar 1oonie commented on August 24, 2024

It should be expected because you have exceeded the 3 second limit. Continuing from your point, neither should the library silently ignore errors.

from pycord.

Luc1412 avatar Luc1412 commented on August 24, 2024

It should be expected

No. It is not mentioned anywhere in the documentation. "Not Found" also doesn't make sense in this context and won't be useful to the library user. Exceptions are only expected on library user input eg. by calling a core.

Continuing from your point, neither should the library silently ignore errors.

But not everyone wants that the interaction to be auto-deferred

from pycord.

1oonie avatar 1oonie commented on August 24, 2024

It is documented in the discord API documentation. The reason that it gets auto-deferred is because you have to respond to the interaction and the defer happens only when the callback is done and no response was made.

It probably should be documented with more clarity in the fact that you have to respond within 3 seconds and that the library auto-defers it for you if you don't respond youself.

from pycord.

Luc1412 avatar Luc1412 commented on August 24, 2024

It is documented in the discord API documentation.

No. The user doesn't know that it will be auto-deferred. The average user probably also only uses pycord's documentation.

The reason that it gets auto-deferred is because you have to respond to the interaction and the defer happens only when the callback is done and no response was made.

You don't need to respond. If you don't respond, it just shows that the interaction failed.

from pycord.

1oonie avatar 1oonie commented on August 24, 2024

The documentation that I referenced documents the fact that you need to respond within 3 seconds if you don't want it to fail.

I suppose the point of having it was that it is better than the "This interaction has failed" text that appears if you don't respond at all. I already said that it should probably be documented that it will auto-defer.

Of course you could have a task that waits for 3 seconds and then checks if the interaction has been responded to or not but this could be prone to race conditions. In my opinion, it is better to keep what we have at the moment but document it better.

from pycord.

Lulalaby avatar Lulalaby commented on August 24, 2024

Stale

from pycord.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.