2019-10-24 20:35:06 +00:00
|
|
|
const fetch = require("node-fetch");
|
|
|
|
|
|
|
|
exports.run = async (message) => {
|
|
|
|
message.channel.sendTyping();
|
2020-06-04 23:18:16 +00:00
|
|
|
const request = await fetch("https://hargrimm-wikihow-v1.p.rapidapi.com/images?count=1", {
|
2019-10-24 20:35:06 +00:00
|
|
|
headers: {
|
2020-06-04 23:18:16 +00:00
|
|
|
"X-RapidAPI-Key": process.env.MASHAPE,
|
|
|
|
"X-RapidAPI-Host": "hargrimm-wikihow-v1.p.rapidapi.com",
|
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";
|