From d0484dae0cb11065731383981f7cc618c2a1512d Mon Sep 17 00:00:00 2001 From: Siwoo Jeon Date: Sat, 15 Mar 2025 12:48:29 +0900 Subject: [PATCH] feat: Add information command --- src/commands/information.ts | 76 +++++++++++++++++++++++++++++++++++++ src/init.ts | 9 +++++ 2 files changed, 85 insertions(+) create mode 100644 src/commands/information.ts diff --git a/src/commands/information.ts b/src/commands/information.ts new file mode 100644 index 0000000..e1c3c9a --- /dev/null +++ b/src/commands/information.ts @@ -0,0 +1,76 @@ +import type { Context } from '../lib/context' +import { ApplyOptions } from '@sapphire/decorators' +import { Command } from '@sapphire/framework' +import { + ChatInputCommandInteraction, + EmbedBuilder, + inlineCode, + Message, + time, +} from 'discord.js' + +@ApplyOptions({ + name: '정보', + description: '머핀봇의 정보를 알ㄹ려줘요.', + detailedDescription: { + usage: '머핀아 정보', + }, +}) +export default class InformationCommand extends Command { + public registerApplicationCommands(registry: Command.Registry) { + registry.registerChatInputCommand(builder => + builder.setName(this.name).setDescription(this.description), + ) + } + + public async messageRun(msg: Message) { + return await this._run(msg) + } + + public async chatInputRun( + interaction: ChatInputCommandInteraction<'cached'>, + ) { + return await this._run(interaction) + } + + private async _run(ctx: Context) { + return await ctx.reply({ + embeds: [ + new EmbedBuilder() + .setTitle(`${ctx.client.user.username}의 정보`) + .addFields( + { + name: '운영 체제', + value: inlineCode(`${process.platform} ${process.arch}`), + }, + { + name: '제작자', + value: inlineCode( + ( + await ctx.client.users.fetch( + this.container.config.bot.ownerId, + ) + ).username, + ), + }, + { + name: '버전', + value: inlineCode(this.container.version), + }, + { + name: '최근에 업데이트된 날짜', + value: time(this.container.updatedAt, 'R'), + inline: true, + }, + { + name: '업타임', + value: time(ctx.client.readyAt, 'R'), + inline: true, + }, + ) + .setColor(this.container.embedColors.default) + .setThumbnail(ctx.client.user.displayAvatarURL()), + ], + }) + } +} diff --git a/src/init.ts b/src/init.ts index 0b1f0b6..c845560 100644 --- a/src/init.ts +++ b/src/init.ts @@ -17,6 +17,7 @@ declare module '@sapphire/pieces' { } channel: ReleaseChannel dokdo: Client + updatedAt: Date } } @@ -46,4 +47,12 @@ else if (container.version.includes(ReleaseChannel.Dev)) else if (container.version.includes(ReleaseChannel.Canary)) container.channel = ReleaseChannel.Canary +const updatedString = container.version.match(/\d+/g)![3] + +container.updatedAt = new Date( + `20${updatedString.slice(0, 2)}-` + + `${updatedString.slice(2, 4)}-` + + `${updatedString.slice(4, 6)}`, +) + await connect(container.config.databaseUrl)