K
Kord2mo ago
Solaris

Possible to intercept a request to modify the payload?

If your application has several commands but needs some kind of notice attached to the response (like a embed with some info) you'd have to add it to every response manually. But is it possible to intercept the request payload for X type and modify it? In my case I have the command markdown </slash command:id> in several commands but I can't hardcode it as the ID changes whenever you update a command. So I just cache all the command IDs on load, but then I'd still have to format it in every single response. Instead I'd like to just intercept the request and format it in one function than every command I have or will add.
5 Replies
SchlaubiBus
SchlaubiBus2mo ago
You could implement your own RequestHandler
Solaris
SolarisOP2mo ago
Are there any docs on that? I see dev.kord.rest.request.RequestHandler but I have no idea how to use it
LustigerLurch
LustigerLurch2mo ago
wouldn't it be possible to extract the logic into a simple function to use instead of kord's response function?
Solaris
SolarisOP2mo ago
yeah but then you have to make sure you use it every time it needs to be
LustigerLurch
LustigerLurch2mo ago
hm, fair. but requesthandler seems to be too low level for your purposes

Did you find this page helpful?