diff --git a/Dockerfile b/Dockerfile index e743558..0c658a0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,4 +6,4 @@ RUN yarn install RUN yarn build -CMD ["yarn", "start"] \ No newline at end of file +ENTRYPOINT ["yarn", "start"] \ No newline at end of file diff --git a/src/ChatBot.ts b/src/ChatBot.ts index f35e342..b211d26 100644 --- a/src/ChatBot.ts +++ b/src/ChatBot.ts @@ -5,17 +5,17 @@ import { Message } from 'discord.js' export default class ChatBot { private db: sqlite3.Database public constructor(dbPath: string) { - const a = sqlite3.verbose() - this.db = new a.Database(dbPath) + this.db = new sqlite3.Database(dbPath) } - public async getResponse(msg: Message) { - this.db.all('select * from statement', [], (err, rows) => { - const a = msg.content.replace('머핀아', '') + public getResponse(msg: Message) { + this.db.all('select * from statement', [], (err, rows: ResponseData[]) => { if (err) throw err + const a = msg.content.replace('머핀아', '') const data: ResponseData[] = [...rows] data.sort(() => Math.random() - 0.5) - const r = data[0].text + let r = data[0].text + if (!r) r = '살ㄹ려주세요' console.log(`⌨️ㅣ${a}`) console.log(`🍰ㅣ${r}`) msg.channel.sendTyping() diff --git a/src/Client.ts b/src/Client.ts index 3a2bef1..8e37bb4 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -22,11 +22,11 @@ export default class MuffinAI extends Client { name: 'ㅅ살려주세요..!', }) console.log(`먹힐 준비 완료`) - }).on('messageCreate', async msg => { + }).on('messageCreate', msg => { if (msg.author.bot) return if (!msg.content.startsWith('머핀아 ')) return - await this.chatBot.getResponse(msg) + this.chatBot.getResponse(msg) }) return super.login() }