pushing food cmd
This commit is contained in:
25
commands/food.js
Normal file
25
commands/food.js
Normal file
@@ -0,0 +1,25 @@
|
||||
var libFlayer = require("../libFlayer.js");
|
||||
|
||||
module.exports = {
|
||||
name: 'food',
|
||||
description: 'Food',
|
||||
async execute(message, args) {
|
||||
try {
|
||||
|
||||
var resultArray = await libFlayer.getFood();
|
||||
|
||||
message.reply(`**Retrieving**:
|
||||
[${resultArray.strMeal} - ${resultArray.strCategory}]
|
||||
|
||||
${resultArray.strInstructions}
|
||||
|
||||
${resultArray.strSource}
|
||||
|
||||
${resultArray.strMealThumb}
|
||||
|
||||
`);
|
||||
} catch (err) {
|
||||
message.reply(err.toString());
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -23,6 +23,7 @@ module.exports = {
|
||||
**!npm** - Gets NPM info from repository: *!npm axios*
|
||||
**!alert** - Gets weather alerts for an area: *!alert TX*
|
||||
**!calc** - Do math: *!calc 2 + 2*
|
||||
**!food** - Selects a random recipe: *!food*
|
||||
`
|
||||
);
|
||||
}
|
||||
|
||||
45
libFlayer.js
45
libFlayer.js
@@ -231,6 +231,47 @@ exports.weatherAlert = async function (state) {
|
||||
return answerData;
|
||||
}
|
||||
|
||||
exports.getFood = async function () {
|
||||
|
||||
var answerURL = `https://www.themealdb.com/api/json/v1/1/random.php`;
|
||||
console.log(answerURL);
|
||||
answerData = {
|
||||
text: `No answer found try using a simpler search term`,
|
||||
source: ``
|
||||
}
|
||||
await axios.get(answerURL)
|
||||
.then(response => {
|
||||
//console.log(response.data.RelatedTopics[0].Text);
|
||||
//console.log(response.data.RelatedTopics[0].FirstURL);
|
||||
|
||||
// if (response.data.meals.length != 0) {
|
||||
|
||||
answerData = {
|
||||
strMeal: `No Data`,
|
||||
strSource: `-`,
|
||||
strInstructions: `-`,
|
||||
strMealThumb: `-`,
|
||||
strCategory: `-`
|
||||
}
|
||||
|
||||
answerData = {
|
||||
strMeal: `${unescape(response.data.meals[0].strMeal)}`,
|
||||
strSource: `${unescape(response.data.meals[0].strSource)}`,
|
||||
strInstructions: `${unescape(response.data.meals[0].strInstructions)}`,
|
||||
strMealThumb: `${unescape(response.data.meals[0].strMealThumb)}`,
|
||||
strCategory: `${unescape(response.data.meals[0].strCategory)}`
|
||||
}
|
||||
// } else {
|
||||
|
||||
//}
|
||||
return answerData;
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
});
|
||||
return answerData;
|
||||
}
|
||||
|
||||
exports.search = async function (question) {
|
||||
|
||||
var answerURL = `https://api.duckduckgo.com/?q=${question}&format=json&pretty=1`;
|
||||
@@ -241,8 +282,8 @@ exports.search = async function (question) {
|
||||
}
|
||||
await axios.get(answerURL)
|
||||
.then(response => {
|
||||
console.log(response.data.RelatedTopics[0].Text);
|
||||
console.log(response.data.RelatedTopics[0].FirstURL);
|
||||
//console.log(response.data.RelatedTopics[0].Text);
|
||||
//console.log(response.data.RelatedTopics[0].FirstURL);
|
||||
|
||||
if (response.data.Abstract != "") {
|
||||
answerData = {
|
||||
|
||||
Reference in New Issue
Block a user