Last active
August 7, 2021 20:35
-
-
Save ArooBaito/e39e383e70aed185fbc5eebb23d71b47 to your computer and use it in GitHub Desktop.
Minimal Discord http-post requests from various Scheme implementations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Documentation on http post requests is a lot of guess-work in certain Scheme implementations. | |
;; To save some frustration, here is a compilation of examples on how to get a Discord | |
;; webhook bot to say a simple message from the various Schemes using default libraries | |
;; To the right is also the command to connect Emacs using inferior Scheme | |
;; BiwaScheme [browser] (setq scheme-program-name "shamisen-emacs") [see biwa-shamisen] | |
(http-post "https://discord.com/api/webhooks/[your info here]" | |
'(("content" . "Hello from BiwaScheme!"))) | |
;; BiwaScheme [node] [not implemented] (setq scheme-program-name "biwas") | |
;; Yutaka Hara only wrote a macro for making a http-post request from BiwaScheme's | |
;; browser client, however it's easy to write your own for BiwaScheme Node. I'll make a separate | |
;; gist for this soon | |
;; Chicken Scheme (setq scheme-program-name "csi") [see https://gist.github.com/ArooBaito/4756ae379d42f7302a7fd61037629d26] | |
;; chicken-install http-client -v | |
;; guix install openssl [or whatever for your OS. Chocolatey or scoop for Windows] | |
;; chicken-install openssl | |
(import http-client (chicken io)) | |
(with-input-from-request "https://discord.com/api/webhooks/[your info here]" | |
'((content . "Hello from Chicken Scheme!")) read-string) | |
;; Gauche Scheme (setq scheme-program-name "gosh") | |
(use rfc.http) | |
(http-post "discord.com" '("/api/webhooks/[your info here]") | |
'((content "Hello from Gauche Scheme!")) :secure #t) | |
;; Guile Scheme (setq scheme-program-name "guile") | |
(use-modules (web client)) | |
(http-post "https://discord.com/api/webhooks/[your info here]" | |
#:headers '((content-length . 38) (content-type application/json)) | |
#:body "{\"content\":\"Hello from Guile Scheme!\"}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment