Advertisement
Guest User

Untitled

a guest
May 20th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1.  
  2. if (cmd == `${prefix}taf`) {
  3. console.log(`TAF for ${args} by ${message.author.tag}`);
  4. let argz = args.map(e=>e.toUpperCase());
  5. let reqURL = `https://avwx.rest/api/taf/${argz}?options=summary`;
  6. message.channel.startTyping(true);
  7. let response = await fetch(reqURL);
  8. let json = fixKeys(await response.json());
  9. let optText = (truthy, ifTrue, ifFalse = '') => truthy ? ifTrue : ifFalse;
  10. if (json.Error) {
  11. let briefErrorEmbed = new Discord.RichEmbed()
  12. .setTitle(`${argz} is not a valid ICAO`)
  13. .setDescription('ERROR 404 [ICOA not found]')
  14. .addField('Quick Tip:', 'ICAOs almost always have four letters', true)
  15. .addBlankField(true)
  16. .addField('Example:', 'EDDF', true)
  17. .setColor("#1BE5E3");
  18. message.channel.stopTyping(true);
  19. console.log('Oop something fucked up')
  20. return message.channel.send(briefErrorEmbed);
  21. }
  22. message.channel.stopTyping(true);
  23. let TAFEmbed = new Discord.RichEmbed()
  24. .setTitle(`TAF for ${json.Station}`)
  25. .setColor("#1BE5E3")
  26. .setDescription(`${json.RawReport}`)
  27. .addField('Readable', `${json.Forecast[0].Summary}`, true)
  28. .setFooter('This is not a source for official weather briefing. Please obtain a weather briefing from the appropriate agency.');
  29. message.channel.send(TAFEmbed);
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement