fix: Can not send empty message

This commit is contained in:
Siwoo Jeon 2023-01-24 12:55:58 +09:00
parent 81fb27cb0a
commit dfd05ae9de
Signed by: migan
GPG key ID: C4151385FFD2082A
3 changed files with 9 additions and 9 deletions

View file

@ -6,4 +6,4 @@ RUN yarn install
RUN yarn build
CMD ["yarn", "start"]
ENTRYPOINT ["yarn", "start"]

View file

@ -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()

View file

@ -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()
}