.
This commit is contained in:
parent
12fe84bb2d
commit
a70711902a
3 changed files with 9 additions and 5 deletions
|
@ -7,7 +7,9 @@ export default class extends Command {
|
|||
}
|
||||
public async execute(msg: Message, args: string[]) {
|
||||
const conn = await database.getConnection()
|
||||
const [rows] = await conn.query<ResponseData[]>('SELECT * FROM statement;')
|
||||
const [rows] = await conn.execute<ResponseData[]>(
|
||||
'SELECT * FROM statement;'
|
||||
)
|
||||
const muffin: ResponseData[] = []
|
||||
rows.forEach(row => {
|
||||
if (row.persona === 'muffin') muffin.push(row)
|
||||
|
|
|
@ -6,7 +6,9 @@ export default class ChatBot {
|
|||
const conn = await database.getConnection()
|
||||
const request = msg.content.replace('머핀아 ', '')
|
||||
console.log(`req: ${request}`)
|
||||
const [rows] = await conn.query<ResponseData[]>('SELECT * FROM statement;')
|
||||
const [rows] = await conn.execute<ResponseData[]>(
|
||||
'SELECT * FROM statement;'
|
||||
)
|
||||
let response = rows[Math.floor(Math.random() * rows.length)].text
|
||||
if (!response) response = '살ㄹ려주세요'
|
||||
console.log(`res: ${response}`)
|
||||
|
@ -20,7 +22,7 @@ export default class ChatBot {
|
|||
const conn = await database.getConnection()
|
||||
if (msg.author.id === '1026185545837191238') {
|
||||
const response = await this.getResponse(msg)
|
||||
const [rows] = await conn.query<ResponseData[]>(
|
||||
const [rows] = await conn.execute<ResponseData[]>(
|
||||
'SELECT * FROM statement;'
|
||||
)
|
||||
try {
|
||||
|
|
|
@ -4,9 +4,9 @@ import { createConnection } from 'mysql2/promise'
|
|||
describe('test database system', () => {
|
||||
test('Validate rows', async () => {
|
||||
return database.getConnection().then(async conn1 => {
|
||||
const [rows1] = await conn1.query('SELECT * FROM statement;')
|
||||
const [rows1] = await conn1.execute('SELECT * FROM statement;')
|
||||
const conn2 = await createConnection(config)
|
||||
const [rows2] = await conn2.query(`SELECT * FROM statement;`)
|
||||
const [rows2] = await conn2.execute(`SELECT * FROM statement;`)
|
||||
expect(rows1).toEqual(rows2)
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue