kill count
This commit is contained in:
parent
76bd731623
commit
975791b83e
3
bot.js
3
bot.js
@ -33,9 +33,10 @@ bot.command(
|
|||||||
))
|
))
|
||||||
)
|
)
|
||||||
bot.hears(
|
bot.hears(
|
||||||
/^kills (.+)$/,
|
/^\/kills[ =](.+)$/,
|
||||||
ctx => getAllKills(ctx.match[1])
|
ctx => getAllKills(ctx.match[1])
|
||||||
.then(allKills => {
|
.then(allKills => {
|
||||||
|
console.log(allKills)
|
||||||
if (!allKills) {
|
if (!allKills) {
|
||||||
ctx.reply('Не найдено')
|
ctx.reply('Не найдено')
|
||||||
return
|
return
|
||||||
|
@ -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) => {
|
db.all(sql, params, (err, rows) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
reject(err)
|
reject(err)
|
||||||
} else {
|
} else {
|
||||||
resolve(rows)
|
resolve(rows.length ? rows : defaultParam)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -93,7 +93,7 @@ export const getKillCount = (displayName, entityName) => get(
|
|||||||
'killCount',
|
'killCount',
|
||||||
0
|
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(
|
export const saveLevelUp = (displayName, levelUpCount) => run(
|
||||||
`INSERT OR REPLACE INTO levelUps (displayName, levelUpCount) VALUES (?, ?)`,
|
`INSERT OR REPLACE INTO levelUps (displayName, levelUpCount) VALUES (?, ?)`,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user