diff --git a/packages/poster/package.json b/packages/poster/package.json index 7099619..bec5cc7 100644 --- a/packages/poster/package.json +++ b/packages/poster/package.json @@ -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", diff --git a/packages/poster/src/index.cljs b/packages/poster/src/index.cljs index 15e4f8f..9e9b5e0 100644 --- a/packages/poster/src/index.cljs +++ b/packages/poster/src/index.cljs @@ -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)))))) diff --git a/packages/poster/test/spec.ts b/packages/poster/test/spec.ts index b5dcc01..a38e662 100644 --- a/packages/poster/test/spec.ts +++ b/packages/poster/test/spec.ts @@ -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; //cast for full typed safety if(poster.isOk(req)) { req.json().then(s => s?.map(v => v.name))