fix subcommands/updates.ts namespace missing
This commit is contained in:
parent
666986afb1
commit
cc5dd22b82
1 changed files with 19 additions and 12 deletions
|
|
@ -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,
|
||||
};
|
||||
Loading…
Add table
Reference in a new issue