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' ], alias: [ 'atis' ],
async execute(message, commandData) { async execute(message, commandData) {
try { try {
const icaoId = commandData.args; const icaoId = commandData.args.toUpperCase();
if (icaoId.length !== 4) throw new Error('Not enough or too many ICAO IDs!') if (icaoId.length !== 4) throw new Error('Invalid ICAO ID. Provide only one ICAO code at a time like KBOS');
const datisData = await fn.avWx.datis.getData(icaoId); if (fn.avWx.datis.validate(icaoId)) {
const messagePayload = fn.avWx.datis.parseData(datisData[0]); const datisData = await fn.avWx.datis.getData(icaoId);
message.reply(messagePayload); 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) { } catch (e) {
try { 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); console.error(e);
} catch (e) { } catch (e) {
console.error(e); console.error(e);

View File

@ -16,7 +16,7 @@ module.exports = {
}); });
} catch (e) { } catch (e) {
try { 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); console.error(e);
} catch (e) { } catch (e) {
console.error(e); console.error(e);

View File

@ -831,7 +831,7 @@ const functions = {
async getAllICAOs() { async getAllICAOs() {
const reqUrl = 'https://datis.clowd.io/api/stations'; const reqUrl = 'https://datis.clowd.io/api/stations';
const response = await axios.get(reqUrl); const response = await axios.get(reqUrl);
response.forEach(icaoId => { response.data.forEach(icaoId => {
config.datisICAOs.push(icaoId); config.datisICAOs.push(icaoId);
}); });
}, },

View File

@ -43,6 +43,7 @@ client.once('ready', async () => {
await fn.download.medicalAdvice(client); await fn.download.medicalAdvice(client);
console.log('Ready!'); console.log('Ready!');
await fn.avWx.metar.getAllICAOs(); await fn.avWx.metar.getAllICAOs();
await fn.avWx.datis.getAllICAOs();
// console.log(JSON.stringify(icaoArray)); // console.log(JSON.stringify(icaoArray));
client.channels.fetch(statusChannelId).then(channel => { client.channels.fetch(statusChannelId).then(channel => {
channel.send(`${new Date().toISOString()} -- <@${process.env.ownerId}>\nStartup Sequence Complete`); channel.send(`${new Date().toISOString()} -- <@${process.env.ownerId}>\nStartup Sequence Complete`);

View File

@ -1,6 +1,6 @@
{ {
"name": "nodbot", "name": "nodbot",
"version": "3.3.0", "version": "3.3.1",
"description": "Nods and Nod Accessories, now with ChatGPT!", "description": "Nods and Nod Accessories, now with ChatGPT!",
"main": "main.js", "main": "main.js",
"dependencies": { "dependencies": {