2019-10-24 20:35:06 +00:00
|
|
|
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: {
|
2019-11-13 00:09:06 +00:00
|
|
|
"X-Mashape-Key": process.env.MASHAPE,
|
2019-10-24 20:35:06 +00:00
|
|
|
"Accept": "application/json"
|
|
|
|
}
|
|
|
|
});
|
|
|
|
const json = await request.json();
|
|
|
|
const image = await fetch(json["1"]);
|
|
|
|
const imageBuffer = await image.buffer();
|
2020-04-12 19:51:48 +00:00
|
|
|
return {
|
2019-10-24 20:35:06 +00:00
|
|
|
file: imageBuffer,
|
|
|
|
name: json["1"].split("/")[json["1"].split("/").length - 1]
|
2020-04-12 19:51:48 +00:00
|
|
|
};
|
2019-10-24 20:35:06 +00:00
|
|
|
};
|
|
|
|
|
2019-11-30 02:00:14 +00:00
|
|
|
exports.aliases = ["wiki"];
|
2019-12-02 20:47:22 +00:00
|
|
|
exports.category = 4;
|
|
|
|
exports.help = "Gets a random WikiHow image";
|
2019-11-30 02:00:14 +00:00
|
|
|
exports.requires = "mashape";
|