2024-11-17 16:42:48 +01:00
|
|
|
import fetch from "node-fetch";
|
2024-11-24 18:47:47 +01:00
|
|
|
import {EmbedBuilder} from "discord.js";
|
2024-11-17 16:42:48 +01:00
|
|
|
|
2024-11-24 18:47:47 +01:00
|
|
|
const embed = new EmbedBuilder()
|
|
|
|
.setColor('#ffffff')
|
|
|
|
.setTitle('Changelog')
|
|
|
|
.setURL('https://github.com/JustusPlays78/ES_AIRAC_PACKAGE_UPDATER/releases')
|
|
|
|
.setAuthor({ name: 'Sevenity', iconURL: 'https://sevenity.net/images/logo.png' })
|
|
|
|
const date = new Date();
|
2024-11-17 16:42:48 +01:00
|
|
|
|
2024-11-24 18:47:47 +01:00
|
|
|
|
|
|
|
export async function fetchText(url, accessToken){
|
2024-11-17 16:42:48 +01:00
|
|
|
try {
|
2024-11-24 18:47:47 +01:00
|
|
|
const response = await fetch(url, {
|
|
|
|
method: 'GET',
|
|
|
|
headers: {
|
|
|
|
'Authorization': `Bearer ${accessToken}`,
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2024-11-17 16:42:48 +01:00
|
|
|
if (!response.ok) {
|
|
|
|
throw new Error(`HTTP-Fehler! Status: ${response.status}`);
|
|
|
|
}
|
2024-11-24 18:47:47 +01:00
|
|
|
|
2024-11-17 16:42:48 +01:00
|
|
|
const text = await response.text();
|
2024-11-24 18:47:47 +01:00
|
|
|
return text;
|
2024-11-17 16:42:48 +01:00
|
|
|
} catch (error) {
|
|
|
|
console.error('Fehler beim Abrufen der Datei:', error);
|
2024-11-24 18:47:47 +01:00
|
|
|
throw error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function getChanges(result){
|
|
|
|
const lines = result.split('\n');
|
|
|
|
let dayChangesArray = [];
|
|
|
|
let days = [];
|
|
|
|
let daysChangeString = [];
|
|
|
|
|
|
|
|
for (let line of lines) {
|
|
|
|
if (line.startsWith('## ')) {
|
|
|
|
const Day = line.replace('## ', '');
|
|
|
|
days.push(Day);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//console.log(JSON.stringify(changes, null, 2));
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
class DayChanges {
|
|
|
|
constructor(id,day,fixes,features,otherChanges) {
|
|
|
|
this.id = id;
|
|
|
|
this.day = day;
|
|
|
|
this.fixes = fixes;
|
|
|
|
this.otherChanges = otherChanges;
|
2024-11-17 16:42:48 +01:00
|
|
|
}
|
|
|
|
}
|