v3.3.0-metars #14

Merged
voidf1sh merged 16 commits from v3.3.0-metars into main 2024-09-24 01:04:49 +00:00
5 changed files with 14 additions and 9 deletions
Showing only changes of commit b11d14b72d - Show all commits

View File

@ -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);

View File

@ -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);

View File

@ -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);
});
},

View File

@ -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`);

View File

@ -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": {