UNPKG

disco-images

Version:

A powerful tool to generate anime images/gifs

25 lines (21 loc) 750 B
import { config as env } from 'dotenv'; env(); import fetch from 'node-fetch' const token = process.env.TOKEN; async function get(topic: string) { const name = topic.split('-' || ' ').join('+'); const response = await fetch(`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') } export default obj;