feat: Add information command
This commit is contained in:
parent
528d7f09eb
commit
d0484dae0c
2 changed files with 85 additions and 0 deletions
76
src/commands/information.ts
Normal file
76
src/commands/information.ts
Normal file
|
@ -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<Command.Options>({
|
||||||
|
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<true>) {
|
||||||
|
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()),
|
||||||
|
],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,6 +17,7 @@ declare module '@sapphire/pieces' {
|
||||||
}
|
}
|
||||||
channel: ReleaseChannel
|
channel: ReleaseChannel
|
||||||
dokdo: Client
|
dokdo: Client
|
||||||
|
updatedAt: Date
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,4 +47,12 @@ else if (container.version.includes(ReleaseChannel.Dev))
|
||||||
else if (container.version.includes(ReleaseChannel.Canary))
|
else if (container.version.includes(ReleaseChannel.Canary))
|
||||||
container.channel = 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)
|
await connect(container.config.databaseUrl)
|
||||||
|
|
Reference in a new issue