diff --git a/src/commands/version.ts b/src/commands/version.ts new file mode 100644 index 00000000..cc9d51e1 --- /dev/null +++ b/src/commands/version.ts @@ -0,0 +1,29 @@ +import { + JBONSAI_VERSION, + JPREPROCESS_VERSION, + OM_SYRINX_VERSION, +} from "@discordjs-japan/om-syrinx"; +import type { + ChatInputCommandInteraction, + RESTPostAPIChatInputApplicationCommandsJSONBody, +} from "discord.js"; +import { OM_VERSION } from "../version"; + +export const definition = { + name: "version", + description: "バージョン情報を表示します。", +} satisfies RESTPostAPIChatInputApplicationCommandsJSONBody; + +export async function handler( + interaction: ChatInputCommandInteraction<"cached">, +) { + await interaction.reply({ + content: `\`\`\` +discordjs-japan/om: ${OM_VERSION} +discordjs-japan/om-syrinx: ${OM_SYRINX_VERSION} +jpreprocess/jpreprocess: ${JPREPROCESS_VERSION} +jpreprocess/jbonsai: ${JBONSAI_VERSION} +\`\`\``, + ephemeral: true, + }); +} diff --git a/src/main.ts b/src/main.ts index 432c8268..32c00bd8 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,9 +2,10 @@ import { ActivityType, Client, Events, GatewayIntentBits } from "discord.js"; import * as join from "./commands/join"; import * as leave from "./commands/leave"; import * as skip from "./commands/skip"; +import * as version from "./commands/version"; import { ReplyableError } from "./error"; import Pipeline from "./pipeline"; -import { version } from "./version"; +import { OM_VERSION } from "./version"; const client = new Client({ intents: [ @@ -20,6 +21,8 @@ client.on(Events.InteractionCreate, async (interaction) => { if (!interaction.isChatInputCommand()) return; try { switch (interaction.commandName) { + case "version": + return await version.handler(interaction); case "join": return await join.handler(interaction); case "leave": @@ -50,13 +53,14 @@ client.on(Events.VoiceStateUpdate, async (_, n) => { client.once(Events.ClientReady, async (client) => { client.application.commands.cache.clear(); await client.application.commands.set([ + version.definition, join.definition, leave.definition, skip.definition, ]); client.user.setActivity({ type: ActivityType.Custom, - name: `v${version}`, + name: `v${OM_VERSION}`, }); }); diff --git a/src/version.ts b/src/version.ts index 48e73936..1ed8680d 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const version: string = "[VI]{{inject}}[/VI]"; +export const OM_VERSION: string = "[VI]{{inject}}[/VI]";