Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoobes committed May 17, 2024
1 parent e30734a commit 760c2b6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/poster/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
7 changes: 5 additions & 2 deletions packages/poster/src/index.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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))))))
Expand Down
7 changes: 4 additions & 3 deletions packages/poster/test/spec.ts
Original file line number Diff line number Diff line change
@@ -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))
Expand Down

0 comments on commit 760c2b6

Please sign in to comment.