Last active
July 4, 2020 13:28
-
-
Save GuyInGrey/84b6cc5d3ccab486485fab970fbb2dd5 to your computer and use it in GitHub Desktop.
New Command for Icarus - Work In Progress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Augur = require("augurbot"), | |
u = require("../utils/utils"); | |
const request = require("request-promise-native"); | |
function getFromAPI(params) { | |
var url = "https://www.edsm.net/api-v1/" + params; | |
return JSON.parse(request(url)); | |
} | |
const Module = new Augur.Module() | |
.addCommand({name: "elite", | |
description: "Elite Dangerous information. Use `!elite help` for more.", | |
syntax: "See `!elite help`", | |
aliases: [], | |
process: (msg, suffix) => { | |
let [command, ...params] = suffix.split(" "); | |
let remainder = params.join(" "); | |
switch (command) | |
{ | |
// Returns help for subcommands. | |
// Will be added once the rest is done. | |
case "help": | |
msg.channel.send("Not *yet* implemented. I might work faster if you give me a :buttermelon:") | |
break; | |
case "system": | |
let starSystem = getFromAPI("system?showPrimaryStar=1&showInformation=1&showPermit=1&systemName=" + remainder); | |
if (starSystem) { | |
let embed = u.embed(); | |
embed.setThumbnail("https://i.imgur.com/Ud8MOzY.png"); | |
embed.setTitle(starSystem.name); | |
if (starSystem.information) { | |
embed.addField("Controlling Faction", starSystem.information.faction); | |
embed.addField("Government Type", starSystem.information.allegiance + " - " + starSystem.information.government); | |
} | |
embed.addField("Permit Required", starSystem.requirePermit); | |
if (starSystem.primaryStar) { | |
embed.addField("Star Scoopable", starSystem.primaryStar.isScoopable); | |
} | |
embed.setFooter("https://www.edsm.net/en/system/id/17631/name/" + starSystem.name.replace(" ", "+")); | |
msg.channel.send({reply}); | |
break; | |
} else { | |
msg.channel.send("I couldn't find a system with that name."); | |
} | |
} | |
} | |
}) | |
module.exports = Module; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment