disco-images
Version:
A powerful tool to generate anime images/gifs
24 lines (23 loc) • 869 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const node_fetch_1 = __importDefault(require("node-fetch"));
class Execute {
_config;
_query;
constructor(query, config) {
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 node_fetch_1.default(url);
const json = await response.json();
return json.results[whichGif].url;
})();
}
}
exports.default = Execute;