mirror of
https://github.com/sern-handler/tools
synced 2026-06-06 01:16:59 +00:00
fdssdffsd
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"name": "@sern/poster",
|
||||
"version": "1.2.1",
|
||||
"version": "1.2.5",
|
||||
"description": "Post discord application commands",
|
||||
"exports": {
|
||||
".": "./dist/poster.mjs"
|
||||
},
|
||||
"types": "./dist/index.d.ts",
|
||||
"main": "./dist/index.mjs",
|
||||
"module": "./dist/index.mjs",
|
||||
"scripts": {
|
||||
"poster:debug": "npx squint compile",
|
||||
"poster:prod": "npx squint compile",
|
||||
@@ -14,11 +14,18 @@
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"files": [
|
||||
"dist",
|
||||
"README.md",
|
||||
"src",
|
||||
"LICENSE"
|
||||
],
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"tag": "latest"
|
||||
},
|
||||
"dependencies": {
|
||||
"squint-cljs": "latest"
|
||||
}
|
||||
},
|
||||
"type": "module"
|
||||
}
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
;; shadow-cljs configuration
|
||||
{:source-paths
|
||||
["src"]
|
||||
|
||||
:dependencies
|
||||
[]
|
||||
|
||||
:builds
|
||||
{:poster {:target :node-library
|
||||
:output-to "dist/index.js"
|
||||
:exports { :client core.poster/poster
|
||||
:isOk core.poster/isOk?
|
||||
:is4XX core.poster/is4XX? }
|
||||
:build-hooks [(dev.mv/hook)]
|
||||
}}}
|
||||
@@ -15,6 +15,7 @@
|
||||
:guild/delete ["DELETE" "/applications/{application.id}/guilds/{guild.id}/commands/{command.id}"]
|
||||
:guild/put ["PUT" "/applications/{application.id}/guilds/{guild.id}/commands"]
|
||||
:application/me ["GET" "/applications/@me"]
|
||||
:user/get ["GET" "/users/{user.id}"]
|
||||
})
|
||||
|
||||
(defn- request-init [v]
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
(-> (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 #"\{command\.id\}" (or (.-command_id ^js opts) ""))))
|
||||
|
||||
(defn- ?params [^js query]
|
||||
(new js/URLSearchParams query))
|
||||
|
||||
|
||||
(defn- fetch-application [headers]
|
||||
(let [url (str base (first (get actions "application/me")))]
|
||||
(-> (js/fetch url #js{ "headers" headers })
|
||||
@@ -1,4 +1,3 @@
|
||||
declare module 'poster.*';
|
||||
|
||||
import type { paths } from './discord.d.ts'
|
||||
|
||||
@@ -13,6 +12,7 @@ export type GuildGet = paths["/applications/{application_id}/guilds/{guild_id}/c
|
||||
export type GuildEdit = paths["/applications/{application_id}/guilds/{guild_id}/commands/{command_id}"]["patch"]
|
||||
export type GuildDelete = paths["/applications/{application_id}/guilds/{guild_id}/commands/{command_id}"]["delete"]
|
||||
export type GuildPut = paths["/applications/{application_id}/guilds/{guild_id}/commands"]["put"]
|
||||
export type UserGet = paths["/users/{user_id}"]['get']
|
||||
export type ApplicationMe = paths["/applications/@me"]['get']
|
||||
|
||||
type ResponsesForRoute<T> = T extends { responses: infer R } ? R : never;
|
||||
@@ -57,7 +57,8 @@ interface RoutesOptions {
|
||||
"guild/put": [{ body: GuildPut["requestBody"]["content"]['application/json']}
|
||||
& GuildPut["parameters"]["path"]
|
||||
& { application_id?: never }];
|
||||
"application/me": []
|
||||
"application/me": [];
|
||||
"user/get" : [UserGet['parameters']['path'] & { application_id?: never } ]
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import poster from '../dist/poster.mjs';
|
||||
import poster from '../dist/index.mjs';
|
||||
|
||||
const send = await poster.client("token");
|
||||
const send = poster.client("token");
|
||||
|
||||
const req = await send("global/get-all", {
|
||||
const req = await send("user/get", {
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import poster, { type GlobalPut, type TypedResponse } from '../dist/poster.js';
|
||||
import poster, { type GlobalPut } from '../dist/index.js';
|
||||
|
||||
const send = await poster.client("token");
|
||||
|
||||
|
||||
const req = await send("global/get-all", {
|
||||
|
||||
}) as TypedResponse<GlobalPut>; //cast for full typed safety
|
||||
const req = await send("user/get", {
|
||||
user_id: ""
|
||||
}); //cast for full typed safety
|
||||
|
||||
if(poster.isOk<GlobalPut>(req)) {
|
||||
req.json().then(s => s?.map(v => v.name))
|
||||
|
||||
Reference in New Issue
Block a user