Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (cmd == `${prefix}taf`) {
- console.log(`TAF for ${args} by ${message.author.tag}`);
- let argz = args.map(e=>e.toUpperCase());
- let reqURL = `https://avwx.rest/api/taf/${argz}?options=summary`;
- message.channel.startTyping(true);
- let response = await fetch(reqURL);
- let json = fixKeys(await response.json());
- let optText = (truthy, ifTrue, ifFalse = '') => truthy ? ifTrue : ifFalse;
- if (json.Error) {
- let briefErrorEmbed = new Discord.RichEmbed()
- .setTitle(`${argz} is not a valid ICAO`)
- .setDescription('ERROR 404 [ICOA not found]')
- .addField('Quick Tip:', 'ICAOs almost always have four letters', true)
- .addBlankField(true)
- .addField('Example:', 'EDDF', true)
- .setColor("#1BE5E3");
- message.channel.stopTyping(true);
- console.log('Oop something fucked up')
- return message.channel.send(briefErrorEmbed);
- }
- message.channel.stopTyping(true);
- let TAFEmbed = new Discord.RichEmbed()
- .setTitle(`TAF for ${json.Station}`)
- .setColor("#1BE5E3")
- .setDescription(`${json.RawReport}`)
- .addField('Readable', `${json.Forecast[0].Summary}`, true)
- .setFooter('This is not a source for official weather briefing. Please obtain a weather briefing from the appropriate agency.');
- message.channel.send(TAFEmbed);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement