mirror of
https://github.com/koreanbots/core.git
synced 2025-12-15 06:10:22 +00:00
fix: vote api not working properly
This commit is contained in:
parent
160fe4ecb3
commit
b90fa8f11e
@ -507,10 +507,15 @@ async function getVote(
|
||||
targetID: string,
|
||||
type: 'bot' | 'server'
|
||||
): Promise<number | null> {
|
||||
const user = await knex('users').select(['votes']).where({ id: userID })
|
||||
if (user.length === 0) return null
|
||||
const data = JSON.parse(user[0].votes)
|
||||
return data[`${type}:${targetID}`] || 0
|
||||
const [vote] = await knex('votes')
|
||||
.select('last_voted')
|
||||
.where({
|
||||
user_id: userID,
|
||||
target: targetID,
|
||||
type: type === 'bot' ? ObjectType.Bot : ObjectType.Server,
|
||||
})
|
||||
if (!vote) return null
|
||||
return vote.last_voted.getTime() || 0
|
||||
}
|
||||
|
||||
async function getWebhook(id: string, type: 'bots' | 'servers'): Promise<Webhook | null> {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user