SHARE
TWEET

Untitled

a guest Jul 23rd, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const botSettings = require("./botSettings.json");
  2. const Discord = require("discord.js");
  3.  
  4. const prefix = botSettings.prefix
  5.  
  6. const bot = new Discord.Client({ disableEveryone: true });
  7.  
  8. function embedMsgICAO(){
  9.     return new Discord.RichEmbed()
  10.         .setTimestamp(Date.now())
  11.         .setDescription("All Airports in ICAOs in Flightline!")
  12.         .addField("Airports:", "-------------------------------------------------")
  13.         .addField("JTPH", "Tophon Bridge Intl.")
  14.         .addField("JSLL", "Wellingsaul Square Intl.")
  15.         .addField("JCO4", "Connerview Airfield")
  16.         .setColor("#00FF00");
  17. }
  18.  
  19. function embedMsgChart(ICAO) {
  20.     return new Discord.RichEmbed()
  21.         .setTimestamp(Date.now())
  22.         .setDescription(`This is the map for ${ICAO}!`)
  23.         .addField(`Below find the link for the Aerodrome map of ${ICAO}`,"Link")
  24.         .setColor("#00FF00");
  25. }
  26.  
  27. function embedMsgHelp(){
  28.     return new Discord.RichEmbed()
  29.     .setTimestamp(Date.now())
  30.     .setTitle("These are the available commands for this bot.")
  31.     .addField("Commands:", "-------------------------------------------------------------------------------------------")
  32.     .addField(`${prefix}ICAOS`, "Displays all the ICAOs for all the airports in Flightline.")
  33.     .addField(`${prefix}{ICAO OF AIRPORT}`, "Displays a link of the map for the chosen airport. (Only in Flightline!)")
  34.     .setFooter("These commands are subject to change should any occur.")
  35.     .setColor("#00FF00");
  36. }
  37.  
  38. function embedMsgATIS(AirportReq, Information, Time, ActRun, Wind, Cloud, Temp, Dew, Altimeter, Remarks){
  39.     return new Discord.RichEmbed()
  40.     .setTitle(`ATIS for ${AirportReq}`)
  41.     .addField("Information for Airport:", `${AirportReq}`)
  42.     .addField("Information:", `${Information}`)
  43.     .addField("Time:", `${Time}`)
  44.     .addField("Active Runways:", `${ActRun}`)
  45.     .addField("Wind:", `${Wind}`)
  46.     .addField("Cloud:", `${Cloud}`)
  47.     .addField("Temperature:", `${Temp}`)
  48.     .addField("Dewpoint:", `${Dew}`)
  49.     .addField("Altimeter:", `${Altimeter}`)
  50.     .addField("Remarks", `${Remarks}`)
  51.     .setFooter("ATIS is constantly updated, beware of sudden weather changes!")
  52.     .setColor("#00FF00");
  53. }
  54.  
  55.  
  56. bot.on("ready", async () => {
  57.     try {
  58.         var link = await bot.generateInvite(["ADMINISTRATOR"]);
  59.     } catch (e) {
  60.         console.log(e.stack)
  61.     }
  62.  
  63.     console.log("--------------------------------------------------------------------------------------------");
  64.     console.log(`Bot is ready! Logged in as: ${bot.user.username}`);
  65.     console.log(`Logged in on: ${botSettings.token}`);
  66.     console.log(`Time Logged on: ${new(Date)}`);
  67.     console.log(`The prefix is: ${prefix}`);
  68.     console.log("Below find the invite link should it be needed for the bot to be invited to another server:");
  69.     console.log(link);
  70.     console.log("--------------------------------------------------------------------------------------------");
  71.  
  72. });
  73.  
  74. bot.on("message", async message => {
  75.     if (message.author.bot) return;
  76.     if (message.channel.type === "dm") return;
  77.  
  78.     let messageArray = message.content.split(" ");
  79.     let command = messageArray[0];
  80.     let args = messageArray.slice(1);
  81.  
  82.     if(!command.startsWith(prefix)) return;
  83.  
  84.     if(command === `${prefix}help`){
  85.         message.channel.send(embedMsgHelp());
  86.     }
  87.  
  88.     if(command === `${prefix}ICAOS`){
  89.         if(args[0] === "JTPH" || "JSLL" || "JCO4") return message.channel.send(embedMsgICAO());
  90.         message.channel.send(embedMsgICAO());
  91.     }
  92.  
  93.     if(command === `${prefix}JTPH`){
  94.         message.channel.send(embedMsgChart(command.slice(1)));
  95.     }
  96.  
  97.     if(command === `${prefix}JSLL`){
  98.         message.channel.send(embedMsgChart(command.slice(1)));
  99.     }
  100.  
  101.     if(command === `${prefix}JCO4`){
  102.         message.channel.send(embedMsgChart(command.slice(1)));
  103.     }
  104.    
  105.     let finishedATISJTPH;
  106.     let finishedATISJSLL;
  107.     let finishedATISJCO4;
  108.  
  109.     if(command === `${prefix}setatis`){
  110.  
  111.         // let guildID = "543398030792065035";
  112.         // let guild = bot.guilds.get(guildID);
  113.         // let member = guild.member();
  114.         // let role = member.roles.find(r => r.name === "Admin Perms")
  115.        
  116.         // if(!member.roles.has(role.id)) message.channel.send("Only ATC's are allowed to set ATIS'es");
  117.  
  118.             let messageArray = message.content.split(",");
  119.             let args = messageArray.slice(1);
  120.        
  121.             let AirportReqIn = args[0];
  122.             let InformationIn = args[1];
  123.             let TimeIn = args[2];
  124.             let ActRunIn = args[3];
  125.             let WindIn = args[4];
  126.             let CloudIn = args[5];
  127.             let TempIn = args[6];
  128.             let DewIn = args[7];
  129.             let AltimeterIn = args[8];
  130.             let RemarksIn = args[9];
  131.  
  132.             definedATISvarJTPH = {
  133.                 AirportReq: AirportReqIn,
  134.                 Information: InformationIn,
  135.                 Time: TimeIn,
  136.                 ActRun: ActRunIn,
  137.                 Wind: WindIn,
  138.                 Cloud: CloudIn,
  139.                 Temp: TempIn,
  140.                 Dew: DewIn,
  141.                 Altimeter: AltimeterIn,
  142.                 Remarks: RemarksIn,
  143.             }
  144.  
  145.             if(args.length < 9) return message.channel.send("Insufficent information provided for the ATIS!");
  146.  
  147.             if(AirportReqIn === "JTPH"){
  148.                 finishedATISJTPH =  embedMsgATIS(definedATISvarJTPH.AirportReq, definedATISvarJTPH.Information, definedATISvarJTPH.Time, definedATISvarJTPH.ActRun, definedATISvarJTPH.Wind, definedATISvarJTPH.Cloud, definedATISvarJTPH.Temp, definedATISvarJTPH.Dew, definedATISvarJTPH.Altimeter, definedATISvarJTPH.Remarks);  
  149.                 message.channel.sendEmbed(finishedATISJTPH);
  150.                 console.log(finishedATISJTPH);
  151.             }
  152.            
  153.             else if(AirportReqIn === "JSLL"){
  154.                 finishedATISJSLL =  embedMsgATIS(definedATISvarJTPH.AirportReq, definedATISvarJTPH.Information, definedATISvarJTPH.Time, definedATISvarJTPH.ActRun, definedATISvarJTPH.Wind, definedATISvarJTPH.Cloud, definedATISvarJTPH.Temp, definedATISvarJTPH.Dew, definedATISvarJTPH.Altimeter, definedATISvarJTPH.Remarks);
  155.                 message.channel.send(finishedATISJSLL);
  156.             }
  157.  
  158.             else if(AirportReqIn === "JCO4"){
  159.                 finishedATISJCO4 =  embedMsgATIS(definedATISvarJTPH.AirportReq, definedATISvarJTPH.Information, definedATISvarJTPH.Time, definedATISvarJTPH.ActRun, definedATISvarJTPH.Wind, definedATISvarJTPH.Cloud, definedATISvarJTPH.Temp, definedATISvarJTPH.Dew, definedATISvarJTPH.Altimeter, definedATISvarJTPH.Remarks);
  160.                 message.channel.send(finishedATISJCO4);
  161.             }
  162.     }
  163.  
  164.  
  165.  
  166.     if(command === `${prefix}atis` || `${prefix}ATIS`){
  167.  
  168.         let AirportChosen = args[0];
  169.        
  170.         if (AirportChosen === "JTPH") {
  171.             message.channel.sendEmbed(finishedATISJTPH);
  172.         }
  173.  
  174.         if (AirportChosen === "JSLL") {
  175.             message.channel.send(finishedATISJSLL);
  176.         }
  177.  
  178.         if (AirportChosen === "JCO4") {
  179.             message.channel.send(finishedATISJCO4);
  180.         }
  181.     }
  182.  
  183.     });
  184.  
  185. bot.login(botSettings.token);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top