Adding airport info search
This commit is contained in:
parent
8fc6505f1d
commit
be7d3a1687
26
commands/airport.js
Normal file
26
commands/airport.js
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
const axios = require("axios").default;
|
||||||
|
const functions = require('../functions.js');
|
||||||
|
|
||||||
|
let options = {
|
||||||
|
method: 'GET',
|
||||||
|
url: 'https://forteweb-airportguide-airport-basic-info-v1.p.rapidapi.com/get_airport_by_iata',
|
||||||
|
params: {auth: 'authairport567', airport_id: 'LAX'},
|
||||||
|
headers: {
|
||||||
|
'x-rapidapi-key': '0b3f85bcb7msh1e6e80e963c9914p1d1934jsnc3542fc83520',
|
||||||
|
'x-rapidapi-host': 'forteweb-airportguide-airport-basic-info-v1.p.rapidapi.com'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'airport',
|
||||||
|
description: 'Get airport information by IATA code.',
|
||||||
|
execute(message, file) {
|
||||||
|
options.params.airport_id = file.name;
|
||||||
|
axios.request(options).then(function (response) {
|
||||||
|
const embed = functions.createAirportEmbed(response.data, message.author);
|
||||||
|
message.channel.send(embed).then().catch(err => console.error(err));
|
||||||
|
}).catch(function (error) {
|
||||||
|
console.error(error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,6 @@
|
|||||||
const axios = require('axios').default;
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'strain',
|
name: '',
|
||||||
description: 'Search for information about a cannabis strain. Powered by Otreeba',
|
description: '',
|
||||||
execute(message, file) {
|
execute(message, file) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,8 @@
|
|||||||
"truth",
|
"truth",
|
||||||
"joint",
|
"joint",
|
||||||
"ping",
|
"ping",
|
||||||
"strain"
|
"strain",
|
||||||
|
"airport"
|
||||||
],
|
],
|
||||||
"emoji": {
|
"emoji": {
|
||||||
"joint": "<:joint:862082955902976000>",
|
"joint": "<:joint:862082955902976000>",
|
||||||
|
14
functions.js
14
functions.js
@ -60,5 +60,19 @@ module.exports = {
|
|||||||
const gif = require(`./gifs/${name}.js`);
|
const gif = require(`./gifs/${name}.js`);
|
||||||
message.client.gifs.set(gif.name, gif);
|
message.client.gifs.set(gif.name, gif);
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
createAirportEmbed(data, author) {
|
||||||
|
const airport = data.airport[0];
|
||||||
|
return new Discord.MessageEmbed()
|
||||||
|
.setAuthor('Airport Information')
|
||||||
|
.setTitle(airport.airport_name)
|
||||||
|
.addFields(
|
||||||
|
{ name: 'Location', value: `${airport.city}, ${airport.state_abbrev}`, inline: true },
|
||||||
|
{ name: 'Coordinates', value: `${airport.latitude}, ${airport.longitude}`, inline: true },
|
||||||
|
{ name: 'Elevation', value: `${airport.elevation}ft`, inline: true },
|
||||||
|
{ name: 'More Information', value: airport.link_path }
|
||||||
|
)
|
||||||
|
.setTimestamp()
|
||||||
|
.setFooter(`@${author.username}#${author.discriminator}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user