3.0.0-Cake #5

Merged
migan merged 33 commits from release/3.0.0 into main 2024-08-14 14:16:30 +00:00
7 changed files with 100 additions and 22 deletions
Showing only changes of commit 8263ad06b9 - Show all commits

View file

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

View file

@ -1,10 +1,12 @@
import { SapphireClient, container, LogLevel } from '@sapphire/framework' import { SapphireClient, container, LogLevel } from '@sapphire/framework'
import { GatewayIntentBits, type Snowflake } from 'discord.js' import { GatewayIntentBits, type Snowflake } from 'discord.js'
import { ChatBot, NODE_ENV, MaaDatabase } from './modules' import { ChatBot, NODE_ENV, MaaDatabase } from './modules'
import { version } from '../package.json'
import config from '../config.json' import config from '../config.json'
container.config = config container.config = config
container.prefix = '머핀아 ' container.prefix = '머핀아 '
container.version = version
container.database = new MaaDatabase() container.database = new MaaDatabase()
container.chatBot = new ChatBot(container.database) container.chatBot = new ChatBot(container.database)
@ -35,6 +37,7 @@ declare module '@sapphire/pieces' {
database: MaaDatabase database: MaaDatabase
chatBot: ChatBot chatBot: ChatBot
prefix: string prefix: string
version: string
config: { config: {
bot: { bot: {
owner_ID: Snowflake 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>({ @ApplyOptions<Command.Options>({
name: '삭제', name: '삭제',
aliases: ['지워', '잊어'], aliases: ['지워', '잊어'],
description: '배운 단어를 삭ㅈ제해요.' description: '배운 단어를 삭ㅈ제해요.',
detailedDescription: {
usage: '머핀아 삭제 (삭제할 단어)',
examples: ['머핀아 삭제 머핀'],
},
}) })
export default class extends Command { export default class extends Command {
public async messageRun(msg: Message, args: Args) { public async messageRun(msg: Message, args: Args) {

View file

@ -1,34 +1,84 @@
import { codeBlock, type Message } from 'discord.js' import { codeBlock, type Message } from 'discord.js'
import { ApplyOptions } from '@sapphire/decorators' import { ApplyOptions } from '@sapphire/decorators'
import { Command } from '@sapphire/framework' import { Args, Command } from '@sapphire/framework'
import { version } from '../../package.json'
@ApplyOptions<Command.Options>({ @ApplyOptions<Command.Options>({
name: '도움말', name: '도움말',
aliases: ['명령어', '도움', 'help'], aliases: ['명령어', '도움', 'help'],
description: '기본적인 사용ㅂ법이에요.', description: '기본적인 사용ㅂ법이에요.',
detailedDescription: {
usage: '머핀아 도움말 [명령어]',
examples: ['머핀아 도움말', '머핀아 도움말 배워'],
},
}) })
export default class extends Command { export default class extends Command {
public async messageRun(msg: Message) { public async messageRun(msg: Message, args: Args) {
const commandList: string[] = [] 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 => { this.container.stores.get('commands').forEach(module => {
commandList.push(module.name) commandList.push(module.name)
}) })
await msg.reply({ await msg.reply({
embeds: [ embeds: [
{ {
title: '머핀봇의 도움말', title: '머핀봇의 도움말',
description: codeBlock( description: codeBlock(
'md', 'md',
commandList.map(item => `- ${item}`).join('\n'), commandList.map(item => `- ${item}`).join('\n'),
), ),
footer: { footer: {
text: `머핀봇 버전: ${version}`, 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: '배워', name: '배워',
aliases: ['공부'], aliases: ['공부'],
description: '단어를 가르치는 명령ㅇ어에요.', description: '단어를 가르치는 명령ㅇ어에요.',
detailedDescription: {
usage: '머핀아 배워 (등록할 단어) (대답)',
examples: [
'머핀아 배워 안녕 안녕!',
'머핀아 배워 "야 죽을래?" "아니요 ㅠㅠㅠ"',
'머핀아 배워 미간은_누구야? 이봇의_개발자요',
],
},
}) })
export default class extends Command { export default class extends Command {
public async messageRun(msg: Message, args: Args) { public async messageRun(msg: Message, args: Args) {

View file

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

View file

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