disco-images
Version:
A powerful tool to generate anime images/gifs
22 lines (19 loc) • 691 B
text/typescript
import { Message } from 'discord.js';
import fetch from 'node-fetch';
class Execute {
private _config: any
private _query: string
constructor(query: string, config: any) {
this._config = config
this._query = query;
(async () => {
const toFind = query.split(/ +/g);
const url = `https://api.tenor.com/v1/search?q=${toFind}&key=${config.key}&limit=50`
const whichGif = Math.floor(Math.random() * 50);
const response = await fetch(url);
const json = await response.json();
return json.results[whichGif].url;
})();
}
}
export default Execute;