2023-01-23 13:53:02 +00:00
|
|
|
import { ActivityType, Client, GatewayIntentBits } from 'discord.js'
|
2023-01-24 07:43:52 +00:00
|
|
|
import ChatBot from './ChatBot.js'
|
|
|
|
import { join, dirname } from 'node:path'
|
|
|
|
import { fileURLToPath } from 'node:url'
|
2023-01-24 11:27:40 +00:00
|
|
|
import Dokdo from 'dokdo'
|
2023-01-23 13:53:02 +00:00
|
|
|
import 'dotenv/config'
|
|
|
|
|
|
|
|
export default class MuffinAI extends Client {
|
2023-01-24 07:43:52 +00:00
|
|
|
private chatBot = new ChatBot(
|
|
|
|
join(dirname(fileURLToPath(import.meta.url)), '..', 'db', 'db.sqlite3')
|
|
|
|
)
|
2023-01-23 13:53:02 +00:00
|
|
|
public constructor() {
|
|
|
|
super({
|
|
|
|
intents: [
|
|
|
|
GatewayIntentBits.Guilds,
|
|
|
|
GatewayIntentBits.GuildMessages,
|
|
|
|
GatewayIntentBits.MessageContent,
|
|
|
|
],
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
public override login(): Promise<string> {
|
2023-01-24 06:59:07 +00:00
|
|
|
this.chatBot.train(this)
|
2023-01-23 13:53:02 +00:00
|
|
|
this.once('ready', client => {
|
|
|
|
client.user!.setActivity({
|
|
|
|
type: ActivityType.Playing,
|
|
|
|
name: 'ㅅ살려주세요..!',
|
|
|
|
})
|
2023-01-23 14:00:35 +00:00
|
|
|
console.log(`먹힐 준비 완료`)
|
2023-01-24 03:55:58 +00:00
|
|
|
}).on('messageCreate', msg => {
|
2023-01-23 13:53:02 +00:00
|
|
|
if (msg.author.bot) return
|
2023-01-24 11:27:40 +00:00
|
|
|
new Dokdo(this, {
|
|
|
|
prefix: '멒힌아 ',
|
|
|
|
noPerm: msg =>
|
|
|
|
msg.reply({
|
|
|
|
content: '당신은 내 남자친구가 아니야!',
|
|
|
|
allowedMentions: {
|
|
|
|
repliedUser: false,
|
|
|
|
parse: [],
|
|
|
|
users: [],
|
|
|
|
roles: [],
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
aliases: ['테스트'],
|
|
|
|
owners: ['415135882006495242'],
|
|
|
|
}).run(msg)
|
2023-01-24 10:54:49 +00:00
|
|
|
if (msg.content.startsWith('머핀아 ')) this.chatBot.getResponse(msg, true)
|
|
|
|
else if (msg.content.startsWith('멒힌아 봇꺼')) {
|
|
|
|
if (msg.author.id !== '415135882006495242') {
|
|
|
|
msg.reply({
|
|
|
|
content: '당신은 내 남자친구가 아니야!',
|
|
|
|
allowedMentions: {
|
|
|
|
repliedUser: false,
|
|
|
|
parse: [],
|
|
|
|
users: [],
|
|
|
|
roles: [],
|
|
|
|
},
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
this.destroy()
|
|
|
|
} else return
|
2023-01-23 13:53:02 +00:00
|
|
|
})
|
|
|
|
return super.login()
|
|
|
|
}
|
2023-01-24 10:54:49 +00:00
|
|
|
|
|
|
|
public override destroy() {
|
|
|
|
this.chatBot.destroy()
|
|
|
|
super.destroy()
|
|
|
|
}
|
2023-01-23 13:53:02 +00:00
|
|
|
}
|