Add and tweak D-ATIS
This commit is contained in:
parent
444bad7935
commit
b11d14b72d
@ -7,14 +7,18 @@ module.exports = {
|
||||
alias: [ 'atis' ],
|
||||
async execute(message, commandData) {
|
||||
try {
|
||||
const icaoId = commandData.args;
|
||||
if (icaoId.length !== 4) throw new Error('Not enough or too many ICAO IDs!')
|
||||
const icaoId = commandData.args.toUpperCase();
|
||||
if (icaoId.length !== 4) throw new Error('Invalid ICAO ID. Provide only one ICAO code at a time like KBOS');
|
||||
if (fn.avWx.datis.validate(icaoId)) {
|
||||
const datisData = await fn.avWx.datis.getData(icaoId);
|
||||
const messagePayload = fn.avWx.datis.parseData(datisData[0]);
|
||||
message.reply(messagePayload);
|
||||
} else {
|
||||
message.reply("No D-ATIS available for the specified ICAO ID.");
|
||||
}
|
||||
} catch (e) {
|
||||
try {
|
||||
message.reply(`Something went wrong while retrieving the METAR: ${e.name}\n\n${e.message}`);
|
||||
message.reply(`D-ATIS Error: ${e.message}`);
|
||||
console.error(e);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
|
@ -16,7 +16,7 @@ module.exports = {
|
||||
});
|
||||
} catch (e) {
|
||||
try {
|
||||
message.reply(`Something went wrong while retrieving the METAR: ${e.name}\n\n${e.message}`);
|
||||
message.reply(`METAR Error: ${e.message}`);
|
||||
console.error(e);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
|
@ -831,7 +831,7 @@ const functions = {
|
||||
async getAllICAOs() {
|
||||
const reqUrl = 'https://datis.clowd.io/api/stations';
|
||||
const response = await axios.get(reqUrl);
|
||||
response.forEach(icaoId => {
|
||||
response.data.forEach(icaoId => {
|
||||
config.datisICAOs.push(icaoId);
|
||||
});
|
||||
},
|
||||
|
1
main.js
1
main.js
@ -43,6 +43,7 @@ client.once('ready', async () => {
|
||||
await fn.download.medicalAdvice(client);
|
||||
console.log('Ready!');
|
||||
await fn.avWx.metar.getAllICAOs();
|
||||
await fn.avWx.datis.getAllICAOs();
|
||||
// console.log(JSON.stringify(icaoArray));
|
||||
client.channels.fetch(statusChannelId).then(channel => {
|
||||
channel.send(`${new Date().toISOString()} -- <@${process.env.ownerId}>\nStartup Sequence Complete`);
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "nodbot",
|
||||
"version": "3.3.0",
|
||||
"version": "3.3.1",
|
||||
"description": "Nods and Nod Accessories, now with ChatGPT!",
|
||||
"main": "main.js",
|
||||
"dependencies": {
|
||||
|
Loading…
Reference in New Issue
Block a user