a little cleaner

This commit is contained in:
Jacob Nguyen
2023-11-20 17:18:53 -06:00
parent 788118e16d
commit d33b950dad
4 changed files with 11 additions and 12 deletions

View File

@@ -12,9 +12,6 @@
"devDependencies": {
"shadow-cljs": "^2.8.52",
"source-map-support": "^0.5.13"
},
"peerDependencies": {
},
"keywords": [],
"author": "",

View File

@@ -28,7 +28,9 @@
(subs (str ky) 1))
(def actions (into {}
(for [[k v] routes] [(keyword->str k) (request-init k)])))
(map (fn [[k v]] [(keyword->str k) (request-init k)]))
routes
))

View File

@@ -6,9 +6,9 @@
(defn processed-url [remaining-url opts]
(-> (str base-url remaining-url)
(replace #"\{application\.id\}" (.-app_id opts))
(replace #"\{guild\.id\}" (.-guild_id opts))
(replace #"\{command\.id\}" (.-command_id opts))))
(replace #"\{application\.id\}" (.-app_id ^js opts))
(replace #"\{guild\.id\}" (.-guild_id ^js opts))
(replace #"\{command\.id\}" (.-command_id ^js opts))))
(defn poster [token, appid]
(let [header #js{ "Content-Type" "application/json"
@@ -16,6 +16,6 @@
(fn [action opts]
(let [ [url mkrequest] (actions action)
full-url (processed-url url #js { "app_id" appid
"guild_id" (.-guild_id opts)
"command_id" (.-command_id opts) })]
(js/fetch full-url (mkrequest (.-body opts ) header))))))
"guild_id" (.-guild_id ^js opts)
"command_id" (.-command_id ^js opts) })]
(js/fetch full-url (mkrequest (.-body ^js opts ) header))))))

View File

@@ -1,9 +1,9 @@
import poster from '../dist/index.js';
const client = poster("token", "appid");
const send = poster("token", "appid");
const req = await client("global/put", { });
const req = await send("global/put", { });
console.log(req);