Pycord-Development / pycord

Pycord is a modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python
https://docs.pycord.dev
MIT License
2.74k stars 462 forks source link

await ctx.defer() do 404 Not Found (error code: 10062): Unknown interaction #1487

Closed Creveoolus closed 2 years ago

Creveoolus commented 2 years ago

Summary

await ctx.defer() do 404 Not Found (error code: 10062): Unknown interaction

Reproduction Steps

Minimal Reproducible Code

Used in cog

    user = SlashCommandGroup(
        'user',
        description='User commands'
    )

    @user.command()
    async def stats(self, ctx: discord.ApplicationContext, member: Option(discord.User, 'Specify an user')):
        member = ctx.author if member is None else member

        await ctx.defer()


### Expected Results

Interaction will be defered

### Actual Results

Throws an `discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction` error

### Intents

all

### System Information

C:\Users\User>python -m discord -v 
- Python v3.10.4-final
- py-cord v2.0.0-final
- aiohttp v3.7.4.post0
- system info: Windows 10 10.0.22000

### Checklist

- [X] I have searched the open issues for duplicates.
- [X] I have shown the entire traceback, if possible.
- [X] I have removed my token from display, if visible.

### Additional Context

I have deadline till tomorow, pls help
plun1331 commented 2 years ago

You are most likely deferring after the 3 second period where you must respond

Lulalaby commented 2 years ago

Check the hosts speed. Maybe execute a speedtest. This is no lib issue.

Creveoolus commented 2 years ago

Check the hosts speed. Maybe execute a speedtest. This is no lib issue.

Actually it's running on my computer. So it can not be the problem.

You are most likely deferring after the 3 second period where you must respond

Thanks for the answer, i might test it

Creveoolus commented 2 years ago

Allright, i tested it, doesn't work. Defer stops working after the on_message event, might that help.

RafaelSolVargas commented 2 years ago

I got this same error in a situation that might help someone. My Discord Bot Vulkan works with the multiprocessing python module to create other processes to play the music. When a process is created it duplicates the code in memory, in fact you increase the number of instances of your program. If any slash command is send, the command is received by all yours program instances, and when the copies of the principal process try to defer the interaction object they will fail with this http 404 error, because they cannot access the interaction object (due to others processing).