This commit is contained in:
parent
e02faaab18
commit
79ae2f4c25
40
index.js
40
index.js
|
@ -6,7 +6,7 @@ const wfos = require("./data/wfos.json");
|
|||
const blacklist = require("./data/blacklist.json");
|
||||
const events = require("./data/events.json");
|
||||
const outlookURLs = require("./data/outlook.json");
|
||||
const sattelites = require("./data/sattelites.json");
|
||||
const satellites = require("./data/satellites.json");
|
||||
const nwrstreams = {callsigns:{}};
|
||||
const Jimp = require("jimp");
|
||||
const { client, xml } = require("@xmpp/client");
|
||||
|
@ -682,19 +682,19 @@ discord.on('ready', async () => {
|
|||
commands = require("./data/commands.json");
|
||||
// Add dynamic commands (based on datas files)
|
||||
satCommand = {
|
||||
"name": "sattelite",
|
||||
"description": "Get the latest sattelite images from a given sattelite",
|
||||
"name": "satellite",
|
||||
"description": "Get the latest satellite images from a given satellite",
|
||||
"options": [
|
||||
{
|
||||
"name": "sattelite",
|
||||
"description": "The sattelite to get images from",
|
||||
"name": "satellite",
|
||||
"description": "The satellite to get images from",
|
||||
"type": 3,
|
||||
"required": true,
|
||||
"choices": []
|
||||
}
|
||||
]
|
||||
}
|
||||
for (const key in sattelites) {
|
||||
for (const key in satellites) {
|
||||
satCommand.options[0].choices.push({
|
||||
"name": key,
|
||||
"value": key
|
||||
|
@ -1333,18 +1333,18 @@ discord.on("interactionCreate", async (interaction) => {
|
|||
console.error(err);
|
||||
});
|
||||
break;
|
||||
case "sattelite": // Get satellite images
|
||||
sat = interaction.options.getString("sattelite");
|
||||
if (!sattelites[sat]) return interaction.reply({ content: "Invalid satellite", ephemeral: true });
|
||||
case "satellite": // Get satellite images
|
||||
sat = interaction.options.getString("satellite");
|
||||
if (!satellites[sat]) return interaction.reply({ content: "Invalid satellite", ephemeral: true });
|
||||
// Fetch all the images
|
||||
productOptions = []
|
||||
await (() => {
|
||||
for (const key in sattelites[sat].products) {
|
||||
// make a discord customid safe id for the product name, add it to the sattelites object
|
||||
sattelites[sat].products[key].customid = key.replace(/[^a-zA-Z0-9]/g, "").toLowerCase();
|
||||
for (const key in satellites[sat].products) {
|
||||
// make a discord customid safe id for the product name, add it to the satellites object
|
||||
satellites[sat].products[key].customid = key.replace(/[^a-zA-Z0-9]/g, "").toLowerCase();
|
||||
productOptions.push({
|
||||
label: key,
|
||||
value: sattelites[sat].products[key].customid
|
||||
value: satellites[sat].products[key].customid
|
||||
})
|
||||
}
|
||||
console.log(JSON.stringify(productOptions, null, 2))
|
||||
|
@ -1427,7 +1427,7 @@ discord.on("interactionCreate", async (interaction) => {
|
|||
sat = satData.sat
|
||||
product = interaction.values[0];
|
||||
// find the original product name
|
||||
product_name = Object.keys(sattelites[sat].products).find(key => sattelites[sat].products[key].customid === product);
|
||||
product_name = Object.keys(satellites[sat].products).find(key => satellites[sat].products[key].customid === product);
|
||||
imageOptions = []
|
||||
satMessages[interaction.customId.split("|")[1]] = {
|
||||
sat,
|
||||
|
@ -1436,13 +1436,13 @@ discord.on("interactionCreate", async (interaction) => {
|
|||
images: {}
|
||||
}
|
||||
await (() => {
|
||||
// for key, value in sattelites[sat].products[product_name]
|
||||
// for key, value in satellites[sat].products[product_name]
|
||||
console.log(product_name)
|
||||
for (const key in sattelites[sat].products[product_name]) {
|
||||
// make a discord customid safe id for the product name, add it to the sattelites object
|
||||
//console.log(sattelites[sat].products[product_name])
|
||||
for (const key in satellites[sat].products[product_name]) {
|
||||
// make a discord customid safe id for the product name, add it to the satellites object
|
||||
//console.log(satellites[sat].products[product_name])
|
||||
if (key === "customid") continue;
|
||||
satMessages[interaction.customId.split("|")[1]].images[key.replace(/[^a-zA-Z0-9]/g, "").toLowerCase()] = sattelites[sat].products[product_name][key];
|
||||
satMessages[interaction.customId.split("|")[1]].images[key.replace(/[^a-zA-Z0-9]/g, "").toLowerCase()] = satellites[sat].products[product_name][key];
|
||||
imageOptions.push({
|
||||
label: key,
|
||||
value: key.replace(/[^a-zA-Z0-9]/g, "").toLowerCase()
|
||||
|
@ -1646,5 +1646,7 @@ process.on("uncaughtException", (error) => {
|
|||
return;
|
||||
});
|
||||
|
||||
|
||||
|
||||
// Login to discord
|
||||
discord.login(config.discord.token);
|
Loading…
Reference in a new issue