3.0.0-Cake #5

Merged
migan merged 33 commits from release/3.0.0 into main 2024-08-14 23:16:30 +09:00
12 changed files with 56 additions and 32 deletions
Showing only changes of commit 2517d50bec - Show all commits

View file

@ -1,7 +1,8 @@
{ {
"bot": { "bot": {
"owner_ID": "", "owner_ID": "",
"token": "" "token": "",
"prefix": ""
}, },
"train": { "train": {
"user_ID": "" "user_ID": ""

View file

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

View file

@ -5,10 +5,11 @@ 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 = config.bot.prefix
container.version = version container.version = version
container.database = new MaaDatabase() container.database = new MaaDatabase()
container.chatBot = new ChatBot(container.database) container.chatBot = new ChatBot(container.database)
container.dokdoAliases = ['dokdo', 'dok', 'Dokdo', 'Dok', '테스트']
export default class MuffinBot extends SapphireClient { export default class MuffinBot extends SapphireClient {
public constructor() { public constructor() {
@ -38,6 +39,7 @@ declare module '@sapphire/pieces' {
chatBot: ChatBot chatBot: ChatBot
prefix: string prefix: string
version: string version: string
dokdoAliases: string[]
config: { config: {
bot: { bot: {
owner_ID: Snowflake owner_ID: Snowflake

View file

@ -5,7 +5,11 @@ import {
codeBlock, codeBlock,
} from 'discord.js' } from 'discord.js'
import { ApplyOptions } from '@sapphire/decorators' import { ApplyOptions } from '@sapphire/decorators'
import { Args, Command } from '@sapphire/framework' import {
Args,
Command,
DetailedDescriptionCommandObject,
} from '@sapphire/framework'
import { type LearnData } from '../modules' import { type LearnData } from '../modules'
@ApplyOptions<Command.Options>({ @ApplyOptions<Command.Options>({
@ -28,7 +32,9 @@ export default class extends Command {
) )
if (!command) { if (!command) {
return await msg.channel.send('사용법: \n```머핀아 삭제 (지울 단어)```') return await msg.channel.send(
`사용법: \n\`\`\`${(this.detailedDescription as DetailedDescriptionCommandObject).usage}\`\`\``,
)
} }
if (!datas) { if (!datas) {

View file

@ -21,13 +21,13 @@ export default class extends Command {
const commandList: string[] = [] 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} - ${module.description}`)
}) })
await msg.reply({ await msg.reply({
embeds: [ embeds: [
{ {
title: '머핀봇의 도움말', title: `${this.container.client.user?.username}의 도움말`,
description: codeBlock( description: codeBlock(
'md', 'md',
commandList.map(item => `- ${item}`).join('\n'), commandList.map(item => `- ${item}`).join('\n'),
@ -35,6 +35,7 @@ export default class extends Command {
footer: { footer: {
text: `머핀봇 버전: ${this.container.version}`, text: `머핀봇 버전: ${this.container.version}`,
}, },
timestamp: new Date().toISOString(),
}, },
], ],
}) })
@ -46,7 +47,7 @@ export default class extends Command {
await msg.reply({ await msg.reply({
embeds: [ embeds: [
{ {
title: '머핀봇의 도움말', title: `${this.container.client.user?.username}의 도움말`,
description: `명령어: ${name}`, description: `명령어: ${name}`,
fields: [ fields: [
{ {
@ -76,6 +77,9 @@ export default class extends Command {
inline: false, inline: false,
}, },
], ],
footer: {
text: `머핀봇 버전: ${this.container.version}`,
},
timestamp: new Date().toISOString(), timestamp: new Date().toISOString(),
}, },
], ],

View file

@ -1,6 +1,6 @@
import { Args, Command } from '@sapphire/framework' import { type Args, Command } from '@sapphire/framework'
import { codeBlock, type Message } from 'discord.js'
import { ApplyOptions } from '@sapphire/decorators' import { ApplyOptions } from '@sapphire/decorators'
import { type Message } from 'discord.js'
@ApplyOptions<Command.Options>({ @ApplyOptions<Command.Options>({
name: '배워', name: '배워',
@ -17,6 +17,7 @@ import { type Message } from 'discord.js'
}) })
export default class extends Command { export default class extends Command {
public async messageRun(msg: Message, args: Args) { public async messageRun(msg: Message, args: Args) {
if (typeof this.detailedDescription === 'string') return
const config = this.container.config const config = this.container.config
const command = (await args.pick('string').catch(() => null))?.replaceAll( const command = (await args.pick('string').catch(() => null))?.replaceAll(
'_', '_',
@ -28,28 +29,27 @@ export default class extends Command {
) )
if (!command || !result) { if (!command || !result) {
return await msg.reply( return await msg.reply(
'```\n사용법: 머핀아 배워 (등록할 단어) (대답)\n예시:\n머핀아 배워 안녕 안녕!\n머핀아 배워 "야 죽을래?" "아니요 ㅠㅠㅠ"\n머핀아 배워 미간은_누구야? 이봇의_개발자요\n```', codeBlock(
'md',
`사용법: ${this.detailedDescription}
예시: ${this.detailedDescription.examples?.map(example => example).join('\n')}`,
),
) )
} }
const commands: string[] = [] const commands: string[] = []
const aliases: string[] = [] const aliases: string[] = []
this.container.stores.get('commands').forEach(module => { this.container.stores.get('commands').forEach(module => {
commands.push(module.name) commands.push(module.name)
module.aliases.forEach(alias => { module.aliases.forEach(alias => aliases.push(alias))
aliases.push(alias)
})
}) })
const ignore = [ const ignore = [
...commands, ...commands,
...aliases, ...aliases,
...this.container.dokdoAliases,
'미간', '미간',
'Migan', 'Migan',
'migan', 'migan',
'간미', '간미',
'dokdo',
'dok',
'Dokdo',
'Dok',
] ]
const disallowed = ['@everyone', '@here', `<@${config.bot.owner_ID}>`] const disallowed = ['@everyone', '@here', `<@${config.bot.owner_ID}>`]
const db = this.container.database const db = this.container.database
@ -67,9 +67,9 @@ export default class extends Command {
} }
await db.learn.insert({ await db.learn.insert({
user_id: msg.author.id,
command, command,
result, result,
user_id: msg.author.id,
}) })
await msg.reply(`${command}을/를 배웠ㅇ어요.`) await msg.reply(`${command}을/를 배웠ㅇ어요.`)
} }

View file

@ -7,8 +7,8 @@ import { Command } from '@sapphire/framework'
aliases: ['list', '목록'], aliases: ['list', '목록'],
description: '당신이 가ㄹ르쳐준 단어를 나열해요.', description: '당신이 가ㄹ르쳐준 단어를 나열해요.',
detailedDescription: { detailedDescription: {
usage: '머핀아 리스트' usage: '머핀아 리스트',
} },
}) })
export default class extends Command { export default class extends Command {
public async messageRun(msg: Message<boolean>) { public async messageRun(msg: Message<boolean>) {
@ -29,7 +29,7 @@ export default class extends Command {
await msg.reply({ await msg.reply({
embeds: [ embeds: [
{ {
title: '지식', title: `${msg.author.username}님의 지식`,
description: `총합: ${data.length}\n${codeBlock( description: `총합: ${data.length}\n${codeBlock(
'md', 'md',
list.map(item => `- ${item}`).join('\n'), list.map(item => `- ${item}`).join('\n'),

View file

@ -2,6 +2,6 @@ import { Listener } from '@sapphire/framework'
export default class extends Listener { export default class extends Listener {
public async run(debug: string) { public async run(debug: string) {
this.container.logger.debug(debug) this.container.logger.debug(`[MuffinBot] ${debug}`)
} }
} }

View file

@ -5,21 +5,20 @@ import Dokdo from 'dokdo'
export default class extends Listener { export default class extends Listener {
public async run(msg: Message) { public async run(msg: Message) {
const prefix = this.container.prefix
const dokdo = new Dokdo(this.container.client, { const dokdo = new Dokdo(this.container.client, {
aliases: ['dokdo', 'dok'], aliases: ['dokdo', 'dok'],
owners: [this.container.config.bot.owner_ID], owners: [this.container.config.bot.owner_ID],
prefix: prefix,
noPerm, noPerm,
prefix: this.container.prefix,
}) })
if (msg.author.bot) return if (msg.author.bot) return
if (msg.content.startsWith(this.container.prefix)) { if (msg.content.startsWith(prefix)) {
const args = msg.content const args = msg.content.slice(prefix.length).trim().split(/ +/g)
.slice(this.container.prefix.length)
.trim()
.split(/ +/g)
this.container.logger.debug(`[ChatBot] command: ${args.join(' ')}`) this.container.logger.debug(`[ChatBot] command: ${args.join(' ')}`)
if (args[0].startsWith('dokdo') || args[0].startsWith('dok')) {
if (dokdo.options.aliases?.includes(args[0])) {
await dokdo.run(msg) await dokdo.run(msg)
} else { } else {
if (!this.container.stores.get('commands').get(args[0])) { if (!this.container.stores.get('commands').get(args[0])) {

View file

@ -15,6 +15,6 @@ export default class extends Listener {
setStatus() setStatus()
setInterval(() => setStatus(), 600000) setInterval(() => setStatus(), 600000)
this.container.logger.info(`[MuffinBotClient] 먹힐 준ㅂ비 완료`) this.container.logger.info(`[MuffinBot] 먹힐 준ㅂ비 완료`)
} }
} }

View file

@ -59,7 +59,7 @@ export default class ChatBot {
if (!(msg.channel as TextChannel).nsfw) return if (!(msg.channel as TextChannel).nsfw) return
if (!msg.content.startsWith(prefix)) return if (!msg.content.startsWith(prefix)) return
const persona = `user:${msg.author.username.slice(0, 50).toLowerCase()}` const persona = `user:${msg.author.username.slice(0, 50).toLowerCase()}`
const text = msg.content.replace('머핀아 ', '') const text = msg.content.replace(prefix, '')
await this.db.nsfwContent.insert({ await this.db.nsfwContent.insert({
text, text,
persona, persona,

12
src/modules/wordRelay.ts Normal file
View file

@ -0,0 +1,12 @@
import { type Message, PermissionFlagsBits } from 'discord.js'
export class WordRelay {
public async startGame(msg: Message<true>) {
if (
msg.guild.members.me?.permissions.has(
PermissionFlagsBits.CreatePublicThreads,
)
)
return msg.reply('제게 공개 스레드 만들기 권한ㅇ이 없어요.')
}
}