]> gitweb.factorcode.org Git - factor.git/commitdiff
discord: fix interaction create, add interaction edit
authorVal Packett <val@packett.cool>
Wed, 3 Apr 2024 00:32:56 +0000 (21:32 -0300)
committerDoug Coleman <doug.coleman@gmail.com>
Wed, 3 Apr 2024 13:36:41 +0000 (08:36 -0500)
extra/discord/discord.factor

index daf9e3b477bf9b8ff33efedf626d3d46058a798e..aedccba572a20aaaabd39d20acbc8e3ee2bb2de9 100644 (file)
@@ -73,6 +73,8 @@ TUPLE: discord-bot
     discord-post-request json-request ;
 : discord-post-json ( payload route -- json )
     [ >json ] dip discord-post-request add-json-header json-request ;
+: discord-post-json-no-resp ( payload route -- )
+    [ >json ] dip discord-post-request add-json-header http-request 2drop ;
 : discord-patch-json ( payload route -- json )
     [ >json ] dip discord-patch-request add-json-header json-request ;
 : discord-delete-json ( route -- json )
@@ -104,13 +106,12 @@ TUPLE: discord-bot
 : delete-discord-application-guild-command ( application-id -- json )
     "/applications/%s/commands" sprintf discord-delete-json ;
 
-: create-interaction-response ( interaction-id interaction-token -- json )
-    [ H{ { "type" 4 } { "data" "pang" } } clone ] 2dip
-    "/webhooks/%s/%s/messages/callback" sprintf discord-post ;
-
+: create-interaction-response ( json interaction-id interaction-token -- )
+    "/interactions/%s/%s/callback" sprintf discord-post-json-no-resp ;
 : get-original-interaction-response ( application-id interaction-token -- json )
     "/webhooks/%s/%s/messages/@original" sprintf discord-get ;
-
+: edit-interaction-response ( json application-id interaction-token -- json )
+    "/webhooks/%s/%s/messages/@original" sprintf discord-patch-json ;
 
 
 : send-message* ( string channel-id -- json )