1import { discordAPI } from "https://esm.town/v/stevekrouse/discordAPI";
2
3export let getDiscordGuilds = ({token, tokenType}) => discordAPI({
4 token,
5 tokenType,
2
3// token_type = 'Bot' | 'Bearer'
4export let discordAPI = ({path, tokenType, token}) => fetchJSON(
5 `https://discord.com/api/${path}`,
6
7 // https://discord.com/developers/docs/reference#authentication
2
3export let discordFetch = (token, route) => fetchJSON(
4 `https://discord.com/api/${route}`,
5 {
6 headers: {
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export let testWebhook = fetchJSON("https://api.val.town/eval/@stevekrouse.webhook", {method: "POST"})
2
3export let fetchHeaders2 = Object.fromEntries(
4 (await fetch("https://swapi.dev/api/people/1/")).headers
5);
2
3export async function hootsuiteNasa(req: express.Request, res: express.Response) {
4 const NASA_ROOT = "https://images-api.nasa.gov";
5 const alphaNumericSpaces = new RegExp("^[a-zA-Z0-9\\s-_]+$");
6 const acceptableRedirectUri = new RegExp(
7 "^https:\/\/api-auth.hootsuite.com\/app-directory\/apps\/[0-9]+\/oauth2\/callback$",
8 );
9 if (req.path === "/v1/media") {
3export let getRandomPokemon = async () => {
4 const id = Math.floor(Math.random() * 151);
5 const url = `https://pokeapi.co/api/v2/pokemon/${id}`;
6 const data = await fetchData(url);
7 console.log(data.name);
1import { myName } from "https://esm.town/v/jakesing/myName";
2
3export function myApi() {
4 return "hi " + myName;
5}
1export function myApi(name) {
2 return "hi " + name;
3}
33 "model": "gpt-3.5-turbo",
34 });
35 let openApiKey = process.env.OPEN_API_KEY;
36 var requestOptions = {
37 method: "POST",
38 headers: {
39 "Content-Type": "application/json",
40 "Authorization": `Bearer ${openApiKey}`,
41 },
42 body: rawBody,
43 redirect: "follow",
44 };
45 let openApiResponse = await fetch(
46 "https://api.openai.com/v1/chat/completions",
47 requestOptions,
48 );
49 let jsonResponse = await openApiResponse.json();
50 let choice = jsonResponse?.choices[0]?.message.content;
51 if (!choice) {