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