v3.3.0-metars #14
@ -11,7 +11,7 @@ module.exports = {
|
|||||||
if (icaoId.length !== 4) throw new Error('Invalid ICAO ID. Provide only one ICAO code at a time like KBOS');
|
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)) {
|
if (fn.avWx.datis.validate(icaoId)) {
|
||||||
const datisData = await fn.avWx.datis.getData(icaoId);
|
const datisData = await fn.avWx.datis.getData(icaoId);
|
||||||
const messagePayload = fn.avWx.datis.parseData(datisData[0]);
|
const messagePayload = fn.avWx.datis.parseData(datisData);
|
||||||
message.reply(messagePayload);
|
message.reply(messagePayload);
|
||||||
} else {
|
} else {
|
||||||
message.reply("No D-ATIS available for the specified ICAO ID.");
|
message.reply("No D-ATIS available for the specified ICAO ID.");
|
||||||
|
26
functions.js
26
functions.js
@ -419,15 +419,29 @@ const functions = {
|
|||||||
},
|
},
|
||||||
datis(datisData) {
|
datis(datisData) {
|
||||||
const messageEmbed = new Discord.MessageEmbed()
|
const messageEmbed = new Discord.MessageEmbed()
|
||||||
.setAuthor({ name: `${datisData.airport} Digital ATIS` })
|
.setAuthor({ name: `${datisData[0].airport} Digital ATIS` })
|
||||||
// .setImage('https://media.discordapp.net/stickers/1175134632845516821.webp')
|
// .setImage('https://media.discordapp.net/stickers/1175134632845516821.webp')
|
||||||
.setDescription(`**Do not use for real world flight planning or navigation.**\n\n${datisData.datis}`)
|
.setDescription(`**Do not use for real world flight planning or navigation.**`)
|
||||||
.addFields(
|
|
||||||
{ name: 'Information', value: `${datisData.code}` },
|
|
||||||
{ name: 'Retreival Time', value: `${new Date().toISOString()}` }
|
|
||||||
)
|
|
||||||
.setFooter({ text: 'D-ATIS by Clowd.io for CumbHub LLC' })
|
.setFooter({ text: 'D-ATIS by Clowd.io for CumbHub LLC' })
|
||||||
|
|
||||||
|
if (datisData.length > 1) {
|
||||||
|
datisData.forEach(data => {
|
||||||
|
if (data.type === 'dep') messageEmbed.addFields({ name: 'Departure Digital ATIS', value: data.datis, inline: false });
|
||||||
|
if (data.type === 'arr') messageEmbed.addFields({ name: 'Arrival Digital ATIS', value: data.datis, inline: false });
|
||||||
|
messageEmbed.addFields({ name: 'Information', value: data.code, inline: true });
|
||||||
|
})
|
||||||
|
messageEmbed.addFields(
|
||||||
|
{ name: 'Retreival Time', value: `${new Date().toISOString()}` }
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
messageEmbed.addFields(
|
||||||
|
{ name: 'Digital ATIS', value: datisData[0].datis, inline: false },
|
||||||
|
{ name: 'Information', value: `${datisData[0].code}`, inline: true },
|
||||||
|
{ name: 'Retreival Time', value: `${new Date().toISOString()}`, inline: true }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const messagePayload = { embeds: [ messageEmbed ] };
|
const messagePayload = { embeds: [ messageEmbed ] };
|
||||||
return messagePayload;
|
return messagePayload;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user