fix: Can not send empty message
This commit is contained in:
parent
81fb27cb0a
commit
dfd05ae9de
3 changed files with 9 additions and 9 deletions
|
@ -6,4 +6,4 @@ RUN yarn install
|
||||||
RUN yarn build
|
RUN yarn build
|
||||||
|
|
||||||
|
|
||||||
CMD ["yarn", "start"]
|
ENTRYPOINT ["yarn", "start"]
|
|
@ -5,17 +5,17 @@ import { Message } from 'discord.js'
|
||||||
export default class ChatBot {
|
export default class ChatBot {
|
||||||
private db: sqlite3.Database
|
private db: sqlite3.Database
|
||||||
public constructor(dbPath: string) {
|
public constructor(dbPath: string) {
|
||||||
const a = sqlite3.verbose()
|
this.db = new sqlite3.Database(dbPath)
|
||||||
this.db = new a.Database(dbPath)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getResponse(msg: Message) {
|
public getResponse(msg: Message) {
|
||||||
this.db.all('select * from statement', [], (err, rows) => {
|
this.db.all('select * from statement', [], (err, rows: ResponseData[]) => {
|
||||||
const a = msg.content.replace('머핀아', '')
|
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
|
const a = msg.content.replace('머핀아', '')
|
||||||
const data: ResponseData[] = [...rows]
|
const data: ResponseData[] = [...rows]
|
||||||
data.sort(() => Math.random() - 0.5)
|
data.sort(() => Math.random() - 0.5)
|
||||||
const r = data[0].text
|
let r = data[0].text
|
||||||
|
if (!r) r = '살ㄹ려주세요'
|
||||||
console.log(`⌨️ㅣ${a}`)
|
console.log(`⌨️ㅣ${a}`)
|
||||||
console.log(`🍰ㅣ${r}`)
|
console.log(`🍰ㅣ${r}`)
|
||||||
msg.channel.sendTyping()
|
msg.channel.sendTyping()
|
||||||
|
|
|
@ -22,11 +22,11 @@ export default class MuffinAI extends Client {
|
||||||
name: 'ㅅ살려주세요..!',
|
name: 'ㅅ살려주세요..!',
|
||||||
})
|
})
|
||||||
console.log(`먹힐 준비 완료`)
|
console.log(`먹힐 준비 완료`)
|
||||||
}).on('messageCreate', async msg => {
|
}).on('messageCreate', msg => {
|
||||||
if (msg.author.bot) return
|
if (msg.author.bot) return
|
||||||
if (!msg.content.startsWith('머핀아 ')) return
|
if (!msg.content.startsWith('머핀아 ')) return
|
||||||
|
|
||||||
await this.chatBot.getResponse(msg)
|
this.chatBot.getResponse(msg)
|
||||||
})
|
})
|
||||||
return super.login()
|
return super.login()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue