Using raw APIInteraction data with DJS

I am no doubt going to sound like a moron with this question and perhaps it's not even something relevant to this Discord. But here it goes. I want to build a sort of proxy for interactions on one of my applications. A webhook server if you want to call it that. So far I have the proxy side working as intended; the endpoint URL is set in the dev portal, that sends application commands to the webhook server which then in turn forwards the request body to a Fastify listener on the Discord application side as an APIInteraction. Now, without needing to rewrite the entire logic of my extensive interactionCreate listeners, I figured a "hacky" workaround would be to use client.emit('interactionCreate', interaction) with interaction being the APIInteraction data. Obviously this doesn't work though as the gateway event in DJS expects Interaction<CacheType>. I will admit I don't understand the backend code of DJS enough to work this out on my own but I'm curious if it's possible for me to somehow put that APIInteraction in to DJS to get back out the type it expects complete with the DJS methods and properties I need (things like isChatInputCommand, isButton, etc) PS. please don't flame me if I'm being stupid thumbsuppepo
8 Replies
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
sludge
sludgeOP•2y ago
DJS: 14.7.1 node: 19.3.0 also just realised I selected the wrong tag
MrMythical
MrMythical•2y ago
https://github.com/discordjs/discord.js/blob/main/packages/discord.js/src/client/actions/InteractionCreate.js If you see the logic djs internal files use here, you could probably manually make your own 👀
sludge
sludgeOP•2y ago
I've been working on this for a few hours, spent a little while looking through the DJS packages to see if I could work it out on my own but I couldn't I think you may have found what I needed. I'll see what I can do from here, thank you! never mind. my tiny brain can't work it out
MrMythical
MrMythical•2y ago
what have you tried?
sludge
sludgeOP•2y ago
those actions rely on the actions property of a Client but its a private property well, so far just doing reading. because I only need to effectively insert the APIInteraction I have in to whatever it is the client does to decorate it with all the props and methods
MrMythical
MrMythical•2y ago
Does it really matter dogeHaHa You're already trying to use a private constructor
sludge
sludgeOP•2y ago
yeah true haha nah I'm gonna be honest, I can't get my head around any of this. I admit defeat and accept that my JS and TS knowledge isn't up to the level it needs to be was hoping I'd be able to emit the APIInteraction to the client somehow but I'm just lost. I'll leave this here on the off chance someone else has any other input but I'll have to put this little idea on hold for now omg I actually feel really dumb so I did try that exact method last night and threw in a ts-ignore to avoid the issue of it being a private property, but I was still sending a 200 response back to the proxy which seemed to be messing with the flow of things doing this now has actually worked as I'd hoped. thank you both for the input
Want results from more Discord servers?
Add your server