Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add version command #379

Merged
merged 2 commits into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/commands/version.ts
Original file line number Diff line number Diff line change
@@ -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: `\`\`\`
Mogyuchi marked this conversation as resolved.
Show resolved Hide resolved
discordjs-japan/om: ${OM_VERSION}
discordjs-japan/om-syrinx: ${OM_SYRINX_VERSION}
jpreprocess/jpreprocess: ${JPREPROCESS_VERSION}
jpreprocess/jbonsai: ${JBONSAI_VERSION}
\`\`\``,
ephemeral: true,
});
}
8 changes: 6 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -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":
Expand Down Expand Up @@ -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}`,
});
});

Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const version: string = "[VI]{{inject}}[/VI]";
export const OM_VERSION: string = "[VI]{{inject}}[/VI]";
Loading