alerts added
This commit is contained in:
28
commands/alert.js
Normal file
28
commands/alert.js
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
var libFlayer = require("../libFlayer.js");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'alert',
|
||||||
|
description: 'Alert',
|
||||||
|
async execute(message, args) {
|
||||||
|
try {
|
||||||
|
if (args.length < 1) {
|
||||||
|
message.reply(`Please use in !alert [state]`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var question = encodeURIComponent(args.join(" "));
|
||||||
|
|
||||||
|
var answerData = await libFlayer.weatherAlert(question);
|
||||||
|
answerData.forEach(feature => {
|
||||||
|
message.reply(`
|
||||||
|
${feature.properties.areaDesc}
|
||||||
|
${feature.properties.headline}
|
||||||
|
${feature.properties.description}
|
||||||
|
`);
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
message.reply(err.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -8,7 +8,7 @@ module.exports = {
|
|||||||
`**!help** - *Lists the available commands*
|
`**!help** - *Lists the available commands*
|
||||||
**!key** - Testing remote Airtable: *!key url*
|
**!key** - Testing remote Airtable: *!key url*
|
||||||
**!categories** - Displays Categories: *!categories*
|
**!categories** - Displays Categories: *!categories*
|
||||||
**!search** - Searches the RSS Sources: *!search google*
|
**!find** - Searches the RSS Sources: *!find google*
|
||||||
**!get** - Retrieves Search By Index: *!get 25*
|
**!get** - Retrieves Search By Index: *!get 25*
|
||||||
**!add** - Add a new RSS Source: *!add http://www.engadget.com/rss.xml*
|
**!add** - Add a new RSS Source: *!add http://www.engadget.com/rss.xml*
|
||||||
**!update** - Updates all current RSS Feeds: *!update*
|
**!update** - Updates all current RSS Feeds: *!update*
|
||||||
@@ -20,6 +20,7 @@ module.exports = {
|
|||||||
**!stock** - AlphaVantage Stock Search: *!stock IBM*
|
**!stock** - AlphaVantage Stock Search: *!stock IBM*
|
||||||
**!play** - Plays a trivia game question: *!play*
|
**!play** - Plays a trivia game question: *!play*
|
||||||
**!answer** - Answers for a question above: *!answer 1*
|
**!answer** - Answers for a question above: *!answer 1*
|
||||||
|
**!alert** - Gets weather alerts for an area: *!alert TX*
|
||||||
`
|
`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
2
index.js
2
index.js
@@ -85,7 +85,7 @@ client.on('interactionCreate', async interaction => {
|
|||||||
if (!interaction.isSelectMenu()) return;
|
if (!interaction.isSelectMenu()) return;
|
||||||
|
|
||||||
let aaa = interaction.values[0];
|
let aaa = interaction.values[0];
|
||||||
await interaction.reply({ content: 'You picked something', ephemeral: true });
|
await interaction.channel.send({ content: 'You picked something', ephemeral: true });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//await command.execute(interaction);
|
//await command.execute(interaction);
|
||||||
|
|||||||
21
libFlayer.js
21
libFlayer.js
@@ -210,6 +210,27 @@ exports.loadFeeds = function () {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
exports.weatherAlert = async function (state) {
|
||||||
|
|
||||||
|
var answerURL = `https://api.weather.gov/alerts/active?area=${state}`;
|
||||||
|
console.log(answerURL);
|
||||||
|
answerData = [];
|
||||||
|
|
||||||
|
await axios.get(answerURL)
|
||||||
|
.then(response => {
|
||||||
|
response.data.features.forEach(feature => {
|
||||||
|
answerData.push(feature);
|
||||||
|
})
|
||||||
|
|
||||||
|
return answerData;
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
|
return answerData;
|
||||||
|
}
|
||||||
|
|
||||||
exports.search = async function (question) {
|
exports.search = async function (question) {
|
||||||
|
|
||||||
var answerURL = `https://api.duckduckgo.com/?q=${question}&format=json&pretty=1`;
|
var answerURL = `https://api.duckduckgo.com/?q=${question}&format=json&pretty=1`;
|
||||||
|
|||||||
Reference in New Issue
Block a user