2023-01-23 13:53:02 +00:00
|
|
|
import { ActivityType, Client, GatewayIntentBits } from 'discord.js'
|
|
|
|
import ChatBot from './ChatBot'
|
|
|
|
import { join } from 'node:path'
|
|
|
|
import 'dotenv/config'
|
|
|
|
|
|
|
|
export default class MuffinAI extends Client {
|
|
|
|
private chatBot = new ChatBot(join(__dirname, '..', 'db', 'db.sqlite3'))
|
|
|
|
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
|
|
|
|
if (!msg.content.startsWith('머핀아 ')) return
|
|
|
|
|
2023-01-24 06:59:07 +00:00
|
|
|
this.chatBot.getResponse(msg, true)
|
2023-01-23 13:53:02 +00:00
|
|
|
})
|
|
|
|
return super.login()
|
|
|
|
}
|
|
|
|
}
|