feat(experimental): Testing slash command feature

This commit is contained in:
Siwoo Jeon 2024-09-28 16:48:08 +09:00
parent 68ff1429e1
commit f4b479a9ca
Signed by: migan
GPG key ID: 036E9A8C5E8E48DA
2 changed files with 57 additions and 43 deletions

View file

@ -1,6 +1,6 @@
{
"name": "muffinbot",
"version": "4.0.0-pudding.d240928c",
"version": "4.0.0-pudding.experimental_slash_test.1",
"main": "dist/index.js",
"private": true,
"dependencies": {

View file

@ -1,6 +1,6 @@
import { ApplyOptions } from '@sapphire/decorators'
import { type ChatInputCommandInteraction, APIEmbed, Message } from 'discord.js'
import { Command, container } from '@sapphire/framework'
import { Message } from 'discord.js'
import { ApplyOptions } from '@sapphire/decorators'
import { platform, arch } from 'os'
@ApplyOptions<Command.Options>({
@ -11,49 +11,63 @@ import { platform, arch } from 'os'
},
})
class InformationCommand extends Command {
public async messageRun(msg: Message) {
await msg.reply({
embeds: [
public registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(builder =>
builder.setName(this.name).setDescription(this.description),
)
}
private async _embed(): Promise<APIEmbed> {
return {
title: `${this.container.client.user?.username}의 정ㅂ보`,
fields: [
{
title: `${this.container.client.user?.username}의 정ㅂ보`,
fields: [
{
name: '구동ㅎ환경',
value: `${platform()} ${arch()}`,
inline: false,
},
{
name: '버ㅈ전',
value: this.container.version,
inline: true,
},
{
name: '채ㄴ널',
value: this.container.channel.toLowerCase(),
inline: true,
},
{
name: '최근 업ㄷ데이트 날짜',
value: this.container.lastUpdated.toLocaleDateString('ko', {
dateStyle: 'long',
}),
inline: true,
},
{
name: '개ㅂ발자',
value: (
await this.container.client.users.fetch(
this.container.config.bot.owner_ID,
)
).username,
inline: false,
},
],
thumbnail: {
url: this.container.client.user!.displayAvatarURL()!,
},
name: '구동ㅎ환경',
value: `${platform()} ${arch()}`,
inline: false,
},
{
name: '버ㅈ전',
value: this.container.version,
inline: true,
},
{
name: '채ㄴ널',
value: this.container.channel.toLowerCase(),
inline: true,
},
{
name: '최근 업ㄷ데이트 날짜',
value: this.container.lastUpdated.toLocaleDateString('ko', {
dateStyle: 'long',
}),
inline: true,
},
{
name: '개ㅂ발자',
value: (
await this.container.client.users.fetch(
this.container.config.bot.owner_ID,
)
).username,
inline: false,
},
],
thumbnail: {
url: this.container.client.user!.displayAvatarURL()!,
},
}
}
public async messageRun(msg: Message) {
await msg.reply({
embeds: [await this._embed()],
})
}
public async chatInputRun(interaction: ChatInputCommandInteraction) {
await interaction.reply({
embeds: [await this._embed()],
})
}
}