bigblindB
Convex Community4mo ago
2 replies
bigblind

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

import type {Foo, Bar} from "discord.js"


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.
Was this page helpful?