Building Discord bot interactions as Convex http actions
I'm building a set of Discord interactions as http actions. I'm using Discord.js because it includes a bunch of very useful typescript types for determining the structure of the data that Discord sends your webhook and what it expects back. The problem is that DiscordJS also imports a whole bunch of node stuff, which I don't care about. Sadly, I can't just do
because several of them are enums, and I need the actual enum value (because Discord uses integers for a bunch of things, and I don't want magic values all over my codebase.
but Convex complains that I'm importing unsupported node modules. I guess my best bet is to just copy these enums out of Discord.js into my own codebase, so that I can stick to importing pure types, but if there's a workaround to somehow treeshake out those unneeded node module imports, I'd be happy to hear about them.
2 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
what you could do is have a file or multiple files with 'use node' to the top, where these files are used elsewhere that doesn't care about that, I believe that should solve your issue!