UNPKG

disco-images

Version:

A powerful tool to generate anime images/gifs

27 lines (26 loc) 1.01 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const dotenv_1 = require("dotenv"); dotenv_1.config(); const node_fetch_1 = __importDefault(require("node-fetch")); const token = process.env.TOKEN; async function get(topic) { const name = topic.split('-' || ' ').join('+'); const response = await node_fetch_1.default(`https://api.tenor.com/v1/search?q=${name}&key=${token}&limit=50`); const json = await response.json(); return json.results[Math.floor(Math.random() * 50)].url; } const obj = { wave: () => get('anime-wave'), hug: () => get('anime-hug'), kiss: () => get('anime-kiss'), slap: () => get(`anime-slap`), punch: () => get('anime-punch'), cry: () => get('anime-cry'), random: () => get('anime-random'), search: () => get('anime-search') }; exports.default = obj;