feat: Feture add help command

This commit is contained in:
Siwoo Jeon 2024-06-23 15:16:54 +09:00
parent b918324c5f
commit 8263ad06b9
Signed by: migan
GPG key ID: C4151385FFD2082A
7 changed files with 100 additions and 22 deletions

View file

@ -1,6 +1,6 @@
{
"name": "muffinbot",
"version": "3.0.0-cake.d240622b",
"version": "3.0.0-cake.d240623a",
"main": "dist/index.js",
"private": true,
"dependencies": {

View file

@ -1,10 +1,12 @@
import { SapphireClient, container, LogLevel } from '@sapphire/framework'
import { GatewayIntentBits, type Snowflake } from 'discord.js'
import { ChatBot, NODE_ENV, MaaDatabase } from './modules'
import { version } from '../package.json'
import config from '../config.json'
container.config = config
container.prefix = '머핀아 '
container.version = version
container.database = new MaaDatabase()
container.chatBot = new ChatBot(container.database)
@ -35,6 +37,7 @@ declare module '@sapphire/pieces' {
database: MaaDatabase
chatBot: ChatBot
prefix: string
version: string
config: {
bot: {
owner_ID: Snowflake
@ -53,3 +56,10 @@ declare module '@sapphire/pieces' {
}
}
}
declare module '@sapphire/framework' {
interface DetailedDescriptionCommandObject {
usage: string
examples?: string[]
}
}

View file

@ -6,7 +6,11 @@ import { type Message } from 'discord.js'
@ApplyOptions<Command.Options>({
name: '삭제',
aliases: ['지워', '잊어'],
description: '배운 단어를 삭ㅈ제해요.'
description: '배운 단어를 삭ㅈ제해요.',
detailedDescription: {
usage: '머핀아 삭제 (삭제할 단어)',
examples: ['머핀아 삭제 머핀'],
},
})
export default class extends Command {
public async messageRun(msg: Message, args: Args) {

View file

@ -1,34 +1,84 @@
import { codeBlock, type Message } from 'discord.js'
import { ApplyOptions } from '@sapphire/decorators'
import { Command } from '@sapphire/framework'
import { version } from '../../package.json'
import { Args, Command } from '@sapphire/framework'
@ApplyOptions<Command.Options>({
name: '도움말',
aliases: ['명령어', '도움', 'help'],
description: '기본적인 사용ㅂ법이에요.',
detailedDescription: {
usage: '머핀아 도움말 [명령어]',
examples: ['머핀아 도움말', '머핀아 도움말 배워'],
},
})
export default class extends Command {
public async messageRun(msg: Message) {
const commandList: string[] = []
public async messageRun(msg: Message, args: Args) {
const commandName = await args.pick('string').catch(() => null)
if (
!commandName ||
!this.container.stores.get('commands').get(commandName)
) {
const commandList: string[] = []
this.container.stores.get('commands').forEach(module => {
commandList.push(module.name)
})
this.container.stores.get('commands').forEach(module => {
commandList.push(module.name)
})
await msg.reply({
embeds: [
{
title: '머핀봇의 도움말',
description: codeBlock(
'md',
commandList.map(item => `- ${item}`).join('\n'),
),
footer: {
text: `머핀봇 버전: ${version}`,
await msg.reply({
embeds: [
{
title: '머핀봇의 도움말',
description: codeBlock(
'md',
commandList.map(item => `- ${item}`).join('\n'),
),
footer: {
text: `머핀봇 버전: ${this.container.version}`,
},
},
},
],
})
],
})
} else {
const { name, aliases, description, detailedDescription } =
this.container.stores.get('commands').get(commandName)!
if (typeof detailedDescription === 'string') return
await msg.reply({
embeds: [
{
title: '머핀봇의 도움말',
description: `명령어: ${name}`,
fields: [
{
name: '설명',
value: description,
inline: true,
},
{
name: '별칭',
value: aliases.map(item => `\`${item}\``).join(', '),
inline: true,
},
{
name: '사용법',
value: `\`${detailedDescription.usage}\``,
inline: true,
},
detailedDescription.examples
? {
name: '예시',
value: `\`\`\`${detailedDescription.examples.map(item => item).join('\n')}\`\`\``,
inline: false,
}
: {
name: '예시',
value: '없음',
inline: false,
},
],
},
],
})
}
}
}

View file

@ -6,6 +6,14 @@ import { type Message } from 'discord.js'
name: '배워',
aliases: ['공부'],
description: '단어를 가르치는 명령ㅇ어에요.',
detailedDescription: {
usage: '머핀아 배워 (등록할 단어) (대답)',
examples: [
'머핀아 배워 안녕 안녕!',
'머핀아 배워 "야 죽을래?" "아니요 ㅠㅠㅠ"',
'머핀아 배워 미간은_누구야? 이봇의_개발자요',
],
},
})
export default class extends Command {
public async messageRun(msg: Message, args: Args) {

View file

@ -7,6 +7,9 @@ import { type Message } from 'discord.js'
name: '데이터학습량',
aliases: ['학습데이터량', '데이터량'],
description: '봇이 학습한 데ㅇ이터량을 보여줘요.',
detailedDescription: {
usage: '머핀아 학습데이터량',
},
})
export default class extends Command {
public async messageRun(msg: Message<true>) {

View file

@ -6,6 +6,9 @@ import { Command } from '@sapphire/framework'
name: '리스트',
aliases: ['list', '목록'],
description: '당신이 가ㄹ르쳐준 단어를 나열해요.',
detailedDescription: {
usage: '머핀아 리스트'
}
})
export default class extends Command {
public async messageRun(msg: Message<boolean>) {