This commit is contained in:
Jacob Nguyen
2024-05-17 17:09:54 -05:00
parent e30734a750
commit 760c2b6a5a
3 changed files with 10 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@sern/poster",
"version": "1.2.5",
"version": "1.2.6",
"description": "Post discord application commands",
"types": "./dist/index.d.ts",
"main": "./dist/index.mjs",

View File

@@ -8,7 +8,7 @@
(-> (str base remaining-url)
(s/replace #"\{application\.id\}" (or (.-app_id ^js opts) ""))
(s/replace #"\{guild\.id\}" (or (.-guild_id ^js opts) ""))
(s/replace #"\{user\.id\}" (or (.-guild_id ^js opts) ""))
(s/replace #"\{user\.id\}" (or (.-user_id ^js opts) ""))
(s/replace #"\{command\.id\}" (or (.-command_id ^js opts) ""))))
(defn- ?params [^js query]
@@ -29,7 +29,10 @@
(^:async fn [action opts]
(let [[url mkrequest] (get actions action)
appid (js-await (fetch-application header))
options {:app_id appid :guild_id (.-guild_id opts) :command_id (.-command_id opts)}
options {:app_id appid
:guild_id (.-guild_id opts)
:command_id (.-command_id opts)
:user_id (.-user_id opts) }
url (new js/URL (inject url options)) ]
(set! (.-search url) (?params (.-query opts)))
(js/fetch url (mkrequest (.-body opts) header))))))

View File

@@ -1,10 +1,11 @@
import poster, { type GlobalPut } from '../dist/index.js';
import poster, { type GlobalPut, type TypedResponse } from '../dist/index.js';
const send = await poster.client("MTI0MTA4MzI5NDYzNzA5NzAyMQ.G8EKXD.q4s-pDrim6SnHcsPrFY3uQpn_8SCF8-vSPYZ48");
const send = await poster.client("token");
const req = await send("user/get", {
user_id: ""
}); //cast for full typed safety
}) as TypedResponse<GlobalPut>; //cast for full typed safety
if(poster.isOk<GlobalPut>(req)) {
req.json().then(s => s?.map(v => v.name))