http to discord js type

lets say i have http interaction and i want to turn it into a discord js object. how could i create a new instance using the payload data from http api
9 Replies
d.js toolkit
d.js toolkit3mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
duck
duck3mo ago
it wouldn't really make sense to do so since you respond to http interactions by responding to the request as opposed to making a POST request to the appropriate endpoint furthermore anything you could achieve by accessing other properties on the interaction could be achieved just by accessing your Client (which would be necessary to construct a djs interaction)
Creeper
CreeperOP3mo ago
im in a unique situation where i need to spin it up from a serverless function so i have an http payload of the interaction but my base code is with discordjs api so the best option would be to make a djs interaction
duck
duck3mo ago
that still doesn't really mean you need to create your own djs structure especially if the interaction is being received from a serverless function, you shouldn't have access to a Client in that environment you should instead be making some means of communicating with your djs Client (e.g. your own http api)
Creeper
CreeperOP3mo ago
i would have to re write every single call and fetch request into the discord endpoint and there is alot. if i could simply make an interaction object and pass the token then i wouldn't have to deal with that
duck
duck3mo ago
well you can't you don't have access to a Client in that environment you can utilize the API structure from @discordjs/core (or more specifically @discordjs/core/http-only) or just use @discordjs/rest
Creeper
CreeperOP3mo ago
its a node environment. i'm able to create an instance of the client on the request. i have the token from the http request. i can destroy it after
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
Creeper
CreeperOP3mo ago
was able to figure it out. i extended the base interaction class thanks
Want results from more Discord servers?
Add your server