70 lines
1.8 KiB
JavaScript
70 lines
1.8 KiB
JavaScript
// https://api.fynn.ai/events
|
|
// https://vps.anotherfoxguy.com/dl/fur-events.json
|
|
|
|
const axios = require("axios").default;
|
|
const moment = require("moment");
|
|
|
|
const config = require("./config.json");
|
|
|
|
async function main() {
|
|
// let data = (await axios("https://vps.anotherfoxguy.com/dl/fur-events.json")).data;
|
|
let data = (await axios("https://api.fynn.ai/events")).data;
|
|
|
|
let currdate = moment();
|
|
let min = moment().subtract(15, "minutes"); // minutes
|
|
let max = moment().add(15, "minutes");
|
|
|
|
//console.log(dat.data)
|
|
const events = data.filter((event) =>
|
|
moment.unix(event.start).isBetween(min, max)
|
|
);
|
|
|
|
events.forEach((event) => {
|
|
// console.log(moment.unix(event.start).isBetween(min, max))
|
|
// let startTime = moment.unix(event.start)
|
|
// let endTime = moment.unix(event.end)
|
|
// let duration = moment.duration(endTime.diff(startTime))
|
|
console.log(event.name);
|
|
|
|
let message = `${event.name} will start in <t:${event.start}:R>`; // <t:1636124400:R>
|
|
|
|
// axios
|
|
// .post(config.webhookurl, {
|
|
// content: message
|
|
// })
|
|
// .catch(function (error) {
|
|
// console.error(error);
|
|
// });
|
|
});
|
|
|
|
let event = data[1];
|
|
let embed = {
|
|
title: event.name, //`${event.name} will start in <t:${event.start}:R>`,// <t:1636124400:R>
|
|
description: event.description,
|
|
timestamp: moment.unix(event.start),
|
|
url: `https://furality.org/schedule#${event.id}`
|
|
};
|
|
|
|
if (event.image_url != "missing") {
|
|
embed.thumbnail = {
|
|
url: `https://furality.org/${event.image_url}`,
|
|
}
|
|
}
|
|
|
|
// axios
|
|
// .post(config.webhookurl, {
|
|
// embeds: [embed]
|
|
// })
|
|
// .catch(function (error) {
|
|
// console.error(error);
|
|
// });
|
|
|
|
console.log(
|
|
JSON.stringify({
|
|
embeds: [embed],
|
|
})
|
|
);
|
|
}
|
|
|
|
main();
|