Fix split ATISes
This commit is contained in:
parent
b11d14b72d
commit
550eb79374
@ -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 (fn.avWx.datis.validate(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);
|
||||
} else {
|
||||
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) {
|
||||
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')
|
||||
.setDescription(`**Do not use for real world flight planning or navigation.**\n\n${datisData.datis}`)
|
||||
.addFields(
|
||||
{ name: 'Information', value: `${datisData.code}` },
|
||||
{ name: 'Retreival Time', value: `${new Date().toISOString()}` }
|
||||
)
|
||||
.setDescription(`**Do not use for real world flight planning or navigation.**`)
|
||||
.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 ] };
|
||||
return messagePayload;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user