fix: hard coding
This commit is contained in:
parent
7295c9ffff
commit
2517d50bec
12 changed files with 56 additions and 32 deletions
|
@ -1,7 +1,8 @@
|
|||
{
|
||||
"bot": {
|
||||
"owner_ID": "",
|
||||
"token": ""
|
||||
"token": "",
|
||||
"prefix": ""
|
||||
},
|
||||
"train": {
|
||||
"user_ID": ""
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "muffinbot",
|
||||
"version": "3.0.0-cake.d240625a",
|
||||
"version": "3.0.0-cake.d240626a",
|
||||
"main": "dist/index.js",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
|
|
|
@ -5,10 +5,11 @@ import { version } from '../package.json'
|
|||
import config from '../config.json'
|
||||
|
||||
container.config = config
|
||||
container.prefix = '머핀아 '
|
||||
container.prefix = config.bot.prefix
|
||||
container.version = version
|
||||
container.database = new MaaDatabase()
|
||||
container.chatBot = new ChatBot(container.database)
|
||||
container.dokdoAliases = ['dokdo', 'dok', 'Dokdo', 'Dok', '테스트']
|
||||
|
||||
export default class MuffinBot extends SapphireClient {
|
||||
public constructor() {
|
||||
|
@ -38,6 +39,7 @@ declare module '@sapphire/pieces' {
|
|||
chatBot: ChatBot
|
||||
prefix: string
|
||||
version: string
|
||||
dokdoAliases: string[]
|
||||
config: {
|
||||
bot: {
|
||||
owner_ID: Snowflake
|
||||
|
|
|
@ -5,7 +5,11 @@ import {
|
|||
codeBlock,
|
||||
} from 'discord.js'
|
||||
import { ApplyOptions } from '@sapphire/decorators'
|
||||
import { Args, Command } from '@sapphire/framework'
|
||||
import {
|
||||
Args,
|
||||
Command,
|
||||
DetailedDescriptionCommandObject,
|
||||
} from '@sapphire/framework'
|
||||
import { type LearnData } from '../modules'
|
||||
|
||||
@ApplyOptions<Command.Options>({
|
||||
|
@ -28,7 +32,9 @@ export default class extends Command {
|
|||
)
|
||||
|
||||
if (!command) {
|
||||
return await msg.channel.send('사용법: \n```머핀아 삭제 (지울 단어)```')
|
||||
return await msg.channel.send(
|
||||
`사용법: \n\`\`\`${(this.detailedDescription as DetailedDescriptionCommandObject).usage}\`\`\``,
|
||||
)
|
||||
}
|
||||
|
||||
if (!datas) {
|
||||
|
|
|
@ -21,13 +21,13 @@ export default class extends Command {
|
|||
const commandList: string[] = []
|
||||
|
||||
this.container.stores.get('commands').forEach(module => {
|
||||
commandList.push(module.name)
|
||||
commandList.push(`${module.name} - ${module.description}`)
|
||||
})
|
||||
|
||||
await msg.reply({
|
||||
embeds: [
|
||||
{
|
||||
title: '머핀봇의 도움말',
|
||||
title: `${this.container.client.user?.username}의 도움말`,
|
||||
description: codeBlock(
|
||||
'md',
|
||||
commandList.map(item => `- ${item}`).join('\n'),
|
||||
|
@ -35,6 +35,7 @@ export default class extends Command {
|
|||
footer: {
|
||||
text: `머핀봇 버전: ${this.container.version}`,
|
||||
},
|
||||
timestamp: new Date().toISOString(),
|
||||
},
|
||||
],
|
||||
})
|
||||
|
@ -46,7 +47,7 @@ export default class extends Command {
|
|||
await msg.reply({
|
||||
embeds: [
|
||||
{
|
||||
title: '머핀봇의 도움말',
|
||||
title: `${this.container.client.user?.username}의 도움말`,
|
||||
description: `명령어: ${name}`,
|
||||
fields: [
|
||||
{
|
||||
|
@ -76,6 +77,9 @@ export default class extends Command {
|
|||
inline: false,
|
||||
},
|
||||
],
|
||||
footer: {
|
||||
text: `머핀봇 버전: ${this.container.version}`,
|
||||
},
|
||||
timestamp: new Date().toISOString(),
|
||||
},
|
||||
],
|
||||
|
|
|
@ -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 { type Message } from 'discord.js'
|
||||
|
||||
@ApplyOptions<Command.Options>({
|
||||
name: '배워',
|
||||
|
@ -17,6 +17,7 @@ import { type Message } from 'discord.js'
|
|||
})
|
||||
export default class extends Command {
|
||||
public async messageRun(msg: Message, args: Args) {
|
||||
if (typeof this.detailedDescription === 'string') return
|
||||
const config = this.container.config
|
||||
const command = (await args.pick('string').catch(() => null))?.replaceAll(
|
||||
'_',
|
||||
|
@ -28,28 +29,27 @@ export default class extends Command {
|
|||
)
|
||||
if (!command || !result) {
|
||||
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 aliases: string[] = []
|
||||
this.container.stores.get('commands').forEach(module => {
|
||||
commands.push(module.name)
|
||||
module.aliases.forEach(alias => {
|
||||
aliases.push(alias)
|
||||
})
|
||||
module.aliases.forEach(alias => aliases.push(alias))
|
||||
})
|
||||
const ignore = [
|
||||
...commands,
|
||||
...aliases,
|
||||
...this.container.dokdoAliases,
|
||||
'미간',
|
||||
'Migan',
|
||||
'migan',
|
||||
'간미',
|
||||
'dokdo',
|
||||
'dok',
|
||||
'Dokdo',
|
||||
'Dok',
|
||||
]
|
||||
const disallowed = ['@everyone', '@here', `<@${config.bot.owner_ID}>`]
|
||||
const db = this.container.database
|
||||
|
@ -67,9 +67,9 @@ export default class extends Command {
|
|||
}
|
||||
|
||||
await db.learn.insert({
|
||||
user_id: msg.author.id,
|
||||
command,
|
||||
result,
|
||||
user_id: msg.author.id,
|
||||
})
|
||||
await msg.reply(`${command}을/를 배웠ㅇ어요.`)
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@ import { Command } from '@sapphire/framework'
|
|||
aliases: ['list', '목록'],
|
||||
description: '당신이 가ㄹ르쳐준 단어를 나열해요.',
|
||||
detailedDescription: {
|
||||
usage: '머핀아 리스트'
|
||||
}
|
||||
usage: '머핀아 리스트',
|
||||
},
|
||||
})
|
||||
export default class extends Command {
|
||||
public async messageRun(msg: Message<boolean>) {
|
||||
|
@ -29,7 +29,7 @@ export default class extends Command {
|
|||
await msg.reply({
|
||||
embeds: [
|
||||
{
|
||||
title: '지식',
|
||||
title: `${msg.author.username}님의 지식`,
|
||||
description: `총합: ${data.length}개\n${codeBlock(
|
||||
'md',
|
||||
list.map(item => `- ${item}`).join('\n'),
|
||||
|
|
|
@ -2,6 +2,6 @@ import { Listener } from '@sapphire/framework'
|
|||
|
||||
export default class extends Listener {
|
||||
public async run(debug: string) {
|
||||
this.container.logger.debug(debug)
|
||||
this.container.logger.debug(`[MuffinBot] ${debug}`)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,21 +5,20 @@ import Dokdo from 'dokdo'
|
|||
|
||||
export default class extends Listener {
|
||||
public async run(msg: Message) {
|
||||
const prefix = this.container.prefix
|
||||
const dokdo = new Dokdo(this.container.client, {
|
||||
aliases: ['dokdo', 'dok'],
|
||||
owners: [this.container.config.bot.owner_ID],
|
||||
prefix: prefix,
|
||||
noPerm,
|
||||
prefix: this.container.prefix,
|
||||
})
|
||||
if (msg.author.bot) return
|
||||
if (msg.content.startsWith(this.container.prefix)) {
|
||||
const args = msg.content
|
||||
.slice(this.container.prefix.length)
|
||||
.trim()
|
||||
.split(/ +/g)
|
||||
if (msg.content.startsWith(prefix)) {
|
||||
const args = msg.content.slice(prefix.length).trim().split(/ +/g)
|
||||
|
||||
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)
|
||||
} else {
|
||||
if (!this.container.stores.get('commands').get(args[0])) {
|
||||
|
|
|
@ -15,6 +15,6 @@ export default class extends Listener {
|
|||
setStatus()
|
||||
setInterval(() => setStatus(), 600000)
|
||||
|
||||
this.container.logger.info(`[MuffinBotClient] 먹힐 준ㅂ비 완료`)
|
||||
this.container.logger.info(`[MuffinBot] 먹힐 준ㅂ비 완료`)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ export default class ChatBot {
|
|||
if (!(msg.channel as TextChannel).nsfw) return
|
||||
if (!msg.content.startsWith(prefix)) return
|
||||
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({
|
||||
text,
|
||||
persona,
|
||||
|
|
12
src/modules/wordRelay.ts
Normal file
12
src/modules/wordRelay.ts
Normal 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('제게 공개 스레드 만들기 권한ㅇ이 없어요.')
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue