jakjus / serverless-discord-bot

Serverless Discord Bot Boilerplate. Ready to deploy to AWS with AWS SAM.
16 stars 7 forks source link

Stuck at "Sending command", CloudWatch shows "AxiosError: Request failed with status code 404" #5

Closed vincent-lu closed 1 year ago

vincent-lu commented 1 year ago

Hi thanks for the repo trying to get it working.

After sam build && sam deploy I can see the command /hello with replies with hello world description in my discord. But once I hit enter it just stucks at "Sending command..."

On CloudWatch the ExampleHelloFromLambdaJs log shows "AxiosError: Request failed with status code 404".

Any help is appreciated!

jakjus commented 1 year ago

It's really hard to tell.

Are you using node js v14? Please check the version in AWS Lambda GUI or CLI

vincent-lu commented 1 year ago

Hi @jakjus thanks for getting back to me. This is a very weird one. I ended up fixing it by deleteing my Discord app/bot and redid everything from scratch.

FWIW in my case both node 14 and 18 worked for me. It's just the Discord App is somehow bugged out.

jakjus commented 1 year ago

Thank you so much for this information. I'm glad it worked :) Now I know, that recreating the app can be helpful for someone having a similar issue.

Nessworthy commented 6 months ago

I get this is an old issue but FWIW discord gives you 3 seconds to respond to the original interaction before the request closes.

What you're seeing happening, is the proxy lambda is taking too long to process the request and not responding in time (and therefore not creating the response message). When your dispatched handler then tries to edit the original request with its response, discord will error because there was no original message posted to edit.

The fast solution in this case is to modify your generate_template/misc/base-template.yaml and increase its memory to 256MB. At 128MB it took about 2.7s to process (not including the time to proxy to and from api gateway). At 256 it took about 0.4s.

However, you're also going to run into trouble nowadays because node14 is no longer supported, so you'll also want to change your runtime to nodejs16.x (still supports AWS SDK v2), or convert over to AWS SDK v3 and using nodejs18.x or higher.