mrmBot-Matrix/commands/wikihow.js

23 lines
656 B
JavaScript
Raw Normal View History

const fetch = require("node-fetch");
exports.run = async (message) => {
message.channel.sendTyping();
const request = await fetch("https://hargrimm-wikihow-v1.p.mashape.com/images?count=1", {
headers: {
"X-Mashape-Key": process.env.MASHAPE,
"Accept": "application/json"
}
});
const json = await request.json();
const image = await fetch(json["1"]);
const imageBuffer = await image.buffer();
return {
file: imageBuffer,
name: json["1"].split("/")[json["1"].split("/").length - 1]
};
};
exports.aliases = ["wiki"];
exports.category = 4;
exports.help = "Gets a random WikiHow image";
exports.requires = "mashape";