Hey all!
I was recently reading this article on Vercel guides about deploying Discord bots to Vercel. It didn’t have clear instructions or a method to do so, so I winged it and started work on my own solution.
Discord bots deployed to Vercel only work with application commands, not events, but at least it’s a lot better than just webhooks or nothing at all.
I created an open-source library that streamlines the development and deployment process, as well as a tutorial on how to use it. I would love feedback… does it work for you? How I can improve it?
This is a great article and project. Thank you for sharing with us! I’m sure that this will be helpful to those wanting to deploy their own Discord bots to Vercel.
You’re in the right place! We’ll see what we can do. What were you thinking?
As far as updating the Vercel guide page (not sure how that’s managed, is it a public repository?), I had a few things in mind:
Mention that Discord bots with applications commands can be deployed to Vercel, but make note of serverless limitations
Have an example or examples of how to do so. This could be starting from scratch or using a framework, like Discraft or other frameworks that might support Vercel deployment (but I don’t think there are any others yet)
I think the Vercel guide kinda paints it as not possible right now, but it is possible (with limitations) so an update might be good.
I also completely understand if you can’t mention third-party libraries in the Vercel guide; mentioning Discraft would be very nice (), but Vercel doesn’t own it, so I’m not sure if it could be mentioned anyway.
With the latest Discraft Vercel template in version 1.7.5, commands are immediately acknowledged and deferred. This means Discord will not time out the command after 3 seconds, and will instead allow the command to load for up to 15 minutes. The acknowledgement itself must happen within 3 seconds, but this should usually not be an issue.
To see it in action, try the bot in the Discord server!
To get started with the updated Vercel template, update Discraft to 1.7.5 with your package manager and run discraft init. Choose the Vercel + TS + AI template. If you are using the latest version, you should see a commands/chat.ts file after initialization with these comments near the top:
// Here you define your command data
// Discraft will handle the registration and interactions with the API
The commands API for serverless commands has changed a bit, but not substantially. If you already had commands, it shouldn’t be hard to migrate (blog post coming soon).