Update from Git Manager GUI

This commit is contained in:
2026-02-25 18:51:08 +01:00
parent de4341a0a9
commit 1567151fce
21 changed files with 2023 additions and 0 deletions

90
commands/changelog.js Normal file
View File

@@ -0,0 +1,90 @@
import { EmbedBuilder, SlashCommandBuilder } from "discord.js";
import { formatText } from "../util/helpers.js";
export default {
name: "changelog",
description: "Zeigt die letzten Update-Beschreibungen eines Plugins an",
aliases: ["cl"],
guild: ["all"],
nsfw: false,
user_permissions: [],
bot_permissions: [],
args_required: 1,
args_usage: "[ressourcen_id] [anzahl] Beispiel: vn!changelog 72678 5",
cooldown: 5,
data: new SlashCommandBuilder()
.setName("changelog")
.setDescription("Zeigt die letzten Updates eines Plugins")
.addStringOption((opt) =>
opt.setName("ressourcen_id").setDescription("Spiget Ressourcen-ID").setRequired(true)
)
.addIntegerOption((opt) =>
opt
.setName("anzahl")
.setDescription("Anzahl der Updates (110, Standard: 3)")
.setMinValue(1)
.setMaxValue(10)
.setRequired(false)
),
async execute(client, ctx, args) {
const resourceID = ctx.isSlash
? ctx.interaction.options.getString("ressourcen_id")
: args[0];
let count = ctx.isSlash
? (ctx.interaction.options.getInteger("anzahl") ?? 3)
: (parseInt(args[1], 10) || 3);
count = Math.min(Math.max(count, 1), 10);
// Fetch resource name
let resourceName = resourceID;
try {
const resInfo = await fetch(`https://api.spiget.org/v2/resources/${resourceID}`);
if (resInfo.ok) {
const data = await resInfo.json();
resourceName = data.name ?? resourceID;
}
} catch { /* ignore */ }
// Fetch updates list
let updates;
try {
const res = await fetch(
`https://api.spiget.org/v2/resources/${resourceID}/updates?size=${count}&sort=-date`
);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
updates = await res.json();
} catch (e) {
client.logger.error(e);
return ctx.reply("Update-Verlauf konnte nicht abgerufen werden. Bitte versuche es erneut.");
}
if (!Array.isArray(updates) || updates.length === 0) {
return ctx.reply(`Für Ressource \`${resourceID}\` wurden keine Updates gefunden.`);
}
const fields = updates.map((u, i) => {
const date = new Date(u.date * 1000).toLocaleDateString("de-DE");
let desc = formatText(Buffer.from(u.description, "base64").toString("utf8"));
if (desc.length > 300) desc = desc.substring(0, 297) + "...";
return {
name: `${i + 1}. ${u.title ?? "Update"} v${u.likes ?? ""} (${date})`,
value: desc || "Keine Beschreibung.",
inline: false,
};
});
const changelogEmbed = new EmbedBuilder()
.setColor(ctx.guild.members.me.displayHexColor)
.setTitle(`📋 Changelog: ${resourceName}`)
.setDescription(`Die letzten **${updates.length}** Updates:`)
.addFields(fields)
.setFooter({ text: `Ressource ID: ${resourceID}` })
.setTimestamp();
return ctx.reply({ embeds: [changelogEmbed] });
},
};