Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | 1x 1x 2x 2x 1x 1x 1x 2x | /** * Ask butlerbot for sagely advice. * @module advice * @return {string} - advice (as a message to discord text channel) */ const axios = require('axios'); module.exports = { name: 'advice', description: 'Ask for butlerbot\'s advice on a question.', aliases: ['advise'], /** * @method execute * @param {string} message - command, used to determine which channel to return results * @return {string} results of advice api call */ execute(message) { /** * @var {string} adviceApi * @summary apology api url */ let adviceApi = 'https://api.adviceslip.com/advice'; /** * @function getAdvice * @async * @param {string} adviceApi - apology api url * @return {Object} response * @summary web location to perform api call against for advice */ function getAdvice (api) { axios.get(api) .then(response => { message.channel.send(response.data.slip.advice); }) .catch(error => { console.log(error); return message.channel.send(`I do not think I can help you with this, sorry ${message.author}`); }); } //* call getAdvice method with our apology api getAdvice(adviceApi); } }; |