mirror of
https://github.com/sern-handler/tools
synced 2026-06-06 01:16:59 +00:00
ss
This commit is contained in:
@@ -22,8 +22,7 @@
|
||||
[url (fn [body headers]
|
||||
#js { "method" method
|
||||
"headers" headers
|
||||
"body" (.stringify js/JSON body )})
|
||||
]))
|
||||
"body" (js/JSON.stringify body)}) ]))
|
||||
|
||||
|
||||
(def actions (into {}
|
||||
|
||||
@@ -14,27 +14,27 @@
|
||||
(new js/URLSearchParams query))
|
||||
|
||||
|
||||
(defn- ^:async fetch-application [headers]
|
||||
(js-await (-> (js/fetch (str base (first (get actions "application/me"))) #js{ "headers" headers })
|
||||
(.then (fn ^:=> [res] (.json res)))
|
||||
(.then (fn ^:=> [son] (if-let [id (.-id son)]
|
||||
id (throw (str "Reason " (.-message son))))))
|
||||
(.catch (fn ^:=> [e] (throw e))))))
|
||||
(defn- fetch-application [headers]
|
||||
(let [url (str base (first (get actions "application/me")))]
|
||||
(-> (js/fetch url #js{ "headers" headers })
|
||||
(.then (fn ^:=> [res] (.json res)))
|
||||
(.then (fn ^:=> [son] (if-let [id (.-id son)]
|
||||
id
|
||||
(throw (str "Reason " (.-message son))))))
|
||||
(.catch (fn ^:=> [e] (throw e))))))
|
||||
|
||||
(defn- poster [token, appid]
|
||||
(let [header #js{ "Content-Type" "application/json"
|
||||
"Authorization" (str "Bot " token) }]
|
||||
(defn- poster [token]
|
||||
(let [header { "Content-Type" "application/json"
|
||||
"Authorization" (str "Bot " token) }]
|
||||
(^:async fn [action opts]
|
||||
(let [[url mkrequest] (get actions action)
|
||||
appid (js-await (fetch-application header))
|
||||
options #js{"app_id" appid
|
||||
"guild_id" (.-guild_id ^js opts)
|
||||
"command_id" (.-command_id ^js opts)}
|
||||
options {:app_id appid :guild_id (.-guild_id opts) :command_id (.-command_id opts)}
|
||||
url (new js/URL (inject url options)) ]
|
||||
(set! (.-search url) (?params (.-query ^js opts)))
|
||||
(js/fetch url (mkrequest (.-body ^js opts) header))))))
|
||||
(set! (.-search url) (?params (.-query opts)))
|
||||
(js/fetch url (mkrequest (.-body opts) header))))))
|
||||
|
||||
(defn- isOk? [^js response]
|
||||
(defn- isOk? [response]
|
||||
(.-ok response))
|
||||
|
||||
|
||||
|
||||
2
packages/poster/src/poster.d.ts
vendored
2
packages/poster/src/poster.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
declare module 'poster';
|
||||
declare module 'poster.*';
|
||||
|
||||
import type { paths } from './discord.d.ts'
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import poster from '../dist/poster.js';
|
||||
import poster from '../dist/poster.mjs';
|
||||
|
||||
const send = await poster.client("");
|
||||
const send = await poster.client("token");
|
||||
|
||||
const req = await send("global/get-all", {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user