fix subcommands/updates.ts namespace missing

This commit is contained in:
Nuno Duque Nunes 2026-06-12 16:31:38 +01:00
parent 666986afb1
commit cc5dd22b82

View file

@ -1,18 +1,18 @@
import { ChatInputCommandInteraction } from "discord.js";
import { Updates } from "@systems/updates";
import { Discord } from "@discord";
export async function handleUpdatesPost(interaction: ChatInputCommandInteraction): Promise<void> {
await Discord.Interaction.deferReply(interaction, { ephemeral: true });
const opts = Discord.Interaction.options(interaction);
const version = opts.string({ key: "version" }) ?? Updates.latest();
if (!version) {
await Discord.Interaction.editReply(interaction, "❌ No versions found.");
return;
}
try {
await Updates.post({ version, client: interaction.client });
await Discord.Interaction.editReply(interaction, `✅ Update \`${version}\` posted.`);
@ -20,21 +20,21 @@ export async function handleUpdatesPost(interaction: ChatInputCommandInteraction
await Discord.Interaction.editReply(interaction, `❌ Failed: ${err.message}`);
}
}
export async function handleUpdatesPreview(interaction: ChatInputCommandInteraction): Promise<void> {
await Discord.Interaction.deferReply(interaction, { ephemeral: true });
const opts = Discord.Interaction.options(interaction);
const version = opts.string({ key: "version" }) ?? Updates.latest();
if (!version) {
await Discord.Interaction.editReply(interaction, "❌ No versions found.");
return;
}
await Updates.preview({ version, interaction });
}
export async function handleUpdatesList(interaction: ChatInputCommandInteraction): Promise<void> {
const versions = Updates.list();
const latest = Updates.latest();
@ -43,13 +43,13 @@ export async function handleUpdatesList(interaction: ChatInputCommandInteraction
const tag = v === latest ? " ← latest" : "";
return `\`${v}\`${entry?.title ?? ""}${tag}`;
});
await Discord.Interaction.reply(interaction, {
content: lines.length > 0 ? lines.join("\n") : "No versions found.",
ephemeral: true,
});
}
export async function autocompleteVersion(interaction: any): Promise<void> {
const focused = interaction.options.getFocused().toLowerCase();
const versions = Updates.list();
@ -61,4 +61,11 @@ export async function autocompleteVersion(interaction: any): Promise<void> {
})
.slice(0, 25);
await interaction.respond(choices);
}
}
export const UpdatesCommands = {
post: handleUpdatesPost,
preview: handleUpdatesPreview,
list: handleUpdatesList,
autocomplete: autocompleteVersion,
};