kill count

This commit is contained in:
smsteel 2019-02-11 16:30:29 +03:00
parent 76bd731623
commit 975791b83e
2 changed files with 5 additions and 4 deletions

3
bot.js
View File

@ -33,9 +33,10 @@ bot.command(
))
)
bot.hears(
/^kills (.+)$/,
/^\/kills[ =](.+)$/,
ctx => getAllKills(ctx.match[1])
.then(allKills => {
console.log(allKills)
if (!allKills) {
ctx.reply('Не найдено')
return

View File

@ -59,12 +59,12 @@ const get = (sql, params, column, defaultParam = null) => new Promise((resolve,
})
})
const all = (sql, params = []) => new Promise((resolve, reject) => {
const all = (sql, params = [], defaultParam = null) => new Promise((resolve, reject) => {
db.all(sql, params, (err, rows) => {
if (err) {
reject(err)
} else {
resolve(rows)
resolve(rows.length ? rows : defaultParam)
}
})
})
@ -93,7 +93,7 @@ export const getKillCount = (displayName, entityName) => get(
'killCount',
0
)
export const getAllKills = displayName => all('SELECT * FROM playerKills WHERE displayName = ? ORDER BY displayName ASC', [ displayName ])
export const getAllKills = displayName => all('SELECT * FROM playerKills WHERE displayName = ?', [ displayName ])
export const saveLevelUp = (displayName, levelUpCount) => run(
`INSERT OR REPLACE INTO levelUps (displayName, levelUpCount) VALUES (?, ?)`,